]> www.infradead.org Git - users/dwmw2/linux.git/commit
bpftool: Prevent setting duplicate _GNU_SOURCE in Makefile
authorViktor Malik <vmalik@redhat.com>
Fri, 1 Nov 2024 08:27:12 +0000 (09:27 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 1 Nov 2024 19:37:01 +0000 (12:37 -0700)
commit0513eeee86d67930f3567e450357d8db1cfb4f16
treec47d5fd9ae37e56823382f57e2fb793516dcb9b6
parent4d99e509c161f8610de125202c648fa4acd00541
bpftool: Prevent setting duplicate _GNU_SOURCE in Makefile

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@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Quentin Monnet <qmo@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/acec3108b62d4df1436cda777e58e93e033ac7a7.1730449390.git.vmalik@redhat.com
tools/bpf/bpftool/Makefile