On Mon, Oct 21, 2024 at 08:20:39AM +0200, Viktor Malik wrote: > On 10/20/24 19:24, Jiri Olsa wrote: > > On Fri, Oct 18, 2024 at 08:49:01AM +0200, Viktor Malik wrote: > >> 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 > > > > hi, > > might be my fedora setup, but this example gives me compile error below > > even with the patch applied: > > > > EXT-OBJ [test_progs] testing_helpers.o > > In file included from testing_helpers.c:10: > > disasm.h:11:10: fatal error: linux/stringify.h: No such file or directory > > 11 | #include <linux/stringify.h> > > | ^~~~~~~~~~~~~~~~~~~ > > Aren't you doing `make CFLAGS="..."` instead of `CFLAGS="..." make`? The > difference is that the former overrides CFLAGS defined in selftests > Makefile and therefore the include dirs are not correctly added. right, I was doing that, thanks Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx> jirka > > > > > jirka > > > >> > >> 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@xxxxxxxxxx> > >> --- > >> tools/testing/selftests/bpf/Makefile | 2 ++ > >> 1 file changed, 2 insertions(+) > >> > >> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > >> index 1fc7c38e56b5..3da1a61968b7 100644 > >> --- a/tools/testing/selftests/bpf/Makefile > >> +++ b/tools/testing/selftests/bpf/Makefile > >> @@ -273,6 +273,7 @@ $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c liburandom > >> $(Q)$(CLANG) $(CLANG_TARGET_ARCH) \ > >> $(filter-out -static,$(CFLAGS) $(LDFLAGS)) \ > >> $(filter %.c,$^) $(filter-out -static,$(LDLIBS)) \ > >> + -Wno-unused-command-line-argument \ > >> -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \ > >> -Wl,--version-script=liburandom_read.map \ > >> -fPIC -shared -o $@ > >> @@ -281,6 +282,7 @@ $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_r > >> $(call msg,BINARY,,$@) > >> $(Q)$(CLANG) $(CLANG_TARGET_ARCH) \ > >> $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \ > >> + -Wno-unused-command-line-argument \ > >> -lurandom_read $(filter-out -static,$(LDLIBS)) -L$(OUTPUT) \ > >> -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \ > >> -Wl,-rpath=. -o $@ > >> -- > >> 2.47.0 > >> > > >