0007-llvm-allow-env-override-of-exe-path.patch 1.5 KB

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