-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.Category: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
#![feature(asm_experimental_arch)]
#![feature(naked_functions)]
#[naked]
pub extern "C" fn foo() {
unsafe { core::arch::naked_asm!("nop") }
}
This should work (at least, I don't know of any reason it shouldn't), but it looks like the way we wrap it is something that LLVM doesn't like (trimmed output):
error: unknown directive
note: instantiated into assembly here
1 | .pushsection .text._ZN7example3foo17h5bf07194c275cbceE,"ax", @progbits
warning: .size directive ignored for function symbols
7 | .size _ZN7example3foo17h5bf07194c275cbceE, . - _ZN7example3foo17h5bf07194c275cbceE
error: unknown directive
note: instantiated into assembly here
8 | .popsection
error: Unmatched block construct(s) at function end: function
note: instantiated into assembly here
9 |
IR for reference:
module asm ".pushsection .text.foo,\22ax\22, @progbits"
module asm ".balign 4"
module asm ".globl foo"
module asm ".type foo, @function"
module asm "foo:"
module asm "nop"
module asm ".size foo, . - foo"
module asm ".popsection"
I don't know enough about wasm to know what is correct here, but looking at some wasm codegen it seems like .pushsection
should become .section
, .popsection
should be dropped, and we should emit .functype
directives (e.g. .functype somefunc (f64) -> (f64)
)
https://rust.godbolt.org/z/re5sverch
cc @folkertdev for naked functions and @daxpedda for knowing more about wasm-asm
Metadata
Metadata
Assignees
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.Category: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.