Skip to content

FreeBSD build fails unless I overwrite target name and add -Duse-zig-libcxx=true #13949

@nunziotocci

Description

@nunziotocci

Zig Version

0.11.0-dev.809+b911b54ae

Steps to Reproduce and Observed Behavior

  1. compile LLVM 15 from source and install to /home/nunzio/local/llvm15-release/
  2. compile zstd from source and install to same prefix (not sure this actually matters, was trying to debug when I did this)
  3. git clone https://github.com/ziglang/zig
  4. cd zig
  5. git checkout b911b54 (latest CI passed commit when I cloned)
  6. mkdir build
  7. cmake .. -DCMAKE_PREFIX_PATH=$HOME/local/llvm15-release -DCMAKE_INSTALL_PATH=$HOME/local/zig
  8. make install

First got:

cd /home/nunzio/Repos/zig && /home/nunzio/Repos/zig/build/zig1 /home/nunzio/Repos/zig/lib build-exe src/main.zig -ofmt=c -lc -OReleaseSmall --name zig2 -femit-bin="/home/nunzio/Repos/zig/build/zig2.c" --
pkg-begin build_options /home/nunzio/Repos/zig/build/config.zig --pkg-end -target amd64-freebsd
error: UnknownArchitecture
[2/6] cd /home/nunzio/Repos/zig && /home/nunzio/Repos/zig/build/zig1 /home/nunzio/Repos/zig/lib build-obj lib/compiler_rt.zig -ofmt=c -OReleaseSmall --name compiler_rt -femit-bin="/home/nunzio/Repos/zig/
build/compiler_rt.c" --pkg-begin build_options /home/nunzio/Repos/zig/build/config.zig --pkg-end -target amd64-freebsd

Then after I forced the arch to be x86_64 I got:

[100%] Building stage3
error: ld.lld: undefined symbol: _Unwind_Resume
    note: referenced by cxxrt_exception.cc:0
    note:               cxxrt_exception.o:(alloc_or_die(unsigned long)) in archive /usr/lib/libc++.a
    note: referenced by cxxrt_exception.cc:0
    note:               cxxrt_exception.o:(__cxa_free_exception) in archive /usr/lib/libc++.a
    note: referenced by cxxrt_exception.cc:0
    note:               cxxrt_exception.o:(__cxa_begin_catch) in archive /usr/lib/libc++.a
    note: referenced 172 more times
error: ld.lld: undefined symbol: _Unwind_RaiseException
    note: referenced by cxxrt_exception.cc:768
    note:               cxxrt_exception.o:(__cxa_throw) in archive /usr/lib/libc++.a
    note: referenced by cxxrt_exception.cc:768
    note:               cxxrt_exception.o:(__cxa_rethrow_primary_exception) in archive /usr/lib/libc++.a
error: ld.lld: undefined symbol: _Unwind_Resume_or_Rethrow
    note: referenced by cxxrt_exception.cc:0
    note:               cxxrt_exception.o:(__cxa_rethrow) in archive /usr/lib/libc++.a
error: ld.lld: undefined symbol: _Unwind_Backtrace
    note: referenced by cxxrt_exception.cc:743
    note:               cxxrt_exception.o:(report_failure(_Unwind_Reason_Code, __cxxabiv1::__cxa_exception*)) in archive /usr/lib/libc++.a
error: ld.lld: undefined symbol: _Unwind_GetLanguageSpecificData
    note: referenced by cxxrt_exception.cc:1106
    note:               cxxrt_exception.o:(__gxx_personality_v0) in archive /usr/lib/libc++.a
error: ld.lld: undefined symbol: _Unwind_SetIP
    note: referenced by cxxrt_exception.cc:1203
    note:               cxxrt_exception.o:(__gxx_personality_v0) in archive /usr/lib/libc++.a
error: ld.lld: undefined symbol: _Unwind_SetGR
    note: referenced by cxxrt_exception.cc:1204
    note:               cxxrt_exception.o:(__gxx_personality_v0) in archive /usr/lib/libc++.a
    note: referenced by cxxrt_exception.cc:1206
    note:               cxxrt_exception.o:(__gxx_personality_v0) in archive /usr/lib/libc++.a
error: ld.lld: undefined symbol: _Unwind_GetRegionStart
    note: referenced by dwarf_eh.h:343 (/usr/src/contrib/libcxxrt/dwarf_eh.h:343)
    note:               cxxrt_exception.o:(parse_lsda(_Unwind_Context*, unsigned char*)) in archive /usr/lib/libc++.a
    note: referenced by dwarf_eh.h:273 (/usr/src/contrib/libcxxrt/dwarf_eh.h:273)
    note:               cxxrt_exception.o:(parse_lsda(_Unwind_Context*, unsigned char*)) in archive /usr/lib/libc++.a
    note: referenced by dwarf_eh.h:413 (/usr/src/contrib/libcxxrt/dwarf_eh.h:413)
    note:               cxxrt_exception.o:(dwarf_eh_find_callsite(_Unwind_Context*, dwarf_eh_lsda*, dwarf_eh_action*)) in archive /usr/lib/libc++.a
    note: referenced 1 more times
