Page MenuHomeFreeBSD

fix emulation name passed to linker when cross compiling
Needs ReviewPublic

Authored by alfredo on Sep 26 2019, 1:49 PM.
Referenced Files
Unknown Object (File)
Dec 19 2023, 11:32 PM
Unknown Object (File)
Dec 10 2023, 7:05 PM
Unknown Object (File)
Jun 22 2023, 4:52 PM
Unknown Object (File)
Apr 8 2023, 12:31 AM
Unknown Object (File)
Mar 21 2023, 8:29 PM
Unknown Object (File)
Mar 15 2023, 2:04 PM
Unknown Object (File)
Mar 4 2023, 8:43 AM
Unknown Object (File)
Feb 10 2023, 12:05 AM

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 - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26811
Build 25145: arc lint + arc unit

Event Timeline

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

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

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.

share/mk/local.meta.sys.mk
45

Agreed, got a name suggestion?