[PATCH] D149193: [Driver] -gsplit-dwarf: derive .dwo names from -o for link actions

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 25 14:14:35 PDT 2023


MaskRay created this revision.
MaskRay added reviewers: dblaikie, phosek, yaxunl.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When the final phase is linking, Clang currently
places auxiliary files in the CWD, ignoring `-o`.
(the `-c` behavior for multiple inputs).
Strangely, -fdebug-compilation-dir=/-ffile-compilation-dir= is considered, which
is untested.

GCC has a (IMHO) more reasonable 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
  # -fdebug-compilation-dir= doesn't affect the .dwo filename.

Port the GCC behavior to Clang.

- When the final phase is link, add -dumpdir
- Forward -dumpdir to -cc1 command lines
- tools::SplitDebugName prefers -dumpdir

-dumpdir is a -cc1 only option for now. We consider making it a driver option when
more options generating auxiliary files has a sensible behavior when the final
phase is linking.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149193

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-gsplit-dwarf-options.hip
  clang/test/Driver/split-debug.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149193.516905.patch
Type: text/x-patch
Size: 6299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230425/5cf622b2/attachment-0001.bin>


More information about the cfe-commits mailing list