[OpenMP] Add search path for llvm-strip

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

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D118965
This commit is contained in:
Kelvin Li 2022-02-04 22:15:14 -05:00
parent 0b7669f333
commit 8ea4aed50a
1 changed files with 7 additions and 1 deletions

View File

@ -310,7 +310,13 @@ extractFromBinary(const ObjectFile &Obj,
// 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");