error: ld.lld: undefined symbol: _Unwind_GetTextRelBase
    note: referenced by dwarf_eh.h:267 (/usr/src/contrib/libcxxrt/dwarf_eh.h:267)
    note:               cxxrt_exception.o:(parse_lsda(_Unwind_Context*, unsigned char*)) in archive /usr/lib/libc++.a
    note: referenced by dwarf_eh.h:267 (/usr/src/contrib/libcxxrt/dwarf_eh.h:267)
    note:               cxxrt_exception.o:(get_type_info_entry(_Unwind_Context*, dwarf_eh_lsda*, int)) in archive /usr/lib/libc++.a
error: ld.lld: undefined symbol: _Unwind_GetDataRelBase
    note: referenced by dwarf_eh.h:270 (/usr/src/contrib/libcxxrt/dwarf_eh.h:270)
    note:               cxxrt_exception.o:(parse_lsda(_Unwind_Context*, unsigned char*)) in archive /usr/lib/libc++.a
    note: referenced by dwarf_eh.h:270 (/usr/src/contrib/libcxxrt/dwarf_eh.h:270)
    note:               cxxrt_exception.o:(get_type_info_entry(_Unwind_Context*, dwarf_eh_lsda*, int)) in archive /usr/lib/libc++.a
error: ld.lld: undefined symbol: _Unwind_GetIP
    note: referenced by dwarf_eh.h:413 (/usr/src/contrib/libcxxrt/dwarf_eh.h:413)
    note:               cxxrt_exception.o:(dwarf_eh_find_callsite(_Unwind_Context*, dwarf_eh_lsda*, dwarf_eh_action*)) in archive /usr/lib/libc++.a
    note: referenced by cxxrt_exception.cc:675
    note:               cxxrt_exception.o:(trace(_Unwind_Context*, void*)) in archive /usr/lib/libc++.a
error: zig...
error: The following command exited with error code 1:
/usr/home/nunzio/Repos/zig/build/zig2 build-exe --stack 33554432 /usr/home/nunzio/Repos/zig/src/main.zig -lc /home/nunzio/Repos/zig/build/zigcpp/libzigcpp.a /home/nunzio/local/llvm15-release/lib/libclangFrontendTool.a /home/nunzio/local/llvm15-release/lib/libclangCodeGen.a /home/nunzio/local/llvm15-release/lib
/libclangFrontend.a /home/nunzio/local/llvm15-release/lib/libclangDriver.a /home/nunzio/local/llvm15-release/lib/libclangSerialization.a /home/nunzio/local/llvm15-release/lib/libclangSema.a /home/nunzio/local/llvm15-release/lib/libclangStaticAnalyzerFrontend.a /home/nunzio/local/llvm15-release/lib/libclangStat
icAnalyzerCheckers.a /home/nunzio/local/llvm15-release/lib/libclangStaticAnalyzerCore.a /home/nunzio/local/llvm15-release/lib/libclangAnalysis.a /home/nunzio/local/llvm15-release/lib/libclangASTMatchers.a /home/nunzio/local/llvm15-release/lib/libclangAST.a /home/nunzio/local/llvm15-release/lib/libclangParse.a
/home/nunzio/local/llvm15-release/lib/libclangSema.a /home/nunzio/local/llvm15-release/lib/libclangBasic.a /home/nunzio/local/llvm15-release/lib/libclangEdit.a /home/nunzio/local/llvm15-release/lib/libclangLex.a /home/nunzio/local/llvm15-release/lib/libclangARCMigrate.a /home/nunzio/local/llvm15-release/lib/li
bclangRewriteFrontend.a /home/nunzio/local/llvm15-release/lib/libclangRewrite.a /home/nunzio/local/llvm15-release/lib/libclangCrossTU.a /home/nunzio/local/llvm15-release/lib/libclangIndex.a /home/nunzio/local/llvm15-release/lib/libclangToolingCore.a /home/nunzio/local/llvm15-release/lib/libclangExtractAPI.a /h
ome/nunzio/local/llvm15-release/lib/libclangSupport.a /usr/local/lib/libunwind.so /home/nunzio/local/llvm15-release/lib/liblldMinGW.a /home/nunzio/local/llvm15-release/lib/liblldELF.a /home/nunzio/local/llvm15-release/lib/liblldCOFF.a /home/nunzio/local/llvm15-release/lib/liblldWasm.a /home/nunzio/local/llvm15
-release/lib/liblldMachO.a /home/nunzio/local/llvm15-release/lib/liblldCommon.a -lLLVMWindowsManifest -lLLVMWindowsDriver -lLLVMXRay -lLLVMLibDriver -lLLVMDlltoolDriver -lLLVMCoverage -lLLVMLineEditor -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMX86TargetMCA -lLLVMX86Disasse
mbler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyDesc -lLLVMWebAssemblyUtils -lLLVMWebAssemblyInfo -lLLVMVEDisassembler -lLLVMVEAsmParser -lLLVMVECodeGen -lLLVMVEDesc -lLLVMVEInfo -lLLVMSyste
mZDisassembler -lLLVMSystemZAsmParser -lLLVMSystemZCodeGen -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDisassembler -lLLVMSparcAsmParser -lLLVMSparcCodeGen -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMRISCVDisassembler -lLLVMRISCVAsmParser -lLLVMRISCVCodeGen -lLLVMRISCVDesc -lLLVMRISCVInfo -lLLVMPowerPCDisassemble
r -lLLVMPowerPCAsmParser -lLLVMPowerPCCodeGen -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMMSP430Disassembler -lLLVMMSP430AsmParser -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMipsDisassembler -lLLVMMipsAsmParser -lLLVMMipsCodeGen -lLLVMMipsDesc -
lLLVMMipsInfo -lLLVMLanaiDisassembler -lLLVMLanaiCodeGen -lLLVMLanaiAsmParser -lLLVMLanaiDesc -lLLVMLanaiInfo -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMBPFDisassembler -lLLVMBPFAsmParser -lLLVMBPFCodeGen -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMAVR
Disassembler -lLLVMAVRAsmParser -lLLVMAVRCodeGen -lLLVMAVRDesc -lLLVMAVRInfo -lLLVMARMDisassembler -lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMDesc -lLLVMARMUtils -lLLVMARMInfo -lLLVMAMDGPUTargetMCA -lLLVMAMDGPUDisassembler -lLLVMAMDGPUAsmParser -lLLVMAMDGPUCodeGen -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMD
GPUInfo -lLLVMAArch64Disassembler -lLLVMAArch64AsmParser -lLLVMAArch64CodeGen -lLLVMAArch64Desc -lLLVMAArch64Utils -lLLVMAArch64Info -lLLVMOrcJIT -lLLVMMCJIT -lLLVMJITLink -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMOrcTargetProcess -lLLVMOrcShared -lLLVMDWP -lLLVMDebugInfoGSYM -lLLVMOption
 -lLLVMObjectYAML -lLLVMObjCopy -lLLVMMCA -lLLVMMCDisassembler -lLLVMLTO -lLLVMPasses -lLLVMCFGuard -lLLVMCoroutines -lLLVMObjCARCOpts -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMInstrumentation -lLLVMFrontendOpenMP -lLLVMFrontendOpenACC -lLLVMExtensions -lLLVMDWARFLinker -lLLVMGlobalISel -lLLVMMIRParser -lLL
