Message ID | 20230217151832.27784-1-revest@chromium.org |
---|---|
State | Accepted |
Commit | b539a287baaa8501b3af4f7f99aba3c0b1d822f8 |
Headers | show |
Series | [bpf-next] selftests/bpf: Fix cross compilation with CLANG_CROSS_FLAGS | expand |
Hello: This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <ast@kernel.org>: On Fri, 17 Feb 2023 16:18:32 +0100 you wrote: > I cross-compile my BPF selftests with the following command: > > CLANG_CROSS_FLAGS="--target=aarch64-linux-gnu --sysroot=/sysroot/" \ > make LLVM=1 CC=clang CROSS_COMPILE=aarch64-linux-gnu- SRCARCH=arm64 > > (Note the use of CLANG_CROSS_FLAGS to specify a custom sysroot instead > of letting clang use gcc's default sysroot) > > [...] Here is the summary with links: - [bpf-next] selftests/bpf: Fix cross compilation with CLANG_CROSS_FLAGS https://git.kernel.org/bpf/bpf-next/c/b539a287baaa You are awesome, thank you!
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 0efb8f2b33ce..ff527ac065cf 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -108,6 +108,8 @@ endif # GCC_TOOLCHAIN_DIR endif # CLANG_CROSS_FLAGS CFLAGS += $(CLANG_CROSS_FLAGS) AFLAGS += $(CLANG_CROSS_FLAGS) +else +CLANG_CROSS_FLAGS := endif # CROSS_COMPILE # Hack to avoid type-punned warnings on old systems such as RHEL5:
I cross-compile my BPF selftests with the following command: CLANG_CROSS_FLAGS="--target=aarch64-linux-gnu --sysroot=/sysroot/" \ make LLVM=1 CC=clang CROSS_COMPILE=aarch64-linux-gnu- SRCARCH=arm64 (Note the use of CLANG_CROSS_FLAGS to specify a custom sysroot instead of letting clang use gcc's default sysroot) However, CLANG_CROSS_FLAGS gets propagated to host tools builds (libbpf and bpftool) and because they reference it directly in their Makefiles, they end up cross-compiling host objects which results in linking errors. This patch ensures that CLANG_CROSS_FLAGS is reset if CROSS_COMPILE isn't set (for example when reaching a BPF host tool build). Signed-off-by: Florent Revest <revest@chromium.org> --- tools/scripts/Makefile.include | 2 ++ 1 file changed, 2 insertions(+)