[clang] [Driver] Honor /Fo when deriving the split-dwarf .dwo path (PR #199613)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 25 23:36:41 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Haohai Wen (HaohaiWen)
<details>
<summary>Changes</summary>
SplitDebugName checked -o and /o but not /Fo, so clang-cl /Fo<path> /c
fell through to the cwd-relative fallback and every .dwo landed in cwd
under <source-stem>.dwo regardless of the .obj location.
---
Full diff: https://github.com/llvm/llvm-project/pull/199613.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+2-1)
- (modified) clang/test/Driver/split-debug.c (+6)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6a0dcfca62c60..f59b50f4f45ca 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1882,7 +1882,8 @@ const char *tools::SplitDebugName(const JobAction &JA, const ArgList &Args,
if (const Arg *A = Args.getLastArg(options::OPT_dumpdir)) {
T = A->getValue();
} else {
- Arg *FinalOutput = Args.getLastArg(options::OPT_o, options::OPT__SLASH_o);
+ Arg *FinalOutput = Args.getLastArg(options::OPT_o, options::OPT__SLASH_o,
+ options::OPT__SLASH_Fo);
if (FinalOutput && Args.hasArg(options::OPT_c)) {
T = FinalOutput->getValue();
llvm::sys::path::remove_filename(T);
diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index 57f3989ed7b51..eaccc2784c50f 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -57,6 +57,12 @@
// SINGLE_WITH_FILENAME: "-split-dwarf-file" "{{.*}}foo.o"
// SINGLE_WITH_FILENAME-NOT: "-split-dwarf-output"
+/// /Fo drives the .dwo path so it lands next to the .obj.
+// RUN: %clang_cl -### -c --target=x86_64-unknown-windows-msvc -gdwarf -gsplit-dwarf /Foobj/out.obj -- %s 2>&1 | FileCheck %s --check-prefix=SPLIT_SLASH_FO
+// RUN: %clang_cl -### -c --target=x86_64-unknown-windows-msvc -gdwarf -gsplit-dwarf /Fo:obj/out.obj -- %s 2>&1 | FileCheck %s --check-prefix=SPLIT_SLASH_FO
+
+// SPLIT_SLASH_FO: "-split-dwarf-file" "obj{{[/\\]}}out.dwo" "-split-dwarf-output" "obj{{[/\\]}}out.dwo"
+
/// If linking is the final phase, the .dwo filename is derived from -o (if specified) or "a".
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o obj/out 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK
// RUN: %clang_cl -### --target=x86_64-unknown-windows-msvc -gsplit-dwarf -g -o obj/out -- %s 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK
``````````
</details>
https://github.com/llvm/llvm-project/pull/199613
More information about the cfe-commits
mailing list