[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 16:17:31 PDT 2023


MaskRay added a comment.

In D149193#4297043 <https://reviews.llvm.org/D149193#4297043>, @scott.linder wrote:

> I'm a bit confused after trying to work out the rules for the GCC version of `-dumpdir` over at https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-dumpdir but it at least seems like our version is a subset of theirs.

Yes, it's quite complex.... I think we'll just port the reasonable subset of rules (like `clang -g -gsplit-dwarf a.c b.c -o out`, but not the more complex ones)...

It seems that `-dumpdir` is the most useful option. `-dumpbase` appends a `-`, which can be undesired, if we intend to expose an option to place auxiliary files.

  gcc -g -gsplit-dwarf -dumpdir f a.c => fa.dwo
  gcc -g -gsplit-dwarf -dumpdir f/ a.c => f/a.dwo
  gcc -g -gsplit-dwarf -dumpbase f a.c => f-a.dwo
  gcc -g -gsplit-dwarf -dumpbase f/ a.c => f/-a.dwo

What's more complex is that `-dumpdir` and `-dumpbase` can be used together. I have played a bit and haven't thought of a case that the combination is useful.

> Do we support any of the other `-dump*` options GCC does? E.g. https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-dumpbase and https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-dumpbase-ext ? I don't think we need to in order to add and use `-dumpdir`, but they do have a somewhat unique inter-dependence in that the exact value of one can cause another to be completely ignored.

We don't. Having just `-dumpdir` perhaps will be useful enough when we make `-save-temps` inter-operate with `-dumpdir` (control `*.i`, `*.s`, `*.bc`, etc)

> Also, would it be worth adding tests for the following cases:
>
>> It defaults to the location of the output file, unless the output file is a special file like /dev/null. Options -save-temps=cwd and -save-temps=obj override this default, just like an explicit -dumpdir option. In case multiple such options are given, the last one prevails:

GCC special cases `/dev/null`, but it doesn't treat other special files differently.

  gcc -g -gsplit-dwarf a.c -o /dev/null  # a.dwo
  gcc -g -gsplit-dwarf a.c -o /dev/zero  # /dev/zero-a.dwo (likely fail to create)
  gcc -g -gsplit-dwarf a.c -o /dev/zero -save-temp=obj  # /dev/null-a.i (likely fail to create)

I suggest that we don't have the special rule.

  clang -g -gsplit-dwarf a.c -o /dev/null  # /dev/null-a.dwo (likely fail to create)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149193/new/

https://reviews.llvm.org/D149193



More information about the cfe-commits mailing list