Skip to contentSkip to conversation

selftests/bpf: fix vmtest static compilation error

PATCH Superseded Daniel T. Lee 2 participants 3 messages Jan 21, 2023 – Jan 25, 2023

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: fix vmtest static compilation error

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")
---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
index 22533a18705e..7bd1ce9c8d87 100644
@@ -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 $@
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 27 lines · Daniel T. Lee

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")
---
  tools/testing/selftests/bpf/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +0 -0
index 22533a18705e..7bd1ce9c8d87 100644

tools/testing/selftests/bpf/Makefile $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c · line 191

Quoted 5 lines
tools/testing/selftests/bpf/Makefile +1 -1
@@ -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?

Quoted 4 lines
tools/testing/selftests/bpf/Makefile +0 -0
  		     -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
  		     -Wl,-rpath=. -o $@
 
#2 lore raw
Quoted 24 lines · Daniel Borkmann
Quoted 22 lines · Daniel T. Lee

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")
---
  tools/testing/selftests/bpf/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

tools/testing/selftests/bpf/Makefile $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c · line 191

Quoted 10 lines
tools/testing/selftests/bpf/Makefile +1 -1
index 22533a18705e..7bd1ce9c8d87 100644
@@ -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!

Quoted 5 lines
Quoted 4 lines
tools/testing/selftests/bpf/Makefile +0 -0
                   -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
                   -Wl,-rpath=. -o $@
 
Signature · 2 lines
Best,
Daniel T. Lee