Skip to content

global_asm! issues LLVM error "undefined temporary symbol" for non-existent numerical labels #140179

Open
@pqcfox

Description

@pqcfox

I've found that if I place undefined local numeric labels in a global_asm! block, that rustc will yield an LLVM (?) error error: Undefined temporary symbol .Ltmp0, presumably as the numeric label is replaced with a temporary symbol .Ltmp0.

Here's a minimum viable example:

use std::arch::global_asm;

fn main () {}

global_asm!(
    "jmp 100f"
);

(Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ddb9a35af1ac6a0c4d3a145253605252)

Notably, changing the label to a (global) text label as in the following doesn't cause any error to be issued.

use std::arch::global_asm;

fn main () {}

global_asm!(
    "jmp .label"
);

I wasn't sure if this is something that would fall into the purview of Rust to handle with a more direct error message, but wanted to raise it as a potential issue since I'd expect either (a) no error message as in the case of the global label or (b) a typical rustc error message indicating where in the code the issue lies.

Meta

rustc --version --verbose:

rustc 1.85.1 (4eb161250 2025-03-15)
binary: rustc
commit-hash: 4eb161250e340c8f48f66e2b929ef4a5bed7c181
commit-date: 2025-03-15
host: x86_64-unknown-linux-gnu
release: 1.85.1
LLVM version: 19.1.7

Also verified with nightly:

rustc 1.88.0-nightly (d6c1e454a 2025-04-21)
binary: rustc
commit-hash: d6c1e454aa8af5e7e59fbf5c4e7d3128d2f99582
commit-date: 2025-04-21
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-global-asmArea: `global_asm!`C-discussionCategory: Discussion or questions that doesn't represent real issues.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