* [PATCH] selftests/rseq: Fix out-of-tree compilation
@ 2020-02-20 11:37 Michael Ellerman
2020-02-20 16:16 ` Mathieu Desnoyers
0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2020-02-20 11:37 UTC (permalink / raw)
To: linux-kselftest
Cc: skhan, linux-kernel, mathieu.desnoyers, peterz, paulmck, boqun.feng
Currently if you build with O=... the rseq tests don't build:
$ make O=$PWD/output -C tools/testing/selftests/ TARGETS=rseq
make: Entering directory '/linux/tools/testing/selftests'
...
make[1]: Entering directory '/linux/tools/testing/selftests/rseq'
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared -fPIC rseq.c -lpthread -o /linux/output/rseq/librseq.so
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c -lpthread -lrseq -o /linux/output/rseq/basic_test
/usr/bin/ld: cannot find -lrseq
collect2: error: ld returned 1 exit status
This is because the library search path points to the source
directory, not the output.
We can fix it by changing the library search path to $(OUTPUT).
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
This works in all cases.
With O= set:
$ make O=$PWD/output -C tools/testing/selftests/ TARGETS=rseq
...
make[1]: Entering directory '/linux/tools/testing/selftests/rseq'
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq -Wl,-rpath=./ basic_test.c -lpthread -lrseq -o /linux/output/rseq/basic_test
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq -Wl,-rpath=./ basic_percpu_ops_test.c -lpthread -lrseq -o /linux/output/rseq/basic_percpu_ops_test
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq -Wl,-rpath=./ param_test.c -lpthread -lrseq -o /linux/output/rseq/param_test
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq -Wl,-rpath=./ -DBENCHMARK param_test.c -lpthread -lrseq -o /linux/output/rseq/param_test_benchmark
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq -Wl,-rpath=./ -DRSEQ_COMPARE_TWICE param_test.c -lpthread -lrseq -o /linux/output/rseq/param_test_compare_twice
make[1]: Leaving directory '/linux/tools/testing/selftests/rseq'
make: Leaving directory '/linux/tools/testing/selftests'
And also without, in which case the selftest makefiles set OUTPUT to
the full path of the source directory:
$ make -C tools/testing/selftests/ TARGETS=rseq
...
make[1]: Entering directory '/linux/tools/testing/selftests/rseq'
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -shared -fPIC rseq.c -lpthread -o /linux/tools/testing/selftests/rseq/librseq.so
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ basic_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/basic_test
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ basic_percpu_ops_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/basic_percpu_ops_test
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ param_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/param_test
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -DBENCHMARK param_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/param_test_benchmark
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -DRSEQ_COMPARE_TWICE param_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/param_test_compare_twice
make[1]: Leaving directory '/linux/tools/testing/selftests/rseq'
make: Leaving directory '/linux/tools/testing/selftests'
And finally, it also works if you build directly in the rseq
directory, eg:
$ cd tools/testing/selftests/rseq
$ make
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -shared -fPIC rseq.c -lpthread -o /linux/tools/testing/selftests/rseq/librseq.so
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ basic_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/basic_test
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ basic_percpu_ops_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/basic_percpu_ops_test
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ param_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/param_test
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -DBENCHMARK param_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/param_test_benchmark
gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -DRSEQ_COMPARE_TWICE param_test.c -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/param_test_compare_twice
---
tools/testing/selftests/rseq/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/rseq/Makefile b/tools/testing/selftests/rseq/Makefile
index d6469535630a..708c1b345245 100644
--- a/tools/testing/selftests/rseq/Makefile
+++ b/tools/testing/selftests/rseq/Makefile
@@ -4,7 +4,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
CLANG_FLAGS += -no-integrated-as
endif
-CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ \
+CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L$(OUTPUT) -Wl,-rpath=./ \
$(CLANG_FLAGS)
LDLIBS += -lpthread
base-commit: 11a48a5a18c63fd7621bb050228cebf13566e4d8
--
2.21.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/rseq: Fix out-of-tree compilation
2020-02-20 11:37 [PATCH] selftests/rseq: Fix out-of-tree compilation Michael Ellerman
@ 2020-02-20 16:16 ` Mathieu Desnoyers
2020-02-20 16:17 ` Shuah Khan
0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Desnoyers @ 2020-02-20 16:16 UTC (permalink / raw)
To: Michael Ellerman, Shuah Khan
Cc: linux-kselftest, linux-kernel, Peter Zijlstra, paulmck, Boqun Feng
----- On Feb 20, 2020, at 6:37 AM, Michael Ellerman mpe@ellerman.id.au wrote:
> Currently if you build with O=... the rseq tests don't build:
>
> $ make O=$PWD/output -C tools/testing/selftests/ TARGETS=rseq
> make: Entering directory '/linux/tools/testing/selftests'
> ...
> make[1]: Entering directory '/linux/tools/testing/selftests/rseq'
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared
> -fPIC rseq.c -lpthread -o /linux/output/rseq/librseq.so
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
> basic_test.c -lpthread -lrseq -o /linux/output/rseq/basic_test
> /usr/bin/ld: cannot find -lrseq
> collect2: error: ld returned 1 exit status
>
> This is because the library search path points to the source
> directory, not the output.
>
> We can fix it by changing the library search path to $(OUTPUT).
Good catch!
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Shuah, can you pick this up please ?
Thanks,
Mathieu
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>
> This works in all cases.
>
> With O= set:
>
> $ make O=$PWD/output -C tools/testing/selftests/ TARGETS=rseq
> ...
> make[1]: Entering directory '/linux/tools/testing/selftests/rseq'
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq
> -Wl,-rpath=./ basic_test.c -lpthread -lrseq -o /linux/output/rseq/basic_test
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq
> -Wl,-rpath=./ basic_percpu_ops_test.c -lpthread -lrseq -o
> /linux/output/rseq/basic_percpu_ops_test
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq
> -Wl,-rpath=./ param_test.c -lpthread -lrseq -o /linux/output/rseq/param_test
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq
> -Wl,-rpath=./ -DBENCHMARK param_test.c -lpthread -lrseq -o
> /linux/output/rseq/param_test_benchmark
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L/linux/output/rseq
> -Wl,-rpath=./ -DRSEQ_COMPARE_TWICE param_test.c -lpthread -lrseq -o
> /linux/output/rseq/param_test_compare_twice
> make[1]: Leaving directory '/linux/tools/testing/selftests/rseq'
> make: Leaving directory '/linux/tools/testing/selftests'
>
> And also without, in which case the selftest makefiles set OUTPUT to
> the full path of the source directory:
>
> $ make -C tools/testing/selftests/ TARGETS=rseq
> ...
> make[1]: Entering directory '/linux/tools/testing/selftests/rseq'
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -shared -fPIC rseq.c
> -lpthread -o /linux/tools/testing/selftests/rseq/librseq.so
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ basic_test.c -lpthread
> -lrseq -o /linux/tools/testing/selftests/rseq/basic_test
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ basic_percpu_ops_test.c
> -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/basic_percpu_ops_test
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ param_test.c -lpthread
> -lrseq -o /linux/tools/testing/selftests/rseq/param_test
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -DBENCHMARK param_test.c
> -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/param_test_benchmark
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -DRSEQ_COMPARE_TWICE
> param_test.c -lpthread -lrseq -o
> /linux/tools/testing/selftests/rseq/param_test_compare_twice
> make[1]: Leaving directory '/linux/tools/testing/selftests/rseq'
> make: Leaving directory '/linux/tools/testing/selftests'
>
> And finally, it also works if you build directly in the rseq
> directory, eg:
>
> $ cd tools/testing/selftests/rseq
> $ make
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -shared -fPIC rseq.c
> -lpthread -o /linux/tools/testing/selftests/rseq/librseq.so
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ basic_test.c -lpthread
> -lrseq -o /linux/tools/testing/selftests/rseq/basic_test
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ basic_percpu_ops_test.c
> -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/basic_percpu_ops_test
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ param_test.c -lpthread
> -lrseq -o /linux/tools/testing/selftests/rseq/param_test
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -DBENCHMARK param_test.c
> -lpthread -lrseq -o /linux/tools/testing/selftests/rseq/param_test_benchmark
> gcc -O2 -Wall -g -I./ -I../../../../usr/include/
> -L/linux/tools/testing/selftests/rseq -Wl,-rpath=./ -DRSEQ_COMPARE_TWICE
> param_test.c -lpthread -lrseq -o
> /linux/tools/testing/selftests/rseq/param_test_compare_twice
> ---
> tools/testing/selftests/rseq/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/rseq/Makefile
> b/tools/testing/selftests/rseq/Makefile
> index d6469535630a..708c1b345245 100644
> --- a/tools/testing/selftests/rseq/Makefile
> +++ b/tools/testing/selftests/rseq/Makefile
> @@ -4,7 +4,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
> CLANG_FLAGS += -no-integrated-as
> endif
>
> -CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ \
> +CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L$(OUTPUT)
> -Wl,-rpath=./ \
> $(CLANG_FLAGS)
> LDLIBS += -lpthread
>
>
> base-commit: 11a48a5a18c63fd7621bb050228cebf13566e4d8
> --
> 2.21.1
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/rseq: Fix out-of-tree compilation
2020-02-20 16:16 ` Mathieu Desnoyers
@ 2020-02-20 16:17 ` Shuah Khan
0 siblings, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2020-02-20 16:17 UTC (permalink / raw)
To: Mathieu Desnoyers, Michael Ellerman
Cc: linux-kselftest, linux-kernel, Peter Zijlstra, paulmck,
Boqun Feng, skh >> Shuah Khan
On 2/20/20 9:16 AM, Mathieu Desnoyers wrote:
> ----- On Feb 20, 2020, at 6:37 AM, Michael Ellerman mpe@ellerman.id.au wrote:
>
>> Currently if you build with O=... the rseq tests don't build:
>>
>> $ make O=$PWD/output -C tools/testing/selftests/ TARGETS=rseq
>> make: Entering directory '/linux/tools/testing/selftests'
>> ...
>> make[1]: Entering directory '/linux/tools/testing/selftests/rseq'
>> gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared
>> -fPIC rseq.c -lpthread -o /linux/output/rseq/librseq.so
>> gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
>> basic_test.c -lpthread -lrseq -o /linux/output/rseq/basic_test
>> /usr/bin/ld: cannot find -lrseq
>> collect2: error: ld returned 1 exit status
>>
>> This is because the library search path points to the source
>> directory, not the output.
>>
>> We can fix it by changing the library search path to $(OUTPUT).
>
> Good catch!
>
> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>
> Shuah, can you pick this up please ?
>
I applied it to linux-kselftest fixes just a little while ago.
I will send this in for rc4.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-20 16:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20 11:37 [PATCH] selftests/rseq: Fix out-of-tree compilation Michael Ellerman
2020-02-20 16:16 ` Mathieu Desnoyers
2020-02-20 16:17 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).