Bug 1834678 - Change the llvm-config trick for cross-compilation. r=gfx-reviewers,gw

Contrary to ld64, lld doesn't ignore libraries it's given on the command
line, and -lLLVM-14 ends up as a link error when using lld.

So instead of relying on the flags llvm-config outputs to be kind of
ignored, we replace them at the source by wrapping llvm-config itself.

Differential Revision: https://phabricator.services.mozilla.com/D178900
This commit is contained in:
Mike Hommey 2023-05-25 01:49:06 +00:00
Родитель 3f6669c88c
Коммит f8a28f990a
2 изменённых файлов: 5 добавлений и 12 удалений

Просмотреть файл

@ -1,15 +1,5 @@
[binaries]
llvm-config = '/builds/worker/fetches/clang/bin/llvm-config'
[properties]
# When linking `libOSMesa.dylib` Meson uses options provided by `llvm-config`.
# The binary for `llvm-config` in Firefox CI comes from a native Linux clang,
# which gives the link options for the Linux libLLVM-11.so in the Linux clang.
# However, we want to link against a native macOS clang's libLLVM.dylib, which
# we have available in a separate directory.
# Meson will still have -lLLVM-11 on the command line, but the linker will
# only warn that it has the wrong format (because it's not for macOS).
cpp_link_args = ['-L/builds/worker/fetches/clang-mac/clang/lib', '-lLLVM']
llvm-config = '/builds/worker/fetches/clang-mac/clang/bin/llvm-config'
[host_machine]
system = 'darwin'

Просмотреть файл

@ -29,7 +29,10 @@ END_PKGCONFIG_WRAPPER
chmod +x "${TARGET_TRIPLE}-pkg-config"
popd
export PATH="${MOZ_FETCHES_DIR}/rustc/bin:${MOZ_FETCHES_DIR}/cctools/bin:${MOZ_FETCHES_DIR}/clang/bin:${MOZ_FETCHES_DIR}/wrench-deps/meson:${PATH}"
[ -d "${MOZ_FETCHES_DIR}/clang-mac/clang" ] && cat > ${MOZ_FETCHES_DIR}/clang-mac/clang/bin/llvm-config <<EOF_LLVM_CONFIG
#!/bin/sh
${MOZ_FETCHES_DIR}/clang/bin/llvm-config "\$@" | sed 's,${MOZ_FETCHES_DIR}/clang,${MOZ_FETCHES_DIR}/clang-mac/clang,g;s,-lLLVM-[0-9]\+,-lLLVM,g'
EOF_LLVM_CONFIG
# The x86_64-darwin11-ld linker from cctools requires libraries provided
# by clang, so we need to set LD_LIBRARY_PATH for that to work.