Skip to content

Commit 4711abc

Browse files
Leo-YanKernel Patches Daemon
authored andcommitted
selftests/bpf: Use common CFLAGS for urandom_read
The urandom_read helper and its shared library are built with $(CLANG) directly rather than through the normal selftest $(CC) rules. The CFLAGS variable can contain specific flags only for $(CC) but might be imcompatible for $(CLANG) and those flags are not necessarily valid for the clang-only urandom_read build. Split the BPF selftest local flags into COMMON_CFLAGS and append them to CFLAGS for the normal build path. Use COMMON_CFLAGS directly for urandom_read and liburandom_read.so, while still filtering out -static as before. Signed-off-by: Leo Yan <leo.yan@arm.com>
1 parent fd0ac24 commit 4711abc

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tools/testing/selftests/bpf/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
5757
srctree := $(patsubst %/,%,$(dir $(srctree)))
5858
endif
5959

60-
CFLAGS += -g $(OPT_FLAGS) -rdynamic -std=gnu11 \
60+
COMMON_CFLAGS = -g $(OPT_FLAGS) -rdynamic -std=gnu11 \
6161
-Wall -Werror -fno-omit-frame-pointer \
6262
-Wno-unused-but-set-variable \
6363
$(GENFLAGS) $(SAN_CFLAGS) $(LIBELF_CFLAGS) \
@@ -70,7 +70,7 @@ LDLIBS += $(LIBELF_LIBS) -lz -lrt -lpthread
7070
PCAP_CFLAGS := $(shell $(PKG_CONFIG) --cflags libpcap 2>/dev/null && echo "-DTRAFFIC_MONITOR=1")
7171
PCAP_LIBS := $(shell $(PKG_CONFIG) --libs libpcap 2>/dev/null)
7272
LDLIBS += $(PCAP_LIBS)
73-
CFLAGS += $(PCAP_CFLAGS)
73+
CFLAGS += $(COMMON_CFLAGS) $(PCAP_CFLAGS)
7474

7575
# Some utility functions use LLVM libraries
7676
jit_disasm_helpers.c-CFLAGS = $(LLVM_CFLAGS)
@@ -267,7 +267,7 @@ endif
267267
$(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c liburandom_read.map
268268
$(call msg,LIB,,$@)
269269
$(Q)$(CLANG) $(CLANG_TARGET_ARCH) \
270-
$(filter-out -static,$(CFLAGS) $(LDFLAGS)) \
270+
$(filter-out -static,$(COMMON_CFLAGS) $(LDFLAGS)) \
271271
$(filter %.c,$^) $(filter-out -static,$(LDLIBS)) \
272272
-Wno-unused-command-line-argument \
273273
-fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
@@ -277,7 +277,7 @@ $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c liburandom
277277
$(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_read.so
278278
$(call msg,BINARY,,$@)
279279
$(Q)$(CLANG) $(CLANG_TARGET_ARCH) \
280-
$(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \
280+
$(filter-out -static,$(COMMON_CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \
281281
-Wno-unused-command-line-argument \
282282
-lurandom_read $(filter-out -static,$(LDLIBS)) -L$(OUTPUT) \
283283
-fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \

0 commit comments

Comments
 (0)