Skip to content

Commit 86f2ec0

Browse files
authored
[llvm][DWARFLinker] Don't attach DW_AT_dwo_id to CUs (#105186)
This fixes a verifier error uncovered as a result of #101775. When compiling with `-gmodules`, Clang will create a skeleton CU that contains a `DW_AT_dwo_id` and a `DW_AT_dwo_name` corresponding to the path of the `.pcm` that carries the type definitions referenced in the non-skeleton CU (see the [gmodules LLDB docs](https://lldb.llvm.org/resources/extensions.html) for more details). The non-skeleton CU will also contain a `DW_AT_dwo_id` that matches that of the skeleton. `dsymutil` effectively undoes the `-gmodules` work, replacing all the module type references with definitions. I.e., we no longer create a skeleton `.dwo` CU. Prior to this patch `dsymutil` did not strip out the `DW_AT_dwo_id` on the non-skeleton CU. This now (since #101775) causes verification errors such as: ``` Verifying .debug_names... error: Name Index @ 0x0: Entry @ 0x9a unable to load .dwo file "None" for DWARF unit @ 0x0. error: output verification failed for x86_64 make: *** [a.out.dSYM] Error 1 ``` ...because the verifier sees the DWO ID but can't find a matching `.dwo` unit. This patch simply strips the `DW_AT_dwo_id` from the main CU.
1 parent 6f45602 commit 86f2ec0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,12 @@ unsigned DWARFLinker::DIECloner::cloneScalarAttribute(
14121412
unsigned AttrSize, AttributesInfo &Info) {
14131413
uint64_t Value;
14141414

1415+
// We don't emit any skeleton CUs with dsymutil. So avoid emitting
1416+
// a redundant DW_AT_GNU_dwo_id on the non-skeleton CU.
1417+
if (AttrSpec.Attr == dwarf::DW_AT_GNU_dwo_id ||
1418+
AttrSpec.Attr == dwarf::DW_AT_dwo_id)
1419+
return 0;
1420+
14151421
// Check for the offset to the macro table. If offset is incorrect then we
14161422
// need to remove the attribute.
14171423
if (AttrSpec.Attr == dwarf::DW_AT_macro_info) {

llvm/test/tools/dsymutil/X86/modules.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#ifdef BAR_H
3232
// ---------------------------------------------------------------------
3333
// CHECK: DW_TAG_compile_unit
34+
// CHECK-NOT: DW_AT_GNU_dwo_id
3435
// CHECK-NOT: DW_TAG
3536
// CHECK: DW_TAG_module
3637
// CHECK-NEXT: DW_AT_name{{.*}}"Bar"
@@ -55,6 +56,7 @@
5556
#ifdef FOO_H
5657
// ---------------------------------------------------------------------
5758
// CHECK: DW_TAG_compile_unit
59+
// CHECK-NOT: DW_AT_GNU_dwo_id
5860
// CHECK-NOT: DW_TAG
5961
// CHECK: 0x0[[FOO:.*]]: DW_TAG_module
6062
// CHECK-NEXT: DW_AT_name{{.*}}"Foo"
@@ -92,8 +94,9 @@ @interface Foo {
9294
#else
9395
// ---------------------------------------------------------------------
9496

95-
// CHECK: DW_TAG_compile_unit
96-
// CHECK: DW_AT_low_pc
97+
// CHECK: DW_TAG_compile_unit
98+
// CHECK-NOT: DW_AT_GNU_dwo_id
99+
// CHECK: DW_AT_low_pc
97100
// CHECK-NOT: DW_TAG_module
98101
// CHECK-NOT: DW_TAG_typedef
99102
//
@@ -130,8 +133,9 @@ int main(int argc, char **argv) {
130133
#endif
131134
#endif
132135

133-
// CHECK: DW_TAG_compile_unit
134-
// CHECK: DW_AT_name {{.*}}"odr_violation.c"
136+
// CHECK: DW_TAG_compile_unit
137+
// CHECK-NOT: DW_AT_GNU_dwo_id
138+
// CHECK: DW_AT_name {{.*}}"odr_violation.c"
135139
// CHECK: DW_TAG_variable
136140
// CHECK: DW_AT_name {{.*}}"odr_violation"
137141
// CHECK: DW_AT_type [DW_FORM_ref4] ({{.*}}{0x{{0*}}[[BAR2:.*]]}

0 commit comments

Comments
 (0)