Skip to content

Commit f9dd1a8

Browse files
KP SinghNobody
KP Singh
authored and
Nobody
committed
bpf/selftests: Allow vmtest.sh to build statically linked test_progs.
Dynamic linking when compiling on the host can cause issues when the libc version does not match the one in the VM image. Allow the user to use static compilation when this issue arises: Before: ./vmtest.sh -- ./test_progs -t test_ima ./test_progs: /usr/lib/libc.so.6: version `GLIBC_2.33' not found (required by ./test_progs) After: TRUNNER_LDFLAGS=-static ./vmtest.sh -- ./test_progs -t test_ima test_ima:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED Not using static as the default as some distros may not have dependent static libraries. Reported-by: "Geyslan G. Bem" <[email protected]> Signed-off-by: KP Singh <[email protected]>
1 parent 8fb5b79 commit f9dd1a8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ $(MAKE_DIRS):
162162

163163
$(OUTPUT)/%.o: %.c
164164
$(call msg,CC,,$@)
165-
$(Q)$(CC) $(CFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@
165+
$(Q)$(CC) $(CFLAGS) $(TRUNNER_LDFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@
166166

167167
$(OUTPUT)/%:%.c
168168
$(call msg,BINARY,,$@)
@@ -468,7 +468,7 @@ $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS) \
468468
$(RESOLVE_BTFIDS) \
469469
| $(TRUNNER_BINARY)-extras
470470
$$(call msg,BINARY,,$$@)
471-
$(Q)$$(CC) $$(CFLAGS) $$(filter %.a %.o,$$^) $$(LDLIBS) -o $$@
471+
$(Q)$$(CC) $$(CFLAGS) $(TRUNNER_LDFLAGS) $$(filter %.a %.o,$$^) $$(LDLIBS) -o $$@
472472
$(Q)$(RESOLVE_BTFIDS) --btf $(TRUNNER_OUTPUT)/btf_data.o $$@
473473
$(Q)ln -sf $(if $2,..,.)/tools/build/bpftool/bootstrap/bpftool $(if $2,$2/)bpftool
474474

tools/testing/selftests/bpf/vmtest.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ NUM_COMPILE_JOBS="$(nproc)"
3737
LOG_FILE_BASE="$(date +"bpf_selftests.%Y-%m-%d_%H-%M-%S")"
3838
LOG_FILE="${LOG_FILE_BASE}.log"
3939
EXIT_STATUS_FILE="${LOG_FILE_BASE}.exit_status"
40+
TRUNNER_LDFLAGS="${TRUNNER_LDFLAGS:=""}"
4041

4142
usage()
4243
{
@@ -155,7 +156,7 @@ update_selftests()
155156
local selftests_dir="${kernel_checkout}/tools/testing/selftests/bpf"
156157

157158
cd "${selftests_dir}"
158-
${make_command}
159+
${make_command} TRUNNER_LDFLAGS="${TRUNNER_LDFLAGS}"
159160

160161
# Mount the image and copy the selftests to the image.
161162
mount_image

0 commit comments

Comments
 (0)