* [PATCH] selftests/bpf: fix vmtest static compilation error
@ 2023-01-21 6:41 Daniel T. Lee
2023-01-24 16:21 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Daniel T. Lee @ 2023-01-21 6:41 UTC (permalink / raw)
To: Daniel Borkmann, Alexei Starovoitov, Andrii Nakryiko,
Andrii Nakryiko, Yonghong Song, Martin KaFai Lau, Song Liu,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Mykola Lysenko, Shuah Khan, Yosry Ahmed
Cc: bpf, netdev, linux-kselftest
As stated in README.rst, in order to resolve errors with linker errors,
'LDLIBS=-static' should be used. Most problems will be solved by this
option, but in the case of urandom_read, this won't fix the problem. So
the Makefile is currently implemented to strip the 'static' option when
compiling the urandom_read. However, stripping this static option isn't
configured properly on $(LDLIBS) correctly, which is now causing errors
on static compilation.
# LDLIBS=-static ./vmtest.sh
ld.lld: error: attempted static link of dynamic object liburandom_read.so
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:190: /linux/tools/testing/selftests/bpf/urandom_read] Error 1
make: *** Waiting for unfinished jobs....
This commit fixes this problem by configuring the strip with $(LDLIBS).
Fixes: 68084a136420 ("selftests/bpf: Fix building bpf selftests statically")
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
---
tools/testing/selftests/bpf/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 22533a18705e..7bd1ce9c8d87 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -188,7 +188,7 @@ $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c
$(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_read.so
$(call msg,BINARY,,$@)
$(Q)$(CLANG) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \
- liburandom_read.so $(LDLIBS) \
+ liburandom_read.so $(filter-out -static,$(LDLIBS)) \
-fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
-Wl,-rpath=. -o $@
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/bpf: fix vmtest static compilation error
2023-01-21 6:41 [PATCH] selftests/bpf: fix vmtest static compilation error Daniel T. Lee
@ 2023-01-24 16:21 ` Daniel Borkmann
2023-01-25 6:07 ` Daniel T. Lee
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2023-01-24 16:21 UTC (permalink / raw)
To: Daniel T. Lee, Alexei Starovoitov, Andrii Nakryiko,
Andrii Nakryiko, Yonghong Song, Martin KaFai Lau, Song Liu,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Mykola Lysenko, Shuah Khan, Yosry Ahmed
Cc: bpf, netdev, linux-kselftest
On 1/21/23 7:41 AM, Daniel T. Lee wrote:
> As stated in README.rst, in order to resolve errors with linker errors,
> 'LDLIBS=-static' should be used. Most problems will be solved by this
> option, but in the case of urandom_read, this won't fix the problem. So
> the Makefile is currently implemented to strip the 'static' option when
> compiling the urandom_read. However, stripping this static option isn't
> configured properly on $(LDLIBS) correctly, which is now causing errors
> on static compilation.
>
> # LDLIBS=-static ./vmtest.sh
> ld.lld: error: attempted static link of dynamic object liburandom_read.so
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
> make: *** [Makefile:190: /linux/tools/testing/selftests/bpf/urandom_read] Error 1
> make: *** Waiting for unfinished jobs....
>
> This commit fixes this problem by configuring the strip with $(LDLIBS).
>
> Fixes: 68084a136420 ("selftests/bpf: Fix building bpf selftests statically")
> Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
> ---
> tools/testing/selftests/bpf/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 22533a18705e..7bd1ce9c8d87 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -188,7 +188,7 @@ $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c
> $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_read.so
> $(call msg,BINARY,,$@)
> $(Q)$(CLANG) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \
> - liburandom_read.so $(LDLIBS) \
> + liburandom_read.so $(filter-out -static,$(LDLIBS)) \
Do we need the same also for liburandom_read.so target's $(LDLIBS) further above?
> -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
> -Wl,-rpath=. -o $@
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/bpf: fix vmtest static compilation error
2023-01-24 16:21 ` Daniel Borkmann
@ 2023-01-25 6:07 ` Daniel T. Lee
0 siblings, 0 replies; 3+ messages in thread
From: Daniel T. Lee @ 2023-01-25 6:07 UTC (permalink / raw)
To: Daniel Borkmann
Cc: Alexei Starovoitov, Andrii Nakryiko, Andrii Nakryiko,
Yonghong Song, Martin KaFai Lau, Song Liu, John Fastabend,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Mykola Lysenko,
Shuah Khan, Yosry Ahmed, bpf, netdev, linux-kselftest
On Wed, Jan 25, 2023 at 1:21 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 1/21/23 7:41 AM, Daniel T. Lee wrote:
> > As stated in README.rst, in order to resolve errors with linker errors,
> > 'LDLIBS=-static' should be used. Most problems will be solved by this
> > option, but in the case of urandom_read, this won't fix the problem. So
> > the Makefile is currently implemented to strip the 'static' option when
> > compiling the urandom_read. However, stripping this static option isn't
> > configured properly on $(LDLIBS) correctly, which is now causing errors
> > on static compilation.
> >
> > # LDLIBS=-static ./vmtest.sh
> > ld.lld: error: attempted static link of dynamic object liburandom_read.so
> > clang: error: linker command failed with exit code 1 (use -v to see invocation)
> > make: *** [Makefile:190: /linux/tools/testing/selftests/bpf/urandom_read] Error 1
> > make: *** Waiting for unfinished jobs....
> >
> > This commit fixes this problem by configuring the strip with $(LDLIBS).
> >
> > Fixes: 68084a136420 ("selftests/bpf: Fix building bpf selftests statically")
> > Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
> > ---
> > tools/testing/selftests/bpf/Makefile | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> > index 22533a18705e..7bd1ce9c8d87 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -188,7 +188,7 @@ $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c
> > $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_read.so
> > $(call msg,BINARY,,$@)
> > $(Q)$(CLANG) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \
> > - liburandom_read.so $(LDLIBS) \
> > + liburandom_read.so $(filter-out -static,$(LDLIBS)) \
>
> Do we need the same also for liburandom_read.so target's $(LDLIBS) further above?
>
Oops, I didn't notice that.
I'll apply the review and send the next version of patch!
> > -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
> > -Wl,-rpath=. -o $@
> >
> >
>
--
Best,
Daniel T. Lee
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-25 6:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-21 6:41 [PATCH] selftests/bpf: fix vmtest static compilation error Daniel T. Lee
2023-01-24 16:21 ` Daniel Borkmann
2023-01-25 6:07 ` Daniel T. Lee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox