Skip to content

tools build: bpf: Append EXTRA_CFLAGS and HOST_EXTRACFLAGS#7927

Open
kernel-patches-daemon-bpf-rc[bot] wants to merge 8 commits into
bpf-next_basefrom
series/1104693=>bpf-next
Open

tools build: bpf: Append EXTRA_CFLAGS and HOST_EXTRACFLAGS#7927
kernel-patches-daemon-bpf-rc[bot] wants to merge 8 commits into
bpf-next_basefrom
series/1104693=>bpf-next

Conversation

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown

Pull request for series with
subject: tools build: bpf: Append EXTRA_CFLAGS and HOST_EXTRACFLAGS
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: b93c55b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 04de7bc
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: c169a2a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: c169a2a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 8a7f2bf
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 5b88319
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: bf29346
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 390dc36
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: f64c723
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 4a7910e
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: dd0f968
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: f1a660b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 68f4e48
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: c15261b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 140fa23
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 2e8ad1f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

Leo-Yan added 3 commits June 10, 2026 16:24
bpftool builds a bootstrap libbpf with HOSTCC, but the libbpf submake can
still inherit target build flags through CFLAGS. This can break cross
builds when host objects are compiled with target-only options.

Since HOST_CFLAGS contains warning options that are not suitable for
building libbpf, use LIBBPF_BOOTSTRAP_CFLAGS with the warning options
removed to build the bootstrap libbpf. Clear EXTRA_CFLAGS so target
extra flags are not mixed into the host bootstrap libbpf build.

Signed-off-by: Leo Yan <leo.yan@arm.com>
Acked-by: Quentin Monnet <qmo@kernel.org>
Prepare for future changes where EXTRA_CFLAGS may include flags not
applicable to the host compiler.

Move the HOST_CFLAGS assignment before appending EXTRA_CFLAGS to
CFLAGS so that HOST_CFLAGS does not inherit flags from EXTRA_CFLAGS.

Acked-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Append HOST_EXTRACFLAGS to HOST_CFLAGS so that additional flags can be
applied to the host compiler.

Acked-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Leo Yan <leo.yan@arm.com>
@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

Upstream branch: 30dee2c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1104693
version: 2

Leo-Yan added 5 commits June 10, 2026 16:24
tools/scripts/Makefile.include may expand EXTRA_CFLAGS in a future
change.  This could alter the initialization of CFLAGS, as the default
options "-g -O2" would never be set once EXTRA_CFLAGS is expanded.

Prepare for this by moving the CFLAGS initialization before including
tools/scripts/Makefile.include, so it is not affected by the extended
EXTRA_CFLAGS.

Append EXTRA_CFLAGS to CFLAGS only after including Makefile.include and
place it last so that the extra flags propagate properly and can
override the default options.

tools/scripts/Makefile.include already appends $(CLANG_CROSS_FLAGS) to
CFLAGS, the Makefile appends $(CLANG_CROSS_FLAGS) again, remove the
redundant append.

Signed-off-by: Leo Yan <leo.yan@arm.com>
Acked-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Append EXTRA_CFLAGS to CFLAGS so that additional flags can be applied to
the compiler.

Signed-off-by: Leo Yan <leo.yan@arm.com>
ASAN reports stack-buffer-overflow due to the uninitialized op_name.

Initialize it to fix the issue.

Fixes: 054b6c7 ("selftests/bpf: Add verifier log tests for BPF_BTF_LOAD command")
Signed-off-by: Leo Yan <leo.yan@arm.com>
The urandom_read helper and its shared library are built with $(CLANG)
directly rather than through the normal selftest $(CC) rules.

The CFLAGS variable can contain specific flags only for $(CC) but might
be imcompatible for $(CLANG) and those flags are not necessarily valid
for the clang-only urandom_read build.

Split the BPF selftest local flags into COMMON_CFLAGS and append them to
CFLAGS for the normal build path. Use COMMON_CFLAGS directly for
urandom_read and liburandom_read.so, while still filtering out -static as
before.

Signed-off-by: Leo Yan <leo.yan@arm.com>
The BPF selftests prefer static LLVM linking, which works for native
builds but can break cross builds. Its --link-static output may include
host-only libraries that are unavailable for the cross compilation,
causing link failures.

Avoid static LLVM linking for cross builds and use shared LLVM libraries
instead. Native builds keep the existing behavior.

Signed-off-by: Leo Yan <leo.yan@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant