kbuild: add --target to correctly cross-compile UAPI headers with Clang
authorMasahiro Yamada <masahiroy@kernel.org>
Sat, 5 Mar 2022 12:56:05 +0000 (21:56 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Thu, 31 Mar 2022 03:03:46 +0000 (12:03 +0900)
commit9fbed27a7a1101c926718dfa9b49aff1d04477b5
tree9a49015d1354817e11e73fa5472c3c67675f2043
parent69304379ff036ce8ecf41efc2aeea4b29dd0c43f
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 7f58b487e9ff ("kbuild: make Clang build userprogs for target
architecture").

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
usr/include/Makefile