[llvm] [BOLT] Get DWO file via a relative path if the CompilationDir does not exist (PR #154515)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 20 04:16:52 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: Jinjie Huang (Jinjie-Huang)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/154515.diff
2 Files Affected:
- (modified) bolt/lib/Core/BinaryContext.cpp (+6)
- (modified) bolt/lib/Rewrite/DWARFRewriter.cpp (+2)
``````````diff
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index 84f1853469709..6a56c8aa7cfa5 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -33,6 +33,7 @@
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Regex.h"
#include <algorithm>
#include <functional>
@@ -1640,6 +1641,11 @@ void BinaryContext::preprocessDWODebugInfo() {
if (!opts::CompDirOverride.empty()) {
sys::path::append(AbsolutePath, opts::CompDirOverride);
sys::path::append(AbsolutePath, DWOName);
+ } else {
+ std::string CompDir = DwarfUnit->getCompilationDir();
+ sys::path::append(AbsolutePath, CompDir);
+ if (!sys::fs::exists(AbsolutePath) && sys::fs::exists(DWOName))
+ AbsolutePath = DWOName;
}
DWARFUnit *DWOCU =
DwarfUnit->getNonSkeletonUnitDIE(false, AbsolutePath).getDwarfUnit();
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 0c1a1bac6c72e..80b24a5561e81 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -1851,6 +1851,8 @@ void DWARFRewriter::writeDWOFiles(
CompDir = opts::DwarfOutputPath.c_str();
else if (!opts::CompDirOverride.empty())
CompDir = opts::CompDirOverride;
+ else if (!sys::fs::exists(CompDir))
+ CompDir = ".";
SmallString<16> AbsolutePath;
sys::path::append(AbsolutePath, CompDir);
``````````
</details>
https://github.com/llvm/llvm-project/pull/154515
More information about the llvm-commits
mailing list