Created attachment 849173 [details] compressed build log from aarch64-cross seems the hosts portage can't make use of the llvm-tblgen within the prefix: [1/130] cd /var/tmp/portage/sys-devel/lld-15.0.7/work/lld_build && /usr/aarch64-unknown-linux-gnu/usr/lib/llvm/15/bin/llvm-tblgen -gen-opt-parser-defs -I /var/tmp/portage/sys-devel/lld-15.0.7/work/lld/COFF -I/var/tmp/portage/sys-devel/lld-15.0.7/work/lld/include -I/var/tmp/portage/sys-devel/lld-15.0.7/work/lld_build/include -I/include -I/usr/aarch64-unknown-linux-gnu/usr/lib/llvm/15/include /var/tmp/portage/sys-devel/lld-15.0.7/work/lld/COFF/Options.td --write-if-changed -o COFF/Options.inc -d COFF/Options.inc.d FAILED: COFF/Options.inc /var/tmp/portage/sys-devel/lld-15.0.7/work/lld_build/COFF/Options.inc cd /var/tmp/portage/sys-devel/lld-15.0.7/work/lld_build && /usr/aarch64-unknown-linux-gnu/usr/lib/llvm/15/bin/llvm-tblgen -gen-opt-parser-defs -I /var/tmp/portage/sys-devel/lld-15.0.7/work/lld/COFF -I/var/tmp/portage/sys-devel/lld-15.0.7/work/lld/include -I/var/tmp/portage/sys-devel/lld-15.0.7/work/lld_build/include -I/include -I/usr/aarch64-unknown-linux-gnu/usr/lib/llvm/15/include /var/tmp/portage/sys-devel/lld-15.0.7/work/lld/COFF/Options.td --write-if-changed -o COFF/Options.inc -d COFF/Options.inc.d /bin/sh: line 1: /usr/aarch64-unknown-linux-gnu/usr/lib/llvm/15/bin/llvm-tblgen: cannot execute binary file: Exec format error
Created attachment 849175 [details] output from emerge --info (aarch64)
I can second this one. The ebuild tries to use the tools from the root you're merging into which obviously fails if you're cross compiling. Removing llvm_pkg_setup from the lld ebuild gets it through the configure stage, but there must be something else happening in cmake because it still tries to use the wrong llvm-tblgen.
I thought it may just need the same treatment I gave Clang recently, but that doesn't work. I'll look closer at the weekend.
I dug into this a little yesterday and believe I've found two issues: 1. llvm_pkg_setup will prepend ${ESYSROOT}/usr/lib/llvm/${PV}/bin to the path in front of any existing llvm installations it finds. Thus the target's llvm install will be placed before the host's llvm. 2. The main CMakeLists.txt for lld searches for the llvm installation using find_package. This only searches the sysroot and thus it finds the target's llvm installation. That's desired for any libraries it needs to link against, but it also sets LLVM_TOOLS_BINARY_DIR to the bin folder in the sysroot and subsequently uses that path to locate some build tools. As a quick and dirty workaround, I've commented out the call to llvm_pkg_setup in the lld ebuild and manually set LLVM_TOOLS_BINARY_DIR to my llvm bin dir in CMakeLists.txt after the find_package call on line 65 and the merge succeeded.
That's what I found with Clang too, but there's a CMake-related reason that I don't fully understand for why ${ESYSROOT}/usr/lib/llvm/${PV}/bin needs to be in the PATH. I was able to fix Clang without removing that from the PATH.
This is now fixed.