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

naked_functions: invalid instruction mnemonic <function name> on an .endef line #138320

Closed
skyfloogle opened this issue Mar 10, 2025 · 3 comments · Fixed by #138346
Closed

naked_functions: invalid instruction mnemonic <function name> on an .endef line #138320

skyfloogle opened this issue Mar 10, 2025 · 3 comments · Fixed by #138346
Labels
A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` O-windows Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@skyfloogle
Copy link

On nightly-2024-12-13 and any later version, I'm seeing compile errors in my project. I do not get these errors on previous nightlies. My project only builds for Windows 32-bit (and requires nightly Rust), but I'm seeing this error both on native MSVC and when cross-compiling on Linux with the i686-pc-windows-gnu target. The error message in question looks like this:

error: invalid instruction mnemonic '_zn8gm82save39confirm_before_deleting_action_timeline17h22d105fcf186e7cce@0'
     |
note: instantiated into assembly here
    --> <inline asm>:1808:9
     |
1808 | .endef @_ZN8gm82save39confirm_before_deleting_action_timeline17h22d105fcf186e7ccE@0
     |   

No additional information is printed with RUST_BACKTRACE=1.

This error occurs for the following functions on debug and release builds (listing manged function names, links point to relevant source code):

And for the following functions, only on release builds:

All of the above are naked functions. The project contains many other naked functions; I don't know whether these are special or whether it just didn't get to any others. I've tried a blank project with just one naked function, and that compiles without issue.

The date and error message seem to point to #128004 (.endef is generated here), but I'm not familiar enough with the internals to identify what's wrong here.

The issue can be reproduced by cloning https://github.com/GM82Project/gm82save and running cargo build (with or without --release, specifying --target=i686-pc-windows-gnu if necessary). There's no unusual dependencies.

@skyfloogle skyfloogle added the C-bug Category: This is a bug. label Mar 10, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 10, 2025
@jieyouxu jieyouxu added O-windows-gnu Toolchain: GNU, Operating system: Windows A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example F-naked_functions `#![feature(naked_functions)]` O-x86_32 Target: x86 processors, 32 bit (like i686-*) labels Mar 10, 2025
@jieyouxu
Copy link
Member

cc @folkertdev in case you have any clues / notice anything obviously wrong

@folkertdev
Copy link
Contributor

I can reproduce this https://godbolt.org/z/b398adPWh.

The fix is simple, clearly the x86_64-pc-windows-gnu parser is less strict than the one for i686 so I'll try and run more tests for that target too.

Thanks for reporting!

@jieyouxu jieyouxu added O-windows Operating system: Windows and removed O-windows-gnu Toolchain: GNU, Operating system: Windows O-x86_32 Target: x86 processors, 32 bit (like i686-*) labels Mar 11, 2025
@moxian
Copy link
Contributor

moxian commented Mar 11, 2025

@rustbot labels: +T-compiler -E-needs-mcve -needs-triage

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 11, 2025
jieyouxu added a commit to jieyouxu/rust that referenced this issue Mar 12, 2025
…, r=ChrisDenton

naked functions: on windows emit `.endef` without the symbol name

tracking issue: rust-lang#90957
fixes rust-lang#138320

The `.endef` directive does not take the name as an argument. Apparently the LLVM x86_64 parser does accept this, but on i686 it's rejected. In general `i686` does some special name mangling stuff, so it's good to include it in the naked function tests.

r? `@ChrisDenton` (because windows)
jieyouxu added a commit to jieyouxu/rust that referenced this issue Mar 12, 2025
…, r=ChrisDenton

naked functions: on windows emit `.endef` without the symbol name

tracking issue: rust-lang#90957
fixes rust-lang#138320

The `.endef` directive does not take the name as an argument. Apparently the LLVM x86_64 parser does accept this, but on i686 it's rejected. In general `i686` does some special name mangling stuff, so it's good to include it in the naked function tests.

r? ``@ChrisDenton`` (because windows)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 13, 2025
…, r=ChrisDenton

naked functions: on windows emit `.endef` without the symbol name

tracking issue: rust-lang#90957
fixes rust-lang#138320

The `.endef` directive does not take the name as an argument. Apparently the LLVM x86_64 parser does accept this, but on i686 it's rejected. In general `i686` does some special name mangling stuff, so it's good to include it in the naked function tests.

r? ```@ChrisDenton``` (because windows)
@bors bors closed this as completed in 1827ffd Mar 13, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 13, 2025
Rollup merge of rust-lang#138346 - folkertdev:naked-asm-windows-endef, r=ChrisDenton

naked functions: on windows emit `.endef` without the symbol name

tracking issue: rust-lang#90957
fixes rust-lang#138320

The `.endef` directive does not take the name as an argument. Apparently the LLVM x86_64 parser does accept this, but on i686 it's rejected. In general `i686` does some special name mangling stuff, so it's good to include it in the naked function tests.

r? ````@ChrisDenton```` (because windows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` O-windows Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants