Code: Select all
clang -target x86_64-pc-linux-gnu -fuse-ld=/usr/local/bin/x86_64-elf-ld # for x86_64
clang -target i686-linux-gnu -fuse-ld=/usr/local/bin/x86_64-elf-ld # for i686, you can reuse x86_64-ld
clang -target arm-none-eabihf -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=arm1176jzf-s -mfloat-abi=hard # for armv6f, for example arm1176jzf-s Raspberry Pi 1
clang -target arm-none-eabihf -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=cortex-a7 -mfloat-abi=hard # for armv7a, for example cortex-a7 in Raspberry Pi 2
clang -target aarch64-linux-gnu -fuse-ld=/usr/local/bin/aarch64-linux-gnu-ld -mcpu=cortex-a53 # for aarch64, for example cortex-a53 in Raspberry Pi 3
# Some other ARM cores you might run across
clang -target arm-none-eabi -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=arm7tdmi
clang -target arm-none-eabi -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=arm926ej-s
clang -target arm-none-eabi -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=cortex-m0
clang -target arm-none-eabi -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=cortex-m3
clang -target arm-none-eabihf -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=cortex-m4 -mfloat-abi=hard
clang -target arm-none-eabihf -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=cortex-m7 -mfloat-abi=hard
clang -target arm-none-eabi -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=cortex-m23
clang -target arm-none-eabihf -fuse-ld=/usr/local/bin/arm-none-eabi-ld -mcpu=cortex-m33 -mfloat-abi=hard
I was trying to use "-target x86_64-gnu" but that resulted in clang generating arguments targeting Apple's ld, freaking GNU ld out. Similar situation happened for aarch64. So you do need to lie a bit so clang would emit the correct command line for the linker, and the linker would accept it.