Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From aeccf16eaccdd80e4d5ecaa51673ce4b2bac1130 Mon Sep 17 00:00:00 2001 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2 | From: Martin Kelly <mkelly@xevo.com> |
| 3 | Date: Fri, 19 May 2017 00:22:57 -0700 |
| 4 | Subject: [PATCH 2/2] llvm: allow env override of exe path |
| 5 | |
| 6 | When using a native llvm-config from inside a sysroot, we need llvm-config to |
| 7 | return the libraries, include directories, etc. from inside the sysroot rather |
| 8 | than from the native sysroot. Thus provide an env override for calling |
| 9 | llvm-config from a target sysroot. |
| 10 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 11 | To let it work in multilib environment, we need to provide a knob to supply |
| 12 | multilib dirname as well |
| 13 | |
| 14 | Upstream-Status: Inappropriate [OE-Specific] |
| 15 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | Signed-off-by: Martin Kelly <mkelly@xevo.com> |
| 17 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 18 | --- |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 19 | tools/llvm-config/llvm-config.cpp | 17 ++++++++++++++++- |
| 20 | 1 file changed, 16 insertions(+), 1 deletion(-) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 21 | |
| 22 | diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 23 | index 08b096afb05..360cc5abf4e 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 24 | --- a/tools/llvm-config/llvm-config.cpp |
| 25 | +++ b/tools/llvm-config/llvm-config.cpp |
| 26 | @@ -225,6 +225,13 @@ Typical components:\n\ |
| 27 | |
| 28 | /// \brief Compute the path to the main executable. |
| 29 | std::string GetExecutablePath(const char *Argv0) { |
| 30 | + // Hack for Yocto: we need to override the root path when we are using |
| 31 | + // llvm-config from within a target sysroot. |
| 32 | + const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH"); |
| 33 | + if (Sysroot != nullptr) { |
| 34 | + return Sysroot; |
| 35 | + } |
| 36 | + |
| 37 | // This just needs to be some symbol in the binary; C++ doesn't |
| 38 | // allow taking the address of ::main however. |
| 39 | void *P = (void *)(intptr_t)GetExecutablePath; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 40 | @@ -306,12 +313,20 @@ int main(int argc, char **argv) { |
| 41 | std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir, |
| 42 | ActiveCMakeDir; |
| 43 | std::string ActiveIncludeOption; |
| 44 | + // Hack for Yocto: we need to override the multilib path when we are using |
| 45 | + // llvm-config from within a target sysroot. |
| 46 | + std::string Multilibdir = std::getenv("YOCTO_ALTERNATE_MULTILIB_NAME"); |
| 47 | + if (Multilibdir.empty()) { |
| 48 | + Multilibdir = "/lib" LLVM_LIBDIR_SUFFIX; |
| 49 | + } |
| 50 | + |
| 51 | if (IsInDevelopmentTree) { |
| 52 | ActiveIncludeDir = std::string(LLVM_SRC_ROOT) + "/include"; |
| 53 | ActivePrefix = CurrentExecPrefix; |
| 54 | |
| 55 | // CMake organizes the products differently than a normal prefix style |
| 56 | // layout. |
| 57 | + |
| 58 | switch (DevelopmentTreeLayout) { |
| 59 | case CMakeStyle: |
| 60 | ActiveBinDir = ActiveObjRoot + "/bin"; |
| 61 | @@ -336,7 +351,7 @@ int main(int argc, char **argv) { |
| 62 | SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR)); |
| 63 | sys::fs::make_absolute(ActivePrefix, path); |
| 64 | ActiveBinDir = path.str(); |
| 65 | - ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX; |
| 66 | + ActiveLibDir = ActivePrefix + Multilibdir; |
| 67 | ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; |
| 68 | ActiveIncludeOption = "-I" + ActiveIncludeDir; |
| 69 | } |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 70 | -- |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 71 | 2.18.0 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 72 | |