Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Disable warnings on unused flags for Clang builds

There exist compiler flags supported by GCC but not supported by Clang
(e.g. -specs=...). Currently, these cannot be passed to BPF selftests
builds, even when building with GCC, as some binaries (urandom_read and
liburandom_read.so) are always built with Clang and the unsupported
flags make the compilation fail (as -Werror is turned on).

Add -Wno-unused-command-line-argument to these rules to suppress such
errors.

This allows to do things like:

$ CFLAGS="-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1" \
make -C tools/testing/selftests/bpf

Without this patch, the compilation would fail with:

[...]
clang: error: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Werror,-Wunused-command-line-argument]
make: *** [Makefile:273: /bpf-next/tools/testing/selftests/bpf/liburandom_read.so] Error 1
[...]

Signed-off-by: Viktor Malik <vmalik@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/2d349e9d5eb0a79dd9ff94b496769d64e6ff7654.1730449390.git.vmalik@redhat.com

authored by

Viktor Malik and committed by
Andrii Nakryiko
77017b9c 0513eeee

+2
+2
tools/testing/selftests/bpf/Makefile
··· 274 274 $(Q)$(CLANG) $(CLANG_TARGET_ARCH) \ 275 275 $(filter-out -static,$(CFLAGS) $(LDFLAGS)) \ 276 276 $(filter %.c,$^) $(filter-out -static,$(LDLIBS)) \ 277 + -Wno-unused-command-line-argument \ 277 278 -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \ 278 279 -Wl,--version-script=liburandom_read.map \ 279 280 -fPIC -shared -o $@ ··· 283 282 $(call msg,BINARY,,$@) 284 283 $(Q)$(CLANG) $(CLANG_TARGET_ARCH) \ 285 284 $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \ 285 + -Wno-unused-command-line-argument \ 286 286 -lurandom_read $(filter-out -static,$(LDLIBS)) -L$(OUTPUT) \ 287 287 -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \ 288 288 -Wl,-rpath=. -o $@