Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang emits wrong (escaped) path in preprocessor+assembler output on Windows #117317

Open
aykevl opened this issue Nov 22, 2024 · 1 comment
Open

Comments

@aykevl
Copy link
Contributor

aykevl commented Nov 22, 2024

Take this very simple assembly file:

foobar:
        nop

If I compile without the preprocessor, the DW_AT_decl_file under DW_TAG_label looks more or less correct:

$ clang -g --target=thumbv6m-unknown-unknown-eabi -c -o tmp/test.o "C:\Users\Ayke\src\tinygo\tinygo\tmp\test.s"

$ llvm-dwarfdump tmp/test.o
tmp/test.o:     file format elf32-littlearm

.debug_info contents:
0x00000000: Compile Unit: length = 0x0000006c, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000070)

0x0000000c: DW_TAG_compile_unit
              DW_AT_stmt_list   (0x00000000)
              DW_AT_low_pc      (0x00000000)
              DW_AT_high_pc     (0x00000002)
              DW_AT_name        ("tmp\\test.s")
              DW_AT_comp_dir    ("C:\\Users\\Ayke\\src\\tinygo\\tinygo")
              DW_AT_producer    ("clang version 19.1.4")
              DW_AT_language    (DW_LANG_Mips_Assembler)

0x0000005b:   DW_TAG_label
                DW_AT_name      ("foobar")
                DW_AT_decl_file ("C:\Users\Ayke\src\tinygo\tinygo/tmp\test.s")
                DW_AT_decl_line (1)
                DW_AT_low_pc    (0x00000000)

0x0000006f:   NULL

(There's a forward slash there for some reason, but that's not what this bug is about).

But when I compile with the preprocessor enabled (note test.S instead of test.s), the DW_AT_decl_file path seems to be escaped:

$ ~/scoop/apps/llvm/current/bin/clang -g --target=thumbv6m-unknown-unknown-eabi -c -o tmp/test.o "C:\Users\Ayke\src\tinygo\tinygo\tmp\test.S"

$ llvm-dwarfdump tmp/test.o
tmp/test.o:     file format elf32-littlearm

.debug_info contents:
0x00000000: Compile Unit: length = 0x00000093, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000097)

0x0000000c: DW_TAG_compile_unit
              DW_AT_stmt_list   (0x00000000)
              DW_AT_low_pc      (0x00000000)
              DW_AT_high_pc     (0x00000002)
              DW_AT_name        ("C:\\\\Users\\\\Ayke\\\\src\\\\tinygo\\\\tinygo\\\\tmp\\\\test.S")
              DW_AT_comp_dir    ("C:\\Users\\Ayke\\src\\tinygo\\tinygo")
              DW_AT_producer    ("clang version 19.1.4")
              DW_AT_language    (DW_LANG_Mips_Assembler)

0x00000082:   DW_TAG_label
                DW_AT_name      ("foobar")
                DW_AT_decl_file ("C:\\Users\\Ayke\\src\\tinygo\\tinygo\\tmp\\test.S")
                DW_AT_decl_line (8)
                DW_AT_low_pc    (0x00000000)

0x00000096:   NULL

Also, the DW_AT_name even looks double-escaped!

This is my Clang version:

$ clang --version
clang version 19.1.4
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Users\Ayke\scoop\apps\llvm\19.1.4\bin
@llvmbot
Copy link
Member

llvmbot commented Nov 22, 2024

@llvm/issue-subscribers-debuginfo

Author: Ayke (aykevl)

Take this very simple assembly file:
foobar:
        nop

If I compile without the preprocessor, the DW_AT_decl_file under DW_TAG_label looks more or less correct:

$ clang -g --target=thumbv6m-unknown-unknown-eabi -c -o tmp/test.o "C:\Users\Ayke\src\tinygo\tinygo\tmp\test.s"

$ llvm-dwarfdump tmp/test.o
tmp/test.o:     file format elf32-littlearm

.debug_info contents:
0x00000000: Compile Unit: length = 0x0000006c, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000070)

0x0000000c: DW_TAG_compile_unit
              DW_AT_stmt_list   (0x00000000)
              DW_AT_low_pc      (0x00000000)
              DW_AT_high_pc     (0x00000002)
              DW_AT_name        ("tmp\\test.s")
              DW_AT_comp_dir    ("C:\\Users\\Ayke\\src\\tinygo\\tinygo")
              DW_AT_producer    ("clang version 19.1.4")
              DW_AT_language    (DW_LANG_Mips_Assembler)

0x0000005b:   DW_TAG_label
                DW_AT_name      ("foobar")
                DW_AT_decl_file ("C:\Users\Ayke\src\tinygo\tinygo/tmp\test.s")
                DW_AT_decl_line (1)
                DW_AT_low_pc    (0x00000000)

0x0000006f:   NULL

(There's a forward slash there for some reason, but that's not what this bug is about).

But when I compile with the preprocessor enabled (note test.S instead of test.s), the DW_AT_decl_file path seems to be escaped:

$ ~/scoop/apps/llvm/current/bin/clang -g --target=thumbv6m-unknown-unknown-eabi -c -o tmp/test.o "C:\Users\Ayke\src\tinygo\tinygo\tmp\test.S"

$ llvm-dwarfdump tmp/test.o
tmp/test.o:     file format elf32-littlearm

.debug_info contents:
0x00000000: Compile Unit: length = 0x00000093, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000097)

0x0000000c: DW_TAG_compile_unit
              DW_AT_stmt_list   (0x00000000)
              DW_AT_low_pc      (0x00000000)
              DW_AT_high_pc     (0x00000002)
              DW_AT_name        ("C:\\\\Users\\\\Ayke\\\\src\\\\tinygo\\\\tinygo\\\\tmp\\\\test.S")
              DW_AT_comp_dir    ("C:\\Users\\Ayke\\src\\tinygo\\tinygo")
              DW_AT_producer    ("clang version 19.1.4")
              DW_AT_language    (DW_LANG_Mips_Assembler)

0x00000082:   DW_TAG_label
                DW_AT_name      ("foobar")
                DW_AT_decl_file ("C:\\Users\\Ayke\\src\\tinygo\\tinygo\\tmp\\test.S")
                DW_AT_decl_line (8)
                DW_AT_low_pc    (0x00000000)

0x00000096:   NULL

Also, the DW_AT_name even looks double-escaped!

This is my Clang version:

$ clang --version
clang version 19.1.4
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Users\Ayke\scoop\apps\llvm\19.1.4\bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants