This fixes machine emulation name appended to LDFLAGS when cross compiling. This was found while testing projects/clang900-import branch, but it should affect master/HEAD too.
In 'contrib/llvm/tools/lld/ELF/Driver.cpp' there's a list of supported target names, and the current code only covers amd64/i386 targets.
The proposed fix is based on solution found in "sys/conf/kern.mk".
Here is the error message cross compiling from amd64 to powerpc64:
--- clang.full --- + c++ -target powerpc64-unknown-freebsd13.0 '--sysroot=/usr/obj/usr/home/alfredo.junior/src/freebsd/powerpc.powerpc64/tmp' -B/usr/obj/usr/home/alfredo.junior/src/freebsd/powerpc.powerpc64/tmp/usr/bin -O2 -pipe -I/usr/obj/usr/home/alfredo.junior/src/freebsd/powerpc.powerpc64/lib/clang/libclang -I/usr/obj/usr/home/alfredo.junior/src/freebsd/powerpc.powerpc64/lib/clang/libllvm -I/usr/home/alfredo.junior/src/freebsd/contrib/llvm/tools/clang/include -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_STATIC_ANALYZER -target powerpc64-unknown-freebsd13.0 -I/usr/home/alfredo.junior/src/freebsd/lib/clang/include -I/usr/home/alfredo.junior/src/freebsd/contrib/llvm/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DHAVE_VCS_VERSION_INC '-DLLVM_DEFAULT_TARGET_TRIPLE="powerpc64-unknown-freebsd13.0"' '-DLLVM_HOST_TRIPLE="powerpc64-unknown-freebsd13.0"' '-DDEFAULT_SYSROOT=""' -DLLVM_TARGET_ENABLE_AARCH64 -DLLVM_TARGET_ENABLE_ARM -DLLVM_TARGET_ENABLE_MIPS -DLLVM_TARGET_ENABLE_POWERPC -DLLVM_TARGET_ENABLE_SPARC -DLLVM_TARGET_ENABLE_X86 '-DLLVM_NATIVE_ASMPARSER=LLVMInitializePowerPCAsmParser' '-DLLVM_NATIVE_ASMPRINTER=LLVMInitializePowerPCAsmPrinter' '-DLLVM_NATIVE_DISASSEMBLER=LLVMInitializePowerPCDisassembler' '-DLLVM_NATIVE_TARGET=LLVMInitializePowerPCTarget' '-DLLVM_NATIVE_TARGETINFO=LLVMInitializePowerPCTargetInfo' '-DLLVM_NATIVE_TARGETMC=LLVMInitializePowerPCTargetMC' -ffunction-sections -fdata-sections -gline-tables-only -Wno-format-zero-length -fstack-protector-strong -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses -Qunused-arguments -fno-exceptions -fno-rtti '-std=c++11' '-stdlib=libc++' -Wno-c++11-extensions -Wl,-m -Wl,elf_powerpc64_fbsd -Wl,--gc-sections -static -o clang.full cc1_main.o cc1as_main.o cc1gen_reproducer_main.o driver.o /usr/obj/usr/home/alfredo.junior/src/freebsd/powerpc.powerpc64/lib/clang/libclang/libclang.a /usr/obj/usr/home/alfredo.junior/src/freebsd/powerpc.powerpc64/lib/clang/libllvm/libllvm.a -lz -lexecinfo -lelf -lncursesw -lpthread ld: error: unknown emulation: elf_powerpc64_fbsd c++: error: linker command failed with exit code 1 (use -v to see invocation) *** [clang.full] Error code 1 make[5]: stopped in /usr/home/alfredo.junior/src/freebsd/usr.bin/clang/clang
Note that "-Wl,elf_powerpc64_fbsd" is passed to c++ comand line