Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame^] | 1 | Upstream-Status: Pending |
| 2 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 3 | |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 4 | From 61b00e1e051e367f5483d7b5253b6c85a9e8a90f Mon Sep 17 00:00:00 2001 |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 5 | From: Martin Kelly <mkelly@xevo.com> |
| 6 | Date: Fri, 19 May 2017 00:22:57 -0700 |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 7 | Subject: [PATCH] llvm: allow env override of exe path |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 8 | |
| 9 | When using a native llvm-config from inside a sysroot, we need llvm-config to |
| 10 | return the libraries, include directories, etc. from inside the sysroot rather |
| 11 | than from the native sysroot. Thus provide an env override for calling |
| 12 | llvm-config from a target sysroot. |
| 13 | |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 14 | Signed-off-by: Martin Kelly <mkelly@xevo.com> |
| 15 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 16 | --- |
| 17 | llvm/tools/llvm-config/llvm-config.cpp | 7 +++++++ |
| 18 | 1 file changed, 7 insertions(+) |
| 19 | |
| 20 | diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp |
| 21 | index 7ef7c46a262..a4f7ed82c7b 100644 |
| 22 | --- a/llvm/tools/llvm-config/llvm-config.cpp |
| 23 | +++ b/llvm/tools/llvm-config/llvm-config.cpp |
| 24 | @@ -225,6 +225,13 @@ Typical components:\n\ |
| 25 | |
| 26 | /// Compute the path to the main executable. |
| 27 | std::string GetExecutablePath(const char *Argv0) { |
| 28 | + // Hack for Yocto: we need to override the root path when we are using |
| 29 | + // llvm-config from within a target sysroot. |
| 30 | + const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH"); |
| 31 | + if (Sysroot != nullptr) { |
| 32 | + return Sysroot; |
| 33 | + } |
| 34 | + |
| 35 | // This just needs to be some symbol in the binary; C++ doesn't |
| 36 | // allow taking the address of ::main however. |
| 37 | void *P = (void *)(intptr_t)GetExecutablePath; |