[PATCH] D118965: [OpenMP] Add search path for llvm-strip

Kelvin Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 3 20:59:26 PST 2022


kkwli0 created this revision.
kkwli0 added reviewers: jhuber6, jdoerfert.
Herald added subscribers: guansong, yaxunl.
kkwli0 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Add the search path for llvm-strip instead of solely relying on the PATH environment variable setting.

Currently, `make check-openmp` has a few failures with the error:

  /build-llvm/./bin/clang-linker-wrapper: error: Unable to find 'llvm-strip' in path


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118965

Files:
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===================================================================
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -303,7 +303,13 @@
 
   // We will use llvm-strip to remove the now unneeded section containing the
   // offloading code.
-  ErrorOr<std::string> StripPath = sys::findProgramByName("llvm-strip");
+  void *P = (void *)(intptr_t)&Help;
+  StringRef COWDir = "";
+  auto COWPath = sys::fs::getMainExecutable("llvm-strip", P);
+  if (!COWPath.empty())
+    COWDir = sys::path::parent_path(COWPath);
+  ErrorOr<std::string> StripPath =
+      sys::findProgramByName("llvm-strip", {COWDir});
   if (!StripPath)
     return createStringError(StripPath.getError(),
                              "Unable to find 'llvm-strip' in path");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118965.405865.patch
Type: text/x-patch
Size: 881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220204/d1e1c555/attachment.bin>


More information about the cfe-commits mailing list