diff mbox series

selftests/bpf: fix vmtest static compilation error

Message ID 20230121064128.67914-1-danieltimlee@gmail.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series selftests/bpf: fix vmtest static compilation error | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_maps on s390x with gcc
netdev/tree_selection success Not a local patch
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 fail Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-32 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-34 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-37 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-38 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32 on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-30 success Logs for test_progs_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-33 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-35 success Logs for test_verifier on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-36 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-31 success Logs for test_progs_parallel on s390x with gcc
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for s390x with gcc

Commit Message

Daniel T. Lee Jan. 21, 2023, 6:41 a.m. UTC
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(-)

Comments

Daniel Borkmann Jan. 24, 2023, 4:21 p.m. UTC | #1
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 $@
>   
>
Daniel T. Lee Jan. 25, 2023, 6:07 a.m. UTC | #2
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 $@
> >
> >
>
diff mbox series

Patch

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 $@