diff mbox series

selftests/futex: fix build for clang

Message ID 20220909110709.1827374-1-ricardo.canuelo@collabora.com
State Superseded
Headers show
Series selftests/futex: fix build for clang | expand

Commit Message

Ricardo Cañuelo Sept. 9, 2022, 11:07 a.m. UTC
Don't use the test-specific header files as source files to force a
target dependency, as clang will complain if more than one source file
is used for a compile command with a single '-o' flag.

Use the proper Makefile variables instead as defined in
tools/testing/selftests/lib.mk.

Signed-off-by: Ricardo Cañuelo <ricardo.canuelo@collabora.com>
---
 tools/testing/selftests/futex/functional/Makefile | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

André Almeida Sept. 14, 2022, 9:53 a.m. UTC | #1
Hi Ricardo :)

On 2022-09-09 13:07, Ricardo Cañuelo wrote:
> Don't use the test-specific header files as source files to force a
> target dependency, as clang will complain if more than one source file
> is used for a compile command with a single '-o' flag.
> 
> Use the proper Makefile variables instead as defined in
> tools/testing/selftests/lib.mk.

Could you share how I can test this patch?

> 
> Signed-off-by: Ricardo Cañuelo <ricardo.canuelo@collabora.com>
> ---
>  tools/testing/selftests/futex/functional/Makefile | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/futex/functional/Makefile
> b/tools/testing/selftests/futex/functional/Makefile
> index 732149011692..5a0e0df8de9b 100644
> --- a/tools/testing/selftests/futex/functional/Makefile
> +++ b/tools/testing/selftests/futex/functional/Makefile
> @@ -3,11 +3,11 @@ INCLUDES := -I../include -I../../
> -I../../../../../usr/include/
>  CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES)
> $(KHDR_INCLUDES)
>  LDLIBS := -lpthread -lrt
>  
> -HEADERS := \
> +LOCAL_HDRS := \
>  	../include/futextest.h \
>  	../include/atomic.h \
>  	../include/logging.h
> -TEST_GEN_FILES := \
> +TEST_GEN_PROGS := \
>  	futex_wait_timeout \
>  	futex_wait_wouldblock \
>  	futex_requeue_pi \
> @@ -24,5 +24,3 @@ TEST_PROGS := run.sh
>  top_srcdir = ../../../../..
>  DEFAULT_INSTALL_HDR_PATH := 1
>  include ../../lib.mk
> -
> -$(TEST_GEN_FILES): $(HEADERS)
Ricardo Cañuelo Sept. 14, 2022, 1:47 p.m. UTC | #2
On mié, sep 14 2022 at 11:53:34, André Almeida <andrealmeid@igalia.com> wrote:

> Hi Ricardo :)

Hey Tony! Long time, haha. I hope you're doing fine.

> Could you share how I can test this patch?

Simply running `make CC=clang' in tools/testing/selftest/futex with and
without the patch on should highlight the differences:

Without the patch:

    $ make CC=clang
    make[1]: Entering directory '/root/linux-kselftest/tools/testing/selftests/futex/functional'
    make --no-builtin-rules ARCH=x86 -C ../../../../.. headers_install
    make[2]: Entering directory '/root/linux-kselftest'
      INSTALL ./usr/include
    make[2]: Leaving directory '/root/linux-kselftest'
    clang  -g -O2 -Wall -D_GNU_SOURCE -pthread -I../include -I../../ -I../../../../../usr/include/     futex_wait_timeout.c ../include/futextest.h ../include/atomic.h ../include/logging.h -lpthread -lrt -o /root/linux-kselftest/tools/testing/selftests/futex/functional/futex_wait_timeout
    clang: error: cannot specify -o when generating multiple output files
    make[1]: *** [../../lib.mk:152: /root/linux-kselftest/tools/testing/selftests/futex/functional/futex_wait_timeout] Error 1
    make[1]: Leaving directory '/root/linux-kselftest/tools/testing/selftests/futex/functional'


With the patch:

    $ make CC=clang
    make[1]: Entering directory '/root/linux-kselftest/tools/testing/selftests/futex/functional'
    make --no-builtin-rules ARCH=x86 -C ../../../../.. headers_install
    make[2]: Entering directory '/root/linux-kselftest'
      INSTALL ./usr/include
    make[2]: Leaving directory '/root/linux-kselftest'
    clang  -g -O2 -Wall -D_GNU_SOURCE -pthread -I../include -I../../ -I../../../../../usr/include/     futex_wait_timeout.c -lpthread -lrt -o /root/linux-kselftest/tools/testing/selftests/futex/functional/futex_wait_timeout
    clang  -g -O2 -Wall -D_GNU_SOURCE -pthread -I../include -I../../ -I../../../../../usr/include/     futex_wait_wouldblock.c -lpthread -lrt -o /root/linux-kselftest/tools/testing/selftests/futex/functional/futex_wait_wouldblock
    ...

I'm testing this with Clang v11, by the way.

Cheers,
Ricardo
diff mbox series

Patch

diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index 732149011692..5a0e0df8de9b 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -3,11 +3,11 @@  INCLUDES := -I../include -I../../ -I../../../../../usr/include/
 CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) $(KHDR_INCLUDES)
 LDLIBS := -lpthread -lrt
 
-HEADERS := \
+LOCAL_HDRS := \
 	../include/futextest.h \
 	../include/atomic.h \
 	../include/logging.h
-TEST_GEN_FILES := \
+TEST_GEN_PROGS := \
 	futex_wait_timeout \
 	futex_wait_wouldblock \
 	futex_requeue_pi \
@@ -24,5 +24,3 @@  TEST_PROGS := run.sh
 top_srcdir = ../../../../..
 DEFAULT_INSTALL_HDR_PATH := 1
 include ../../lib.mk
-
-$(TEST_GEN_FILES): $(HEADERS)