Skip to content

Conversation

@llvmbot
Copy link
Member

@llvmbot llvmbot commented Feb 12, 2025

Backport 0abe058

Requested by: @nikic

@llvmbot
Copy link
Member Author

llvmbot commented Feb 12, 2025

@dcci What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented Feb 12, 2025

@llvm/pr-subscribers-bolt

Author: None (llvmbot)

Changes

Backport 0abe058

Requested by: @nikic


Full diff: https://github.com/llvm/llvm-project/pull/126881.diff

1 Files Affected:

  • (modified) bolt/tools/driver/llvm-bolt.cpp (+1-11)
diff --git a/bolt/tools/driver/llvm-bolt.cpp b/bolt/tools/driver/llvm-bolt.cpp
index efa06cd68cb99..f151cf5f63fc5 100644
--- a/bolt/tools/driver/llvm-bolt.cpp
+++ b/bolt/tools/driver/llvm-bolt.cpp
@@ -173,16 +173,6 @@ void boltMode(int argc, char **argv) {
   }
 }
 
-static std::string GetExecutablePath(const char *Argv0) {
-  SmallString<256> ExecutablePath(Argv0);
-  // Do a PATH lookup if Argv0 isn't a valid path.
-  if (!llvm::sys::fs::exists(ExecutablePath))
-    if (llvm::ErrorOr<std::string> P =
-            llvm::sys::findProgramByName(ExecutablePath))
-      ExecutablePath = *P;
-  return std::string(ExecutablePath);
-}
-
 int main(int argc, char **argv) {
   // Print a stack trace if we signal out.
   sys::PrintStackTraceOnErrorSignal(argv[0]);
@@ -190,7 +180,7 @@ int main(int argc, char **argv) {
 
   llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
 
-  std::string ToolPath = GetExecutablePath(argv[0]);
+  std::string ToolPath = llvm::sys::fs::getMainExecutable(argv[0], nullptr);
 
   // Initialize targets and assembly printers/parsers.
   llvm::InitializeAllTargetInfos();

@dcci
Copy link
Member

dcci commented Feb 12, 2025

OK with merging this.

Use LLVM's getMainExecutable() helper instead of rolling our own. This
will result in standard behavior across platforms, such as making sure
that symlinks are always resolved.

(cherry picked from commit 0abe058)
@tstellar tstellar merged commit c99d611 into llvm:release/20.x Feb 13, 2025
6 of 9 checks passed
@github-actions
Copy link

@nikic (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

4 participants