[PATCH] D80391: [Driver] Don't make -gsplit-dwarf imply -g2
David Blaikie via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 13 13:16:55 PST 2021
dblaikie added inline comments.
================
Comment at: clang/docs/ReleaseNotes.rst:120
`nonnull` attribute on `this` for configurations that need it to be nullable.
+- ``-gsplit-dwarf`` no longer implies ``-g2``.
----------------
MaskRay wrote:
> dblaikie wrote:
> > thakis wrote:
> > > This apparently bit us (chromium) in thinlto configs. Could this here be more explicit that `-gsplit-dwarf` now needs an explicit `-g2` in cflags, and if using thinlto, in ldflags as well?
> > Arguably I think maybe it should be fixed/made to work for (thin)lto with -g2 in cflags and -gsplit-dwarf in ldflags, without the need to specify -g2 in ldflags (if that's what you're saying is currently required). Since the -gN level would hopefully at best be ignored (because the IR carries the N in -gN with it, and it'd be unfortunate it enabling split dwarf meant you had to ignore all your per-file -gN levels, or that the -gN is ignored except for allowing -gsplit-dwarf to be respected).
> >
> > @MaskRay ?
> LLD LTO does not have debug related options. `ld -g` is an ignored compatibility option. LLD somewhat inherited that from GNU ld. I don't think `-gsplit-dwarf` or `-g` can be separately controlled in ldflags.
>
> @thakis Can you share the crbug.com discussion thread?
Hmm, I guess the thing that bit Chromium would've been the need to add -g2 to cflags where previously it might've been just -gsplit-dwarf for cflags and ldflags.
But it doesn't look like -g2 is needed in ldflags, only passing it to the compilation seems sufficient, then the -gsplit-dwarf passed to the link step is respected:
```
$ clang++-tot -flto=thin test.cpp -g -c && clang++-tot -flto=thin -fuse-ld=lld -gsplit-dwarf test.o && llvm-dwarfdump-tot a.out
a.out: file format elf64-x86-64
.debug_info contents:
0x00000000: Compile Unit: length = 0x0000002c, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000030)
0x0000000b: DW_TAG_compile_unit
DW_AT_stmt_list (0x00000000)
DW_AT_comp_dir ("/usr/local/google/home/blaikie/dev/scratch")
DW_AT_GNU_dwo_name ("a.out_dwo/1.dwo")
DW_AT_GNU_dwo_id (0xf29563d7c812deae)
DW_AT_low_pc (0x0000000000201730)
DW_AT_high_pc (0x0000000000201738)
DW_AT_GNU_addr_base (0x00000000)
$ clang++-tot -flto=thin test.cpp -g -c && clang++-tot -flto=thin -fuse-ld=lld test.o && llvm-dwarfdump-tot a.out
a.out: file format elf64-x86-64
.debug_info contents:
0x00000000: Compile Unit: length = 0x00000047, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0000004b)
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("clang version 12.0.0 (git at github.com:llvm/llvm-project.git 0d88d7d82bc44b211a8187650a06c6cd3492186a)")
DW_AT_language (DW_LANG_C_plus_plus_14)
DW_AT_name ("test.cpp")
DW_AT_stmt_list (0x00000000)
DW_AT_comp_dir ("/usr/local/google/home/blaikie/dev/scratch")
DW_AT_low_pc (0x0000000000201730)
DW_AT_high_pc (0x0000000000201738)
0x0000002a: DW_TAG_subprogram
DW_AT_low_pc (0x0000000000201730)
DW_AT_high_pc (0x0000000000201738)
DW_AT_frame_base (DW_OP_reg6 RBP)
DW_AT_name ("main")
DW_AT_decl_file ("/usr/local/google/home/blaikie/dev/scratch/test.cpp")
DW_AT_decl_line (3)
DW_AT_type (0x00000043 "int")
DW_AT_external (true)
0x00000043: DW_TAG_base_type
DW_AT_name ("int")
DW_AT_encoding (DW_ATE_signed)
DW_AT_byte_size (0x04)
0x0000004a: NULL
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80391/new/
https://reviews.llvm.org/D80391
More information about the cfe-commits
mailing list