Skip to content

Line number information missing for new naked-asm implementation #146736

@cbiffle

Description

@cbiffle

When we upgraded the default toolchain for Hubris to the 2025-07-20 nightly, we had to go through and update our syscall stubs for the new (stable!) naked function syntax, which we did enthusiastically.

However, it looks like since that commit, stack traces that begin in naked assembly routines have been broken (oxidecomputer/hubris#2236 if you're curious).

I dug into this today, and it appears that on recent compilers, some forms of line number information are not being generated for naked_asm!. In the attached example output binary (which was produced on nightly-2025-09-17 after bisecting didn't turn up any improvements), none of objdump, addr2line, Humility, or my DWARF analysis tools (debugdb/tysh) are able to recover a line number for any position in the _start routine:

[cbiffle@gwydion hubris5]$ arm-none-eabi-objdump -dCl /tmp/idle | head

/tmp/idle:     file format elf32-littlearm


Disassembly of section .text:

080086c0 <_start>:
_start():
 80086c0:	f242 1000 	movw	r0, #8448	@ 0x2100
 80086c4:	f2c2 4000 	movt	r0, #9216	@ 0x2400
[cbiffle@gwydion hubris5]$ arm-none-eabi-addr2line -e /tmp/idle 0x080086c0
task_idle.63c1e54c3c0b5cbe-cgu.0:?

The "filename" given by addr2line looks an awful lot like some sort of tmpnam to me, leading me to wonder if the compiler might accidentally be attributing naked asm blocks to a temporary file. (Though this doesn't explain why the simpler ELF info used by objdump appears to be missing.)

On other Oxide projects we've also confirmed that this happens on the x86-none ELF target, so it isn't ARM specific.

For what it's worth, I suspect that #144610 is not the same issue:

  • when it says "unwinding" it means the program unwinding itself, whereas I'm talking about debuggers;
  • the line number information is not part of the CFI annotations, and I've confirmed that CFI-annotating the assembly stubs does not cause this behavior to change.

Meta

Tested as recently as:

[cbiffle@gwydion hubris5]$ rustc --version --verbose
rustc 1.92.0-nightly (a9d0a6f15 2025-09-16)
binary: rustc
commit-hash: a9d0a6f15533a364816c4d81e2192009ef601d33
commit-date: 2025-09-16
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1

Appears to start around nightly-2025-07-20 but it's a bit hard to bisect, since it requires changing the syntax of the input code to the new naked-asm feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)A-inline-assemblyArea: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcF-naked_functions`#![feature(naked_functions)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions