Page MenuHomeFreeBSD

fix emulation name passed to linker when cross compiling
Needs ReviewPublic

Authored by alfredo.junior_eldorado.org.br on Sep 26 2019, 1:49 PM.

Details

Summary

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

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 26811
Build 25145: arc lint + arc unit

Event Timeline

dim updated this revision to Diff 62796.Oct 1 2019, 5:30 PM

A few minor changes.

Adding imp and bdrewery for some more sanity checking. I know almost nothing about meta mode. :)

bdrewery added a subscriber: sjg.Dec 13 2019, 5:43 PM

FYI This fixes *DIRDEPS* not *META*. The file is misnamed.
I suggest adding @sjg to the review

imp added inline comments.Dec 13 2019, 6:02 PM
share/mk/local.meta.sys.mk
45

any reason we can't relocate this to a common file? I hate having long lists like this in multiple places.

sjg added inline comments.Dec 13 2019, 7:46 PM
share/mk/local.meta.sys.mk
45

Agreed, got a name suggestion?

linimon removed a subscriber: linimon.Sun, Jan 5, 10:30 PM