Message ID | 20231016124313.60220-1-akihiko.odaki@daynix.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next,v3] selftests/bpf: Use pkg-config to determine ld flags | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-VM_Test-5 | fail | Logs for build for x86_64 with llvm-16 |
bpf/vmtest-bpf-next-VM_Test-2 | fail | Logs for build for aarch64 with gcc |
bpf/vmtest-bpf-next-VM_Test-6 | success | Logs for set-matrix |
bpf/vmtest-bpf-next-VM_Test-1 | success | Logs for ShellCheck |
bpf/vmtest-bpf-next-VM_Test-3 | fail | Logs for build for s390x with gcc |
bpf/vmtest-bpf-next-PR | success | PR summary |
bpf/vmtest-bpf-next-VM_Test-4 | fail | Logs for build for x86_64 with gcc |
bpf/vmtest-bpf-next-VM_Test-7 | success | Logs for veristat |
bpf/vmtest-bpf-next-VM_Test-0 | success | Logs for ShellCheck |
netdev/series_format | success | Single patches do not need cover letters |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 9 this patch: 9 |
netdev/cc_maintainers | success | CCed 16 of 16 maintainers |
netdev/build_clang | success | Errors and warnings before: 9 this patch: 9 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/deprecated_api | success | None detected |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 9 this patch: 9 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 24 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On 2023/10/16 21:52, Daniel Borkmann wrote: > On 10/16/23 2:43 PM, Akihiko Odaki wrote: >> When linking statically, libraries may require other dependencies to be >> included to ld flags. In particular, libelf may require libzstd. Use >> pkg-config to determine such dependencies. >> >> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> >> --- >> V2 -> V3: Added missing "echo". >> V1 -> V2: Implemented fallback, referring to HOSTPKG_CONFIG. > > Same issue in v3. Please don't resend your patches too quickly, but > properly set up an > environment where you can test that this fallback works first : > > https://github.com/kernel-patches/bpf/actions/runs/6533309175/job/17738285759 I think you are looking at a wrong run. The run checks out: https://github.com/kernel-patches/bpf/commit/0c184cb0b561d2fb60b2dc79c2917cd7ff8cd8a2 This is v2. I think the correct one is: https://github.com/kernel-patches/bpf/actions/runs/6533797864 That said, I found spurious error messages with the run. I tested it by setting PKG_CONFIG=false, but I should have tested it with PKG_CONFIG=a-command-that-does-not-exist. Now I sent v4, which does no longer emit noisy error messages and is properly tested.
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index caede9b574cb..0b4ce6266bfc 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -4,6 +4,7 @@ include ../../../scripts/Makefile.arch include ../../../scripts/Makefile.include CXX ?= $(CROSS_COMPILE)g++ +PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config CURDIR := $(abspath .) TOOLSDIR := $(abspath ../../..) @@ -31,7 +32,8 @@ CFLAGS += -g -O0 -rdynamic -Wall -Werror $(GENFLAGS) $(SAN_CFLAGS) \ -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) \ -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT) LDFLAGS += $(SAN_LDFLAGS) -LDLIBS += -lelf -lz -lrt -lpthread +LDLIBS += $(shell $(PKG_CONFIG) --libs libelf zlib || echo -lelf -lz) \ + -lrt -lpthread ifneq ($(LLVM),) # Silence some warnings when compiled with clang diff --git a/tools/testing/selftests/bpf/README.rst b/tools/testing/selftests/bpf/README.rst index cb9b95702ac6..9af79c7a9b58 100644 --- a/tools/testing/selftests/bpf/README.rst +++ b/tools/testing/selftests/bpf/README.rst @@ -77,7 +77,7 @@ In case of linker errors when running selftests, try using static linking: .. code-block:: console - $ LDLIBS=-static vmtest.sh + $ LDLIBS=-static PKG_CONFIG='pkg-config --static' vmtest.sh .. note:: Some distros may not support static linking.
When linking statically, libraries may require other dependencies to be included to ld flags. In particular, libelf may require libzstd. Use pkg-config to determine such dependencies. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> --- V2 -> V3: Added missing "echo". V1 -> V2: Implemented fallback, referring to HOSTPKG_CONFIG. tools/testing/selftests/bpf/Makefile | 4 +++- tools/testing/selftests/bpf/README.rst | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)