2024-10-18 08:49 UTC+0200 ~ Viktor Malik <vmalik@xxxxxxxxxx> > When building selftests with CFLAGS set via env variable, the value of > CFLAGS is propagated into bpftool Makefile (called from selftests > Makefile). This makes the compilation fail as _GNU_SOURCE is defined two > times - once from selftests Makefile (by including lib.mk) and once from > bpftool Makefile (by calling `llvm-config --cflags`): > > $ CFLAGS="" make -C tools/testing/selftests/bpf > [...] > CC /bpf-next/tools/testing/selftests/bpf/tools/build/bpftool/btf.o > <command-line>: error: "_GNU_SOURCE" redefined [-Werror] > <command-line>: note: this is the location of the previous definition > cc1: all warnings being treated as errors > [...] > > Filter out -D_GNU_SOURCE from the result of `llvm-config --cflags` in > bpftool Makefile to prevent this error. > > Signed-off-by: Viktor Malik <vmalik@xxxxxxxxxx> I am not aware of any extension in use in bpftool that would require the use of -D_GNU_SOURCE, so I suppose it's fine to remove it unconditionally, even when it's not in CFLAGS before we append the flags from llvm-config. Thanks! Acked-by: Quentin Monnet <qmo@xxxxxxxxxx>