https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123886
Bug ID: 123886
Summary: Invalid assembly expressions generated with LTO and
debuging info
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: ssorensen at roku dot com
Target Milestone: ---
When building llvm-21.1.8 with
cmake -DCMAKE_CXX_FLAGS="-O1 -g -fsanitize=thread -flto=auto" \
-DCMAKE_BUILD_TYPE=Debug \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_TARGETS_TO_BUILD='X86'
make -j32 llvm-libraries
I get this error:
/tmp/ccLGSbzu.s: Assembler messages:
/tmp/ccLGSbzu.s:277970: Error: bad expression
GCC Version: master@74e0bb3faacfccfdf5633ab7ad3a15549d4a954d, 14.3.0, 15.2.0
Host: Ubuntu 24.04 x86_64
Host GCC: 13.3.0
Binutils: 2.42
With -save-temps and -dA I see this in the .debug_info section of the generated
assembly file:
.uleb128 0x40 # (DIE (0x6e090) DW_TAG_namespace)
.long ^R+84812 # DW_AT_abstract_origin
.uleb128 0x3d # (DIE (0x6e095) DW_TAG_subprogram)
# DW_AT_external
# DW_AT_declaration
.long .LASF68 # DW_AT_linkage_name: "__cxa_atexit"
.long .LASF68 # DW_AT_name: "__cxa_atexit"
.byte 0 # end of children of DIE 0x6e090
.byte 0 # end of children of DIE 0xc
Output from running with -fdump-debug:
DIE 0: DW_TAG_namespace (0x7f58dff83500)
abbrev id: 0 offset: 0 mark: 0
DW_AT_abstract_origin: die -> label:
<A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5><A5>__si_class_type_info
+ 84812 (0x7f58dff83550)
DIE 0: DW_TAG_subprogram (0x7f58dff835a0)
abbrev id: 0 offset: 0 mark: 0
DW_AT_external: 1
DW_AT_declaration: 1
DW_AT_linkage_name: "__cxa_atexit"
DW_AT_name: "__cxa_atexit"
Digging into this, the p.sym pointer passed to external_die_map->put() in
dwarf2out_register_external_die() points to a valid string, but later in
output_die the
content has been overwritten by GC poisoning. This happens the first time GC
runs after
setting ggc_protect_identifiers to false.
Moving setting ggc_protect_identifiers to false to after debug_info generation
is done in
compile_file() fixes the compilation, but I don't know enough about GCC
internals to
assess if this is a valid solution or what the side effects might be.