[all-commits] [llvm/llvm-project] dbedcf: [Driver] Add -dumpdir and change -gsplit-dwarf .dw...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Tue May 9 14:43:58 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: dbedcfdc2007e235d97b38db7693bd1f5ff443d8
https://github.com/llvm/llvm-project/commit/dbedcfdc2007e235d97b38db7693bd1f5ff443d8
Author: Fangrui Song <i at maskray.me>
Date: 2023-05-09 (Tue, 09 May 2023)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Driver/Options.td
M clang/lib/Driver/Driver.cpp
M clang/lib/Driver/ToolChains/Clang.cpp
M clang/lib/Driver/ToolChains/CommonArgs.cpp
M clang/test/Driver/hip-gsplit-dwarf-options.hip
M clang/test/Driver/split-debug.c
Log Message:
-----------
[Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking
When the final phase is linking, Clang currently places `.dwo` files in the
current directory (like the `-c` behavior for multiple inputs).
Strangely, -fdebug-compilation-dir=/-ffile-compilation-dir= is considered, which
is untested.
GCC has a more useful behavior that derives auxiliary filenames from the final
output (-o).
```
gcc -c -g -gsplit-dwarf d/a.c d/b.c # a.dwo b.dwo
gcc -g -gsplit-dwarf d/a.c d/b.c -o e/x # e/x-a.dwo e/x-b.dwo
gcc -g -gsplit-dwarf d/a.c d/b.c # a-a.dwo a-b.dwo
```
Port a useful subset of GCC behaviors that are easy to describe to Clang.
* Add a driver and cc1 option -dumpdir
* When the final phase is link, add a default -dumpdir if not specified by the user
* Forward -dumpdir to -cc1 command lines
* tools::SplitDebugName prefers -dumpdir when constructing the .dwo filename
GCC provides -dumpbase. If we use just one of -dumpdir and -dumpbase,
-dumpbase isn't very useful as it appends a dash.
```
gcc -g -gsplit-dwarf -dumpdir e d/a.c # ea.dwo
gcc -g -gsplit-dwarf -dumpdir e/ d/a.c # e/a.dwo
gcc -g -gsplit-dwarf -dumpbase e d/a.c # e-a.dwo
gcc -g -gsplit-dwarf -dumpbase e/ d/a.c # e/-a.dwo
```
If we specify both `-dumpdir` and `-dumpbase`, we can avoid the influence of the
source filename when there is one input file.
```
gcc -g -gsplit-dwarf -dumpdir f/ -dumpbase x d/a.c # f/x.dwo
gcc -g -gsplit-dwarf -dumpdir f/ -dumpbase x d/a.c d/b.c # f/x-a.dwo f/x-b.dwo
```
Given the above examples, I think -dumpbase is not useful.
GCC -save-temps has interesting interaction with -dumpdir as -save-temps
generated files are considered auxiliary files like .dwo files.
For Clang, with this patch, -save-temps and -dumpdir are orthogonal, which is
easier to explain.
```
gcc -g -gsplit-dwarf d/a.c -o e/x -dumpdir f/ -save-temps=obj # e/a.{i,s,o,dwo}
gcc -g -gsplit-dwarf d/a.c -o e/x -save-temps=obj -dumpdir f/ # f/a.{i,s,o,dwo}
clang -g -gsplit-dwarf d/a.c -o e/x -save-temps=obj -dumpdir f/ # e/a.{i,s,o} f/a.dwo
```
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D149193
More information about the All-commits
mailing list