@@ -8,16 +8,18 @@ return the libraries, include directories, etc. from inside the sysroot rather
than from the native sysroot. Thus provide an env override for calling
llvm-config from a target sysroot.
+Add YOCTO_ALTERNATE_LIBDIR and YOCTO_ALTERNATE_EXE_PATH env variables
+
Upstream-Status: Inappropriate [OE-specific]
Signed-off-by: Martin Kelly <mkelly@xevo.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
- llvm/tools/llvm-config/llvm-config.cpp | 7 +++++++
- 1 file changed, 7 insertions(+)
+ llvm/tools/llvm-config/llvm-config.cpp | 25 +++++++++++++++++++------
+ 1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
-index d5b76b1bb..6c28c34bc 100644
+index d5b76b1bb6c1..a739f0d8dbea 100644
--- a/llvm/tools/llvm-config/llvm-config.cpp
+++ b/llvm/tools/llvm-config/llvm-config.cpp
@@ -246,6 +246,13 @@ Typical components:\n\
@@ -34,3 +36,36 @@ index d5b76b1bb..6c28c34bc 100644
// This just needs to be some symbol in the binary; C++ doesn't
// allow taking the address of ::main however.
void *P = (void *)(intptr_t)GetExecutablePath;
+@@ -325,7 +332,7 @@ int main(int argc, char **argv) {
+ // Compute various directory locations based on the derived location
+ // information.
+ std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir,
+- ActiveCMakeDir;
++ ActiveCMakeDir, BaseLibDir;
+ std::string ActiveIncludeOption;
+ if (IsInDevelopmentTree) {
+ ActiveIncludeDir = std::string(LLVM_SRC_ROOT) + "/include";
+@@ -366,12 +373,18 @@ int main(int argc, char **argv) {
+ sys::fs::make_absolute(ActivePrefix, Path);
+ ActiveBinDir = std::string(Path);
+ }
+- ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
+- {
+- SmallString<256> Path(LLVM_INSTALL_PACKAGE_DIR);
+- sys::fs::make_absolute(ActivePrefix, Path);
+- ActiveCMakeDir = std::string(Path);
++ // Hack for Yocto: we need to override the lib path when we are using
++ // llvm-config from within a target sysroot since LLVM_LIBDIR_SUFFIX
++ // maybe different for host llvm vs target e.g. ppc64 Libdir=lib64 but
++ // x86_64 Libdir = lib
++ const char *YoctoLibDir = std::getenv("YOCTO_ALTERNATE_LIBDIR");
++ if (YoctoLibDir != nullptr) {
++ BaseLibDir = std::string(YoctoLibDir);
++ } else {
++ BaseLibDir = std::string("/lib") + LLVM_LIBDIR_SUFFIX;
+ }
++ ActiveLibDir = ActivePrefix + BaseLibDir;
++ ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
+ ActiveIncludeOption = "-I" + ActiveIncludeDir;
+ }
+
@@ -9,6 +9,13 @@
# Provide ours from the environment instead.
NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
+SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
+export YOCTO_ALTERNATE_EXE_PATH="${YOCTO_ALTERNATE_EXE_PATH:="$(readlink -f "$SCRIPT_DIR/../llvm-config")"}"
+if [ -n "$( echo $base_libdir | sed -n '/lib64/p')" ]; then
+ export YOCTO_ALTERNATE_LIBDIR="${YOCTO_ALTERNATE_LIBDIR:="/lib64"}"
+else
+ export YOCTO_ALTERNATE_LIBDIR="${YOCTO_ALTERNATE_LIBDIR:="/lib"}"
+fi
if [[ $# == 0 ]]; then
exec "$NEXT_LLVM_CONFIG"
fi
Cross-building of mesa requires us to be able to provide target-specific value for --libdir. Update the cross-environment llvm-config patch from meta-clang in order to allow overriding the --libdir output. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> --- ...-llvm-allow-env-override-of-exe-path.patch | 41 +++++++++++++++++-- meta/recipes-devtools/llvm/llvm/llvm-config | 7 ++++ 2 files changed, 45 insertions(+), 3 deletions(-)