diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -310,7 +310,13 @@ // We will use llvm-strip to remove the now unneeded section containing the // offloading code. - ErrorOr 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 StripPath = + sys::findProgramByName("llvm-strip", {COWDir}); if (!StripPath) return createStringError(StripPath.getError(), "Unable to find 'llvm-strip' in path");