#![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
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):
IR for reference:
I don't know enough about wasm to know what is correct here, but looking at some wasm codegen it seems like
.pushsectionshould become.section,.popsectionshould be dropped, and we should emit.functypedirectives (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