Files
poky/meta/recipes-devtools/llvm/llvm/llvm-config
Alexander Kanavin 44bb88cc86 mesa: do not rely on native llvm-config in target sysroot
Sadly the magic is not perfect: llvm-config contains a hardcoded
value for the libdir from the native configuration, and things will
break if the target build installs libraries somewhere else (e.g. lib64).

llvm-config in target bindir also needs a rpath adjustment,
otherwise it simply won't even run when e.g. building for arm on x86.

To avoid patching llvm-source let's simply add more cases to the
llvm-config wrapper script, so that falling through to llvm-config binary
is avoided. Fortunately those cases are all static in what they return,
even though llvm-config binary does poke around the file tree to arrive
at them (which is where breakage happens if native and target don't match
exactly wrt libdir).

I verified that this works by building mesa with llvm enabled for
qemuarm64 and with baselib set to 'lib64' - so that both the target
architecture and target libdir differ from native ones.

Upstream tickets:
https://github.com/llvm/llvm-project/issues/58984
https://github.com/mesonbuild/meson/issues/11043

(From OE-Core rev: 056431883e94296b767a479d029b914392e4fd7c)

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-11-15 09:38:38 +00:00

1.0 KiB

#!/bin/bash

Copyright OpenEmbedded Contributors

SPDX-License-Identifier: MIT

Wrap llvm-config since the native llvm-config will remap some values correctly

if placed in the target sysroot but for flags, it would provide the native ones.

Provide ours from the environment instead.

NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)" if ; then exec "$NEXT_LLVM_CONFIG" fi

remain="" output="" for arg in "$@"; do case "$arg" in --cppflags) output="${output} ${CPPFLAGS}" ;; --cflags) output="${output} ${CFLAGS}" ;; --cxxflags) output="${output} ${CXXFLAGS}" ;; --ldflags) output="${output} ${LDFLAGS}" ;; --shared-mode) output="${output} shared" ;; --libs) output="${output} -lLLVM" ;; --link-shared) break ;; *) remain="${remain} ${arg}" ;; esac done

if [ "${remain}" != "" ]; then output="${output} "$("$NEXT_LLVM_CONFIG" ${remain}) fi

echo "${output}"