Skip to content

Commit 0e5fc4d

Browse files
yosrym93Kernel Patches Daemon
authored andcommitted
selftests/bpf: fix building bpf selftests statically
bpf selftests can no longer be built with CFLAGS=-static with liburandom_read.so and its dependent target. Filter out -static for liburandom_read.so and its dependent target. Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
1 parent e83cb63 commit 0e5fc4d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,17 @@ $(OUTPUT)/%:%.c
168168
$(call msg,BINARY,,$@)
169169
$(Q)$(LINK.c) $^ $(LDLIBS) -o $@
170170

171+
# If the tests are being built statically, exclude dynamic libraries defined
172+
# in this Makefile and their dependencies.
173+
DYNAMIC_CFLAGS := $(filter-out -static,$(CFLAGS))
171174
$(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c
172175
$(call msg,LIB,,$@)
173-
$(Q)$(CC) $(CFLAGS) -fPIC $(LDFLAGS) $^ $(LDLIBS) --shared -o $@
176+
$(Q)$(CC) $(DYNAMIC_CFLAGS) -fPIC $(LDFLAGS) $^ $(LDLIBS) --shared -o $@
174177

175178
$(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_read.so
176179
$(call msg,BINARY,,$@)
177-
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.c,$^) \
178-
liburandom_read.so $(LDLIBS) \
180+
$(Q)$(CC) $(DYNAMIC_CFLAGS) $(LDFLAGS) $(filter %.c,$^) \
181+
liburandom_read.so $(LDLIBS) \
179182
-Wl,-rpath=. -Wl,--build-id=sha1 -o $@
180183

181184
$(OUTPUT)/bpf_testmod.ko: $(VMLINUX_BTF) $(wildcard bpf_testmod/Makefile bpf_testmod/*.[ch])

0 commit comments

Comments
 (0)