• Nick Desaulniers's avatar
    kbuild: fix linker feature test macros when cross compiling with Clang · 51d137ca
    Nick Desaulniers authored
    (commit 86a9df59 upstream)
    
    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's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: default avatarMatthias Kaehlcke <mka@chromium.org>
    Signed-off-by: Masahiro Yamada's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    [ND: readjusted for context]
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    51d137ca
Name
Last commit
Last update
..
basic Loading commit data...
coccinelle Loading commit data...
dtc Loading commit data...
gcc-plugins Loading commit data...
gdb Loading commit data...
genksyms Loading commit data...
kconfig Loading commit data...
ksymoops Loading commit data...
mod Loading commit data...
package Loading commit data...
selinux Loading commit data...
tracing Loading commit data...
.gitignore Loading commit data...
Kbuild.include Loading commit data...
Lindent Loading commit data...
Makefile Loading commit data...
Makefile.asm-generic Loading commit data...
Makefile.build Loading commit data...
Makefile.clean Loading commit data...
Makefile.dtbinst Loading commit data...
Makefile.extrawarn Loading commit data...
Makefile.fwinst Loading commit data...
Makefile.gcc-plugins Loading commit data...
Makefile.headersinst Loading commit data...
Makefile.help Loading commit data...
Makefile.host Loading commit data...
Makefile.kasan Loading commit data...
Makefile.lib Loading commit data...
Makefile.modbuiltin Loading commit data...
Makefile.modinst Loading commit data...
Makefile.modpost Loading commit data...
Makefile.modsign Loading commit data...
Makefile.ubsan Loading commit data...
adjust_autoksyms.sh Loading commit data...
analyze_suspend.py Loading commit data...
asn1_compiler.c Loading commit data...
bloat-o-meter Loading commit data...
bootgraph.pl Loading commit data...
check-lc_ctype.c Loading commit data...
check_extable.sh Loading commit data...
checkincludes.pl Loading commit data...
checkkconfigsymbols.py Loading commit data...
checkpatch.pl Loading commit data...
checkstack.pl Loading commit data...
checksyscalls.sh Loading commit data...
checkversion.pl Loading commit data...
cleanfile Loading commit data...
cleanpatch Loading commit data...
coccicheck Loading commit data...
config Loading commit data...
conmakehash.c Loading commit data...
const_structs.checkpatch Loading commit data...
decode_stacktrace.sh Loading commit data...
decodecode Loading commit data...
depmod.sh Loading commit data...
diffconfig Loading commit data...
docproc.c Loading commit data...
export_report.pl Loading commit data...
extract-cert.c Loading commit data...
extract-ikconfig Loading commit data...
extract-module-sig.pl Loading commit data...
extract-sys-certs.pl Loading commit data...
extract-vmlinux Loading commit data...
extract_xc3028.pl Loading commit data...
faddr2line Loading commit data...
gcc-goto.sh Loading commit data...
gcc-ld Loading commit data...
gcc-plugin.sh Loading commit data...
gcc-version.sh Loading commit data...
gcc-x86_32-has-stack-protector.sh Loading commit data...
gcc-x86_64-has-stack-protector.sh Loading commit data...
gen_initramfs_list.sh Loading commit data...
get_dvb_firmware Loading commit data...
get_maintainer.pl Loading commit data...
gfp-translate Loading commit data...
headerdep.pl Loading commit data...
headers.sh Loading commit data...
headers_check.pl Loading commit data...
headers_install.sh Loading commit data...
insert-sys-cert.c Loading commit data...
kallsyms.c Loading commit data...
kernel-doc Loading commit data...
kernel-doc-xml-ref Loading commit data...
ld-version.sh Loading commit data...
link-vmlinux.sh Loading commit data...
makelst Loading commit data...
markup_oops.pl Loading commit data...
mkcompile_h Loading commit data...
mkmakefile Loading commit data...
mksysmap Loading commit data...
mkuboot.sh Loading commit data...
mkversion Loading commit data...
module-common.lds Loading commit data...
namespace.pl Loading commit data...
objdiff Loading commit data...
patch-kernel Loading commit data...
pnmtologo.c Loading commit data...
profile2linkerlist.pl Loading commit data...
prune-kernel Loading commit data...
recordmcount.c Loading commit data...
recordmcount.h Loading commit data...
recordmcount.pl Loading commit data...
setlocalversion Loading commit data...
show_delta Loading commit data...
sign-file.c Loading commit data...
sortextable.c Loading commit data...
sortextable.h Loading commit data...
spelling.txt Loading commit data...
stackdelta Loading commit data...
stackusage Loading commit data...
tags.sh Loading commit data...
unifdef.c Loading commit data...
ver_linux Loading commit data...
xen-hypercalls.sh Loading commit data...
xz_wrap.sh Loading commit data...