Skip to content

error on empty export_name#155515

Open
folkertdev wants to merge 1 commit intorust-lang:mainfrom
folkertdev:export-name-not-empty
Open

error on empty export_name#155515
folkertdev wants to merge 1 commit intorust-lang:mainfrom
folkertdev:export-name-not-empty

Conversation

@folkertdev
Copy link
Copy Markdown
Contributor

fixes #155495

Using an empty string as the name makes LLVM make up a name. However this name can be inconsistent between compilation units, which is UB and can cause linking errors, and some parts of LLVM just crash on the empty name (see the linked issue).

As far as we know there is only one valid pattern that could use this, a #[used] static that is not referenced by the program at all. That is not UB, but the export_name is not required for that to work, just normal rust name mangling would do fine.

Technically this is a breaking change, but it seems unlikely that this actually breaks code in the wild that wasn't already broken. I'll leave it up to T-lang to determine what is required here (crater run, FCW, ...), but my gut feeling is that we could just merge this and nobody would notice.

@folkertdev folkertdev added the I-lang-nominated Nominated for discussion during a lang team meeting. label Apr 19, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 19, 2026

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 19, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 19, 2026

r? @jdonszelmann

rustbot has assigned @jdonszelmann.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 72 candidates
  • Random selection from 17 candidates

@Urgau
Copy link
Copy Markdown
Member

Urgau commented Apr 19, 2026

Should we consider a symbol name with only white spaces as empty?

@folkertdev
Copy link
Copy Markdown
Contributor Author

Hmm, I don't know that it's useful at all but it apparently does work https://godbolt.org/z/dMqhK6hbx

" ":
.Lfunc_begin0:
        .cfi_startproc
        .file   1 "/app" "example.rs"
        .loc    1 2 16 prologue_end

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) I-lang-nominated Nominated for discussion during a lang team meeting. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llvm error: export_name

4 participants