VMAsmPrinter -lLLVMSelectionDAG -lLLVMCodeGen -lLLVMIRReader -lLLVMAsmParser -lLLVMInterfaceStub -lLLVMFileCheck -lLLVMFuzzMutate -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMSymbolize -lLLVMDebugInfoPDB
-lLLVMDebugInfoMSF -lLLVMDebugInfoDWARF -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMBitReader -lLLVMFuzzerCLI -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMTableGen -lLLVMSupport -lLLVMDemangle -lexecinfo -lz -lzstd /usr/lib/libc++.a --cache-dir /u
sr/home/nunzio/Repos/zig/zig-cache --global-cache-dir /home/nunzio/.cache/zig --name zig --pkg-begin build_options /usr/home/nunzio/Repos/zig/zig-cache/options/pRUwb64kQ9rYUb_EvqOgdRXgZ3UiddVBn40G4Nc62Zyqg2-axylVF1dPUXoFpD_a --pkg-end -I /home/nunzio/local/llvm15-release/include -I /usr/home/nunzio/local/llvm1
5-release/include -L /usr/home/nunzio/local/llvm15-release/lib -L /home/nunzio/local/llvm15-release/lib -I /home/nunzio/local/llvm15-release/include -fno-build-id --zig-lib-dir /home/nunzio/Repos/zig/lib --enable-cache
error: the following build command failed with exit code 1:
/usr/home/nunzio/Repos/zig/zig-cache/o/5d43b86d4d88e3525c2120de4d7b1954/build /usr/home/nunzio/Repos/zig/build/zig2 /usr/home/nunzio/Repos/zig /usr/home/nunzio/Repos/zig/zig-cache /home/nunzio/.cache/zig compile --zig-lib-dir /home/nunzio/Repos/zig/lib -Dconfig_h=/home/nunzio/Repos/zig/build/config.h -Denable-
llvm -Dtarget=native -Dcpu=native -Dversion-string=0.11.0-dev.809+b911b54ae

Expected Behavior

I expected it to build. My solution:

  1. nano CMakeFiles/zig2.dir/build.make (replace amd64 with x86_65)
  2. nano ./CMakeFiles/stage3.dir/build.make (add -Duse-zig-libcxx=true to build compile line)
  3. nano cmake_install.cmake add -Duse-zig-libcxx=true to ZIG_BUILD_ARGS
  4. make install

Here's my uname -a:

FreeBSD <host> 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC amd64

Looking forward to playing with zig, thank you for all of the hard work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-freebsdFreeBSD

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions