Skip to content

Wrong DWARF source file path for system libraries #20775

@kon72

Description

@kon72

I recently bumped emscripten version and I noticed source map is not working for system libraries.
After bisecting, it seems the commit 53bb231 introduces the source map failure.

To point out the DWARF entry for __trap.c in libcompiler_rt.a, DW_AT_name should be /emsdk/emscripten/system/lib/compiler-rt/__trap.c or system/lib/compiler-rt/__trap.c, but it actually points to ../../../system/lib/compiler-rt/__trap.c

Expected behavior (before 53bb231):

$ llvm-dwarfdump -debug-info -debug-line --recurse-depth=0  emscripten/cache/sysroot/lib/wasm32-emscripten/libcompiler_rt.a
emscripten/cache/sysroot/lib/wasm32-emscripten/libcompiler_rt.a(__trap.o):  file format WASM

.debug_info contents:
0x00000000: Compile Unit: length = 0x0000003a, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x0000003e)

0x0000000b: DW_TAG_compile_unit
              DW_AT_producer    ("clang version 17.0.0 (https://github.com/llvm/llvm-project a8cbd27d1f238e104a5d5ca345d93bc1f4d4ab1f)")
              DW_AT_language    (DW_LANG_C11)
              DW_AT_name    ("/emsdk/emscripten/system/lib/compiler-rt/__trap.c")
              DW_AT_stmt_list   (0x00000000)
              DW_AT_comp_dir    ("/emsdk/emscripten")

Actual behavior (after 53bb231):

$ llvm-dwarfdump -debug-info -debug-line --recurse-depth=0  emscripten/cache/sysroot/lib/wasm32-emscripten/libcompiler_rt.a
emscripten/cache/sysroot/lib/wasm32-emscripten/libcompiler_rt.a(__trap.o):  file format WASM

.debug_info contents:
0x00000000: Compile Unit: length = 0x0000003a, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x0000003e)

0x0000000b: DW_TAG_compile_unit
              DW_AT_producer    ("clang version 17.0.0 (https://github.com/llvm/llvm-project a8cbd27d1f238e104a5d5ca345d93bc1f4d4ab1f)")
              DW_AT_language    (DW_LANG_C11)
              DW_AT_name    ("../../../system/lib/compiler-rt/__trap.c")
              DW_AT_stmt_list   (0x00000000)
              DW_AT_comp_dir    ("/emsdk/emscripten")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions