Skip to content

Commit

Permalink
selftests/bpf: use simply-expanded variables for libpcap flags
Browse files Browse the repository at this point in the history
Save pkg-config output for libpcap as simply-expanded variables.
For an obscure reason 'shell' call in LDLIBS/CFLAGS recursively
expanded variables makes *.test.o files compilation non-parallel
when make is executed with -j option.

While at it, reuse 'pkg-config --cflags' call to define
-DTRAFFIC_MONITOR=1 option, it's exit status is the same as for
'pkg-config --exists'.

Fixes: f52403b ("selftests/bpf: Add traffic monitor functions.")
Signed-off-by: Eduard Zingerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin KaFai Lau <[email protected]>
  • Loading branch information
eddyz87 authored and Martin KaFai Lau committed Aug 23, 2024
1 parent 5cd0aea commit 5772c34
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/testing/selftests/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ CFLAGS += -g $(OPT_FLAGS) -rdynamic \
LDFLAGS += $(SAN_LDFLAGS)
LDLIBS += $(LIBELF_LIBS) -lz -lrt -lpthread

LDLIBS += $(shell $(PKG_CONFIG) --libs libpcap 2>/dev/null)
CFLAGS += $(shell $(PKG_CONFIG) --cflags libpcap 2>/dev/null)
CFLAGS += $(shell $(PKG_CONFIG) --exists libpcap 2>/dev/null && echo "-DTRAFFIC_MONITOR=1")
PCAP_CFLAGS := $(shell $(PKG_CONFIG) --cflags libpcap 2>/dev/null && echo "-DTRAFFIC_MONITOR=1")
PCAP_LIBS := $(shell $(PKG_CONFIG) --libs libpcap 2>/dev/null)
LDLIBS += $(PCAP_LIBS)
CFLAGS += $(PCAP_CFLAGS)

# The following tests perform type punning and they may break strict
# aliasing rules, which are exploited by both GCC and clang by default
Expand Down

0 comments on commit 5772c34

Please sign in to comment.