1*4882a593SmuzhiyunFrom 7111770e8290082530d920e120995bf81431b0aa Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Martin Kelly <mkelly@xevo.com> 3*4882a593SmuzhiyunDate: Fri, 19 May 2017 00:22:57 -0700 4*4882a593SmuzhiyunSubject: [PATCH 12/18] llvm: allow env override of exe path 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunWhen using a native llvm-config from inside a sysroot, we need llvm-config to 7*4882a593Smuzhiyunreturn the libraries, include directories, etc. from inside the sysroot rather 8*4882a593Smuzhiyunthan from the native sysroot. Thus provide an env override for calling 9*4882a593Smuzhiyunllvm-config from a target sysroot. 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunUpstream-Status: Inappropriate [oe-core specific] 12*4882a593SmuzhiyunSigned-off-by: Martin Kelly <mkelly@xevo.com> 13*4882a593SmuzhiyunSigned-off-by: Khem Raj <raj.khem@gmail.com> 14*4882a593Smuzhiyun--- 15*4882a593Smuzhiyun llvm/tools/llvm-config/llvm-config.cpp | 7 +++++++ 16*4882a593Smuzhiyun 1 file changed, 7 insertions(+) 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun--- a/llvm/tools/llvm-config/llvm-config.cpp 19*4882a593Smuzhiyun+++ b/llvm/tools/llvm-config/llvm-config.cpp 20*4882a593Smuzhiyun@@ -226,6 +226,13 @@ Typical components:\n\ 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun /// Compute the path to the main executable. 23*4882a593Smuzhiyun std::string GetExecutablePath(const char *Argv0) { 24*4882a593Smuzhiyun+ // Hack for Yocto: we need to override the root path when we are using 25*4882a593Smuzhiyun+ // llvm-config from within a target sysroot. 26*4882a593Smuzhiyun+ const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH"); 27*4882a593Smuzhiyun+ if (Sysroot != nullptr) { 28*4882a593Smuzhiyun+ return Sysroot; 29*4882a593Smuzhiyun+ } 30*4882a593Smuzhiyun+ 31*4882a593Smuzhiyun // This just needs to be some symbol in the binary; C++ doesn't 32*4882a593Smuzhiyun // allow taking the address of ::main however. 33*4882a593Smuzhiyun void *P = (void *)(intptr_t)GetExecutablePath; 34