diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp --- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -1025,7 +1025,9 @@ // Save the current executable directory as it will be useful to find other // tools. - BundlerExecutable = sys::fs::getMainExecutable(argv[0], &BundlerExecutable); + BundlerExecutable = argv[0]; + if (!llvm::sys::fs::exists(BundlerExecutable)) + BundlerExecutable = sys::fs::getMainExecutable(argv[0], &BundlerExecutable); if (llvm::Error Err = Unbundle ? UnbundleFiles() : BundleFiles()) { reportError(std::move(Err));