clang not emitting debug information with gsplit-dwarf option without -g option
clang needs -g option to emit debug information along with -gsplit-dwarf option. If -gsplit-dwarf option is specified without -g option, no debug info is emitted and .dwo file is not created. Like other -g options, such as, -gdwarf-*, -gsplit-dwarf also should be enabling debug information. gcc compiler emits debug information with just -gsplit-dwarf option and does not require explicit -g option.
$ clang -gsplit-dwarf=split sample.c // No debug info and no sample.dwo file generaged $ clang -gsplit-dwarf=split -g sample.c // sample.dwo file generated $ gcc -gsplit-dwarf sample.c // sample.dwo file generated
I tested with clang-14 & clang-15. It is not the case with older clang.
@llvm/issue-subscribers-clang-driver
Yeah, this was an intentional change in behavior - it's changed in GCC too, in sufficiently recent versions, as I understand it.
(some context for the intent of the change: Some other -g flags don't enable debug info emission (eg: -gpubnames) and only modify the output if debug info emission is otherwise enabled - it's somewhat recognized that orthogonal flags do make things easier (eg: if you have a build that includes debug info for some parts of the build and not others, but you want to turn on some debug info feature (eg: migrate to a newer version of DWARF, switch to Split DWARF, etc) - but without turning on debug info for every target, but only changing what's emitted where it's already otherwise requested) so that's hopefully the direction we'll go in in the future, -g prefixed flags that don't imply/enable emission by themselves, so they can be composed)