2017-11-07 3:47 GMT+09:00 Nick Desaulniers <ndesaulniers@xxxxxxxxxx>: > I was not seeing my linker flags getting added when using ld-option when > cross compiling with Clang. Upon investigation, this seems to be due to > a difference in how GCC vs Clang handle cross compilation. > > GCC is configured at build time to support one backend, that is implicit > when compiling. Clang is explicit via the use of `-target <triple>` and > ships with all supported backends by default. > > GNU Make feature test macros that compile then link will always fail > when cross compiling with Clang unless Clang's triple is passed along to > the compiler. For example: > > $ clang -x c /dev/null -c -o temp.o > $ aarch64-linux-android/bin/ld -E temp.o > aarch64-linux-android/bin/ld: > unknown architecture of input file `temp.o' is incompatible with > aarch64 output > aarch64-linux-android/bin/ld: > warning: cannot find entry symbol _start; defaulting to > 0000000000400078 > $ echo $? > 1 > > $ clang -target aarch64-linux-android- -x c /dev/null -c -o temp.o > $ aarch64-linux-android/bin/ld -E temp.o > aarch64-linux-android/bin/ld: > warning: cannot find entry symbol _start; defaulting to 00000000004002e4 > $ echo $? > 0 > > This causes conditional checks that invoke $(CC) without the target > triple, then $(LD) on the result, to always fail. > > Suggested-by: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> > Signed-off-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> > Reviewed-by: Matthias Kaehlcke <mka@xxxxxxxxxxxx> > --- > Changes since v2: > * Add LDFLAGS to ld-option, as per Masahiro, and spotted by 0-day bot: > https://lists.01.org/pipermail/lkp/2017-October/007427.html > > scripts/Kbuild.include | 5 +++-- Applied to linux-kbuild/kbuild. -- Best Regards Masahiro Yamada -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html