[llvm] 4531f53 - [llvm-dwp] Get the DWO file from relative path if the absolute path is not valid
Zhang Qing Shan via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 12 22:46:16 PDT 2022
Author: Zhang Qing Shan
Date: 2022-09-13T13:45:51+08:00
New Revision: 4531f5385125dd6448004a16cd80a94484ca68b7
URL: https://github.com/llvm/llvm-project/commit/4531f5385125dd6448004a16cd80a94484ca68b7
DIFF: https://github.com/llvm/llvm-project/commit/4531f5385125dd6448004a16cd80a94484ca68b7.diff
LOG: [llvm-dwp] Get the DWO file from relative path if the absolute path is not valid
Extend the llvm-dwp to support searching the DWOs that from relative path for the
case that build from remote building system(different comp_dir).
Reviewd By: dblaikie
Differential Revision: https://reviews.llvm.org/D133480
Added:
llvm/test/tools/llvm-dwp/Inputs/search_dwos/a.dwo
llvm/test/tools/llvm-dwp/Inputs/search_dwos/b.dwo
llvm/test/tools/llvm-dwp/Inputs/search_dwos/main
llvm/test/tools/llvm-dwp/X86/search_dwos.test
Modified:
llvm/tools/llvm-dwp/llvm-dwp.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-dwp/Inputs/search_dwos/a.dwo b/llvm/test/tools/llvm-dwp/Inputs/search_dwos/a.dwo
new file mode 100644
index 0000000000000..56c6f413691b1
Binary files /dev/null and b/llvm/test/tools/llvm-dwp/Inputs/search_dwos/a.dwo
diff er
diff --git a/llvm/test/tools/llvm-dwp/Inputs/search_dwos/b.dwo b/llvm/test/tools/llvm-dwp/Inputs/search_dwos/b.dwo
new file mode 100644
index 0000000000000..c72acbdcfb41a
Binary files /dev/null and b/llvm/test/tools/llvm-dwp/Inputs/search_dwos/b.dwo
diff er
diff --git a/llvm/test/tools/llvm-dwp/Inputs/search_dwos/main b/llvm/test/tools/llvm-dwp/Inputs/search_dwos/main
new file mode 100755
index 0000000000000..f39d615bc24b1
Binary files /dev/null and b/llvm/test/tools/llvm-dwp/Inputs/search_dwos/main
diff er
diff --git a/llvm/test/tools/llvm-dwp/X86/search_dwos.test b/llvm/test/tools/llvm-dwp/X86/search_dwos.test
new file mode 100644
index 0000000000000..bf45bba60481e
--- /dev/null
+++ b/llvm/test/tools/llvm-dwp/X86/search_dwos.test
@@ -0,0 +1,22 @@
+RUN: rm -rf %t
+RUN: mkdir %t
+RUN: cd %t
+RUN: cp %p/../Inputs/search_dwos/a.dwo a.dwo
+RUN: cp %p/../Inputs/search_dwos/b.dwo b.dwo
+RUN: cp %p/../Inputs/search_dwos/main main
+RUN: llvm-dwp -e main -o %t.dwp
+
+Search the DWO from relative path if absolute path is not valid.
+Build commands for the test binaries:
+
+clang++ -Xclang -fdebug-compilation-dir -Xclang "path-not-exists" -g -O0 -gsplit-dwarf a.cpp b.cpp -o main
+
+sources:
+a.cpp:
+ void a() {}
+
+b.cpp:
+ void b() {}
+ int main() {
+ return 0;
+ }
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index 7d1dd61dc0597..f9d1dc4b27495 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -71,7 +71,10 @@ getDWOFilenames(StringRef ExecFilename) {
if (!DWOCompDir.empty()) {
SmallString<16> DWOPath(std::move(DWOName));
sys::fs::make_absolute(DWOCompDir, DWOPath);
- DWOPaths.emplace_back(DWOPath.data(), DWOPath.size());
+ if (!sys::fs::exists(DWOPath) && sys::fs::exists(DWOName))
+ DWOPaths.push_back(std::move(DWOName));
+ else
+ DWOPaths.emplace_back(DWOPath.data(), DWOPath.size());
} else {
DWOPaths.push_back(std::move(DWOName));
}
More information about the llvm-commits
mailing list