➜ kernel-all git:(master) ✗ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang init/main.o
CALL scripts/checksyscalls.sh
CC init/main.o
aarch64-linux-gnu-ld: init/.tmp_main.o: compiled for a little endian system and target is big endian
aarch64-linux-gnu-ld: failed to merge target specific data of file init/.tmp_main.o
scripts/Makefile.build:305: recipe for target 'init/main.o' failed
make[1]: *** [init/main.o] Error 1
Makefile:1678: recipe for target 'init/main.o' failed
make: *** [init/main.o] Error 2
Just started investigating but I think it has something to do with the fact that aarch64_be-linux-gnu needs to be the target triple when CONFIG_CPU_BIG_ENDIAN is set.
However, if I change it to that, arch/arm64/kernel/vdso/gettimeofday.S and arch/arm64/kernel/vdso/gettimeofday.S just explode (could absolutely be my toolchains but they work fine for little endian).
Which version of Clang are you using?
I got some hints and patches by Arnd Bergman today, this issue seems related: https://reviews.llvm.org/D42930
I have the feeling that CROSS_COMPILE needs to be CROSS_COMPILE=aarch64_be-linux-gnu- (note the additional _be. From @agners link above, which then links to https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140310/101365.html.
Hmm, the debian package binutils-aarch64-linux-gnu does not include any _be binaries.
https://packages.ubuntu.com/en/trusty/amd64/binutils-aarch64-linux-gnu/filelist
Maybe that's a bug for the debian maintainers, or something else is the problem.
The kernel should additionally warn if CROSS_COMPILE doesn't match a shortlist based on ARCH.
oh, maybe if the compiler needs -mbig-endian, the linker also needs some flag?
https://reviews.llvm.org/D52784
related to #57
Most helpful comment
https://reviews.llvm.org/rC344597