Skip to content

Commit 9fbed27

Browse files
committed
kbuild: add --target to correctly cross-compile UAPI headers with Clang
When you compile-test UAPI headers (CONFIG_UAPI_HEADER_TEST=y) with Clang, they are currently compiled for the host target (likely x86_64) regardless of the given ARCH=. In fact, some exported headers include libc headers. For example, include/uapi/linux/agpgart.h includes <stdlib.h> after being exported. The header search paths should match to the target we are compiling them for. Pick up the --target triple from KBUILD_CFLAGS in the same ways as commit 7f58b48 ("kbuild: make Clang build userprogs for target architecture"). Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]>
1 parent 6930437 commit 9fbed27

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

usr/include/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ UAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration
1010

1111
# In theory, we do not care -m32 or -m64 for header compile tests.
1212
# It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64.
13-
UAPI_CFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
13+
UAPI_CFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1414

1515
# USERCFLAGS might contain sysroot location for CC.
1616
UAPI_CFLAGS += $(USERCFLAGS)

0 commit comments

Comments
 (0)