tra created this revision.
tra added reviewers: sfantao, yaxunl, sdmitriev.
Herald added a subscriber: bixia.
Herald added a project: clang.
tra requested review of this revision.

The path produced by `getMainExecutable()` may not be the right one when the 
files are installed in
a symlinked tree and when the real location of `llvm-objdump` is in a different 
directory.

Given that clang-offload-bundler is invoked by clang, the driver already does 
the job figuring out 
the right path (e.g. it pays attention to `-no-canonical-prefixes`). 
Offload bundler should use it, instead of trying to figure out the path on its 
own.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90436

Files:
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===================================================================
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ 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));


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===================================================================
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ 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));
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to