Closed issue by jjsullivan5196 on void-packages repository https://github.com/void-linux/void-packages/issues/24959 Description: **Old info below**, I've made it possible to cross-compile without touching the `llvm10` template or nasty hacks. See the latest template [here](https://github.com/jjsullivan5196/void-packages/tree/zig-cross/srcpkgs/zig) I've been trying to get the zig compiler cross-compiled to aarch64 (want to have it on the pinephone) but I'm getting snubbed by some linker errors. I took a look at the zig project's own [bootstrap package](https://github.com/ziglang/zig-bootstrap) and found that it needs an AVR codegen target for cross targets, and that the host zig compiler can be used to cross-compiler the later stages. I made appropriate changes to the [`llvm10` and `zig` templates](https://github.com/jjsullivan5196/void-packages/tree/zig-cross). On `aarch64` and `aarch64-musl` I can fully compile stage0 with `cross-gcc`, but I get this mess when it links ``` [ 97%] Linking CXX static library zig_cpp/libzigcompiler.a [ 97%] Built target zigcompiler Scanning dependencies of target zig0 [ 98%] Building CXX object CMakeFiles/zig0.dir/src/stage2.cpp.o [ 98%] Building CXX object CMakeFiles/zig0.dir/src/main.cpp.o [ 99%] Linking CXX executable zig0 /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMWindowsManifest.a(WindowsManifestMerger.cpp.o): in function `stripComments(_xmlNode*) [clone .isra.0]': (.text._ZL13stripCommentsP8_xmlNode.isra.0+0x54): undefined reference to `xmlUnlinkNode' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZL13stripCommentsP8_xmlNode.isra.0+0x60): undefined reference to `xmlFreeNode' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMWindowsManifest.a(WindowsManifestMerger.cpp.o): in function `searchOrDefine(unsigned char const*, _xmlNode*)': (.text._ZL14searchOrDefinePKhP8_xmlNode+0x15c): undefined reference to `xmlNewNs' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMWindowsManifest.a(WindowsManifestMerger.cpp.o): in function `llvm::windows_manifest::WindowsManifestMerger::WindowsManifestMergerImpl::~WindowsManifestMergerImpl()': (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImplD2Ev+0x24): undefined reference to `xmlFreeDoc' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImplD2Ev+0x38): undefined reference to `xmlFree' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImplD2Ev+0x3c): undefined reference to `xmlFree' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMWindowsManifest.a(WindowsManifestMerger.cpp.o): in function `treeMerge(_xmlNode*, _xmlNode*)': (.text._ZL9treeMergeP8_xmlNodeS0_+0xc4): undefined reference to `xmlNewProp' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZL9treeMergeP8_xmlNodeS0_+0x120): undefined reference to `xmlStrdup' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZL9treeMergeP8_xmlNodeS0_+0x180): undefined reference to `xmlCopyNamespace' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZL9treeMergeP8_xmlNodeS0_+0x52c): undefined reference to `xmlUnlinkNode' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZL9treeMergeP8_xmlNodeS0_+0x538): undefined reference to `xmlAddChild' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZL9treeMergeP8_xmlNodeS0_+0x74c): undefined reference to `xmlFree' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZL9treeMergeP8_xmlNodeS0_+0x754): undefined reference to `xmlFree' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZL9treeMergeP8_xmlNodeS0_+0x924): undefined reference to `xmlFree' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZL9treeMergeP8_xmlNodeS0_+0x928): undefined reference to `xmlFree' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMWindowsManifest.a(WindowsManifestMerger.cpp.o): in function `checkAndStripPrefixes(_xmlNode*, std::vector<_xmlNs*, std::allocator<_xmlNs*> >&)': (.text._ZL21checkAndStripPrefixesP8_xmlNodeRSt6vectorIP6_xmlNsSaIS3_EE+0x2a8): undefined reference to `xmlFreeNs' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMWindowsManifest.a(WindowsManifestMerger.cpp.o): in function `llvm::windows_manifest::WindowsManifestMerger::WindowsManifestMergerImpl::getMergedManifest()': (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl17getMergedManifestEv+0x44): undefined reference to `xmlDocGetRootElement' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl17getMergedManifestEv+0x64): undefined reference to `xmlNewDoc' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl17getMergedManifestEv+0x70): undefined reference to `xmlDocSetRootElement' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl17getMergedManifestEv+0x78): undefined reference to `xmlKeepBlanksDefault' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl17getMergedManifestEv+0x98): undefined reference to `xmlDocDumpFormatMemoryEnc' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl17getMergedManifestEv+0xac): undefined reference to `xmlFree' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl17getMergedManifestEv+0xb0): undefined reference to `xmlFree' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl17getMergedManifestEv+0xc4): undefined reference to `xmlFreeDoc' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMWindowsManifest.a(WindowsManifestMerger.cpp.o): in function `llvm::windows_manifest::WindowsManifestMerger::WindowsManifestMergerImpl::merge(llvm::MemoryBuffer const&)': (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl5mergeERKNS_12MemoryBufferE+0x54): undefined reference to `xmlSetGenericErrorFunc' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl5mergeERKNS_12MemoryBufferE+0x70): undefined reference to `xmlReadMemory' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl5mergeERKNS_12MemoryBufferE+0x84): undefined reference to `xmlSetGenericErrorFunc' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl5mergeERKNS_12MemoryBufferE+0xb0): undefined reference to `xmlDocGetRootElement' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl5mergeERKNS_12MemoryBufferE+0xe0): undefined reference to `xmlUnlinkNode' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl5mergeERKNS_12MemoryBufferE+0xec): undefined reference to `xmlFreeNode' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm16windows_manifest21WindowsManifestMerger25WindowsManifestMergerImpl5mergeERKNS_12MemoryBufferE+0x104): undefined reference to `xmlDocGetRootElement' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMSupport.a(Compression.cpp.o): in function `llvm::zlib::compress(llvm::StringRef, llvm::SmallVectorImpl&, int)': (.text._ZN4llvm4zlib8compressENS_9StringRefERNS_15SmallVectorImplIcEEi+0x40): undefined reference to `compressBound' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm4zlib8compressENS_9StringRefERNS_15SmallVectorImplIcEEi+0x6c): undefined reference to `compress2' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMSupport.a(Compression.cpp.o): in function `llvm::zlib::uncompress(llvm::StringRef, char*, unsigned long&)': (.text._ZN4llvm4zlib10uncompressENS_9StringRefEPcRm+0x3c): undefined reference to `uncompress' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMSupport.a(Compression.cpp.o): in function `llvm::zlib::crc32(llvm::StringRef)': (.text._ZN4llvm4zlib5crc32ENS_9StringRefE+0x14): undefined reference to `crc32' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMSupport.a(CRC.cpp.o): in function `llvm::crc32(unsigned int, llvm::ArrayRef)': (.text._ZN4llvm5crc32EjNS_8ArrayRefIhEE+0x38): undefined reference to `crc32' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMSupport.a(DynamicLibrary.cpp.o): in function `llvm::sys::DynamicLibrary::HandleSet::~HandleSet()': (.text._ZN4llvm3sys14DynamicLibrary9HandleSetD2Ev+0x24): undefined reference to `dlclose' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm3sys14DynamicLibrary9HandleSetD2Ev+0x38): undefined reference to `dlclose' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMSupport.a(DynamicLibrary.cpp.o): in function `llvm::sys::DynamicLibrary::HandleSet::DLOpen(char const*, std::__cxx11::basic_string, std::allocator >*)': (.text._ZN4llvm3sys14DynamicLibrary9HandleSet6DLOpenEPKcPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x14): undefined reference to `dlopen' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm3sys14DynamicLibrary9HandleSet6DLOpenEPKcPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2c): undefined reference to `dlerror' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMSupport.a(DynamicLibrary.cpp.o): in function `llvm::sys::DynamicLibrary::HandleSet::DLClose(void*)': (.text._ZN4llvm3sys14DynamicLibrary9HandleSet7DLCloseEPv+0x0): undefined reference to `dlclose' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMSupport.a(DynamicLibrary.cpp.o): in function `llvm::sys::DynamicLibrary::HandleSet::DLSym(void*, char const*)': (.text._ZN4llvm3sys14DynamicLibrary9HandleSet5DLSymEPvPKc+0x0): undefined reference to `dlsym' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/usr/lib/libLLVMSupport.a(Process.cpp.o): in function `llvm::sys::Process::FileDescriptorHasColors(int)': (.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xa0): undefined reference to `setupterm' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xcc): undefined reference to `tigetnum' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xd8): undefined reference to `set_curterm' /usr/lib/gcc/aarch64-linux-gnu/9.3.0/../../../../aarch64-linux-gnu/bin/ld: (.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xdc): undefined reference to `del_curterm' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/zig0.dir/build.make:309: zig0] Error 1 make[1]: *** [CMakeFiles/Makefile2:110: CMakeFiles/zig0.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 99%] Built target zig_build_libstage2 make: *** [Makefile:149: all] Error 2 => ERROR: zig-0.6.0_1: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2 => ERROR: in do_build() at common/build-style/cmake.sh:74 ``` This version of `llvm10` can still build zig on the host target (x86_64) without a problem. Not sure what's causing this to happen. Has anyone seen errors like this trying to build other llvm10-based software, maybe rust? @Duncaen @ifreund @q66