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

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From fbfaab8d1dfa23aff4e4adb0e92dd4ff6467e453 Mon Sep 17 00:00:00 2001
  2. From: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  3. Date: Tue, 9 Nov 2021 10:05:00 +0800
  4. Subject: [PATCH 05/34] llvm: allow env override of exe 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. Rebased to LLVM 14.0.0 by Jun Yuan Tan
  10. Signed-off-by: Martin Kelly <mkelly@xevo.com>
  11. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  12. Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  13. ---
  14. llvm/tools/llvm-config/llvm-config.cpp | 7 +++++++
  15. 1 file changed, 7 insertions(+)
  16. diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
  17. index 1a2f04552d13..019d8f2b5c5e 100644
  18. --- a/llvm/tools/llvm-config/llvm-config.cpp
  19. +++ b/llvm/tools/llvm-config/llvm-config.cpp
  20. @@ -247,6 +247,13 @@ Typical components:\n\
  21. /// Compute the path to the main executable.
  22. std::string GetExecutablePath(const char *Argv0) {
  23. + // Hack for Yocto: we need to override the root path when we are using
  24. + // llvm-config from within a target sysroot.
  25. + const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
  26. + if (Sysroot != nullptr) {
  27. + return Sysroot;
  28. + }
  29. +
  30. // This just needs to be some symbol in the binary; C++ doesn't
  31. // allow taking the address of ::main however.
  32. void *P = (void *)(intptr_t)GetExecutablePath;
  33. --
  34. 2.33.1