Skip to content

Commit e5b40f6

Browse files
committed
Backport bolt fix (rhbz#2344830)
Backport llvm/llvm-project#126698 to fix https://bugzilla.redhat.com/show_bug.cgi?id=2344830.
1 parent 6f41874 commit e5b40f6

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 0abe058d7f99c9c7bbaf4ee98308c5e78d229897 Mon Sep 17 00:00:00 2001
2+
From: Nikita Popov <[email protected]>
3+
Date: Wed, 12 Feb 2025 09:44:26 +0100
4+
Subject: [PATCH] [BOLT] Use getMainExecutable() (#126698)
5+
6+
Use LLVM's getMainExecutable() helper instead of rolling our own. This
7+
will result in standard behavior across platforms, such as making sure
8+
that symlinks are always resolved.
9+
---
10+
bolt/tools/driver/llvm-bolt.cpp | 12 +-----------
11+
1 file changed, 1 insertion(+), 11 deletions(-)
12+
13+
diff --git a/bolt/tools/driver/llvm-bolt.cpp b/bolt/tools/driver/llvm-bolt.cpp
14+
index efa06cd68cb9..f151cf5f63fc 100644
15+
--- a/bolt/tools/driver/llvm-bolt.cpp
16+
+++ b/bolt/tools/driver/llvm-bolt.cpp
17+
@@ -173,16 +173,6 @@ void boltMode(int argc, char **argv) {
18+
}
19+
}
20+
21+
-static std::string GetExecutablePath(const char *Argv0) {
22+
- SmallString<256> ExecutablePath(Argv0);
23+
- // Do a PATH lookup if Argv0 isn't a valid path.
24+
- if (!llvm::sys::fs::exists(ExecutablePath))
25+
- if (llvm::ErrorOr<std::string> P =
26+
- llvm::sys::findProgramByName(ExecutablePath))
27+
- ExecutablePath = *P;
28+
- return std::string(ExecutablePath);
29+
-}
30+
-
31+
int main(int argc, char **argv) {
32+
// Print a stack trace if we signal out.
33+
sys::PrintStackTraceOnErrorSignal(argv[0]);
34+
@@ -190,7 +180,7 @@ int main(int argc, char **argv) {
35+
36+
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
37+
38+
- std::string ToolPath = GetExecutablePath(argv[0]);
39+
+ std::string ToolPath = llvm::sys::fs::getMainExecutable(argv[0], nullptr);
40+
41+
// Initialize targets and assembly printers/parsers.
42+
llvm::InitializeAllTargetInfos();
43+
--
44+
2.48.1
45+

llvm.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
#region main package
227227
Name: %{pkg_name_llvm}
228228
Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}}
229-
Release: 7%{?dist}
229+
Release: 8%{?dist}
230230
Summary: The Low Level Virtual Machine
231231

232232
License: Apache-2.0 WITH LLVM-exception OR NCSA
@@ -315,6 +315,7 @@ Patch1908: cstdint.patch
315315

316316
#region BOLT patches
317317
Patch1909: 0001-19-PATCH-Bolt-CMake-Don-t-export-bolt-libraries-in-LLVM.patch
318+
Patch1913: 0001-BOLT-Use-getMainExecutable-126698.patch
318319
#endregion BOLT patches
319320

320321
#region polly patches
@@ -3061,8 +3062,11 @@ fi
30613062

30623063
#region changelog
30633064
%changelog
3065+
* Wed Feb 12 2025 Nikita Popov <[email protected]> - 19.1.7-8
3066+
- Backport bolt fix (rhbz#2344830)
3067+
30643068
* Wed Feb 12 2025 Nikita Popov <[email protected]> - 19.1.7-7
3065-
- Introduce llvm-resource-directory
3069+
- Introduce llvm-resource-filesystem
30663070

30673071
* Tue Feb 04 2025 Nikita Popov <[email protected]> - 19.1.7-6
30683072
- Don't use directory symlinks

0 commit comments

Comments
 (0)