rust-lang / rustc_codegen_cranelift

Cranelift based backend for rustc
Apache License 2.0
1.59k stars 101 forks source link

Full asm!() support #1204

Open bjorn3 opened 2 years ago

bjorn3 commented 2 years ago

Tracking issue for stabilizing asm!(): https://github.com/rust-lang/rust/issues/72016 Has been stabilized.

bjorn3 commented 2 years ago

Avoid the object file linking hack. It doesn't work on macOS and Windows but is currently necessary as incr comp expects each codegen unit to provide a single object file instead of allowing an extra object file for the compiled assembly.

I managed to do this on the parallel_comp_refactor branch.

bjorn3 commented 2 years ago

Merged in #1264.

bjorn3 commented 1 year ago

Mostly implemented const and sym operands for both inline and global asm.

bjorn3 commented 11 months ago

As of https://github.com/rust-lang/rustc_codegen_cranelift/pull/1403 inline asm is now supported and stable on all targets supported by cg_clif.

repi commented 11 months ago

awesome!

did a quick test with building our codebase with this and did fail on wasmtime-runtime using inline asm:

error: asm! and global_asm! sym operands are not yet supported
   --> /home/repi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-runtime-14.0.2/src/libcalls.rs:156:5
    |
156 |     wasmtime_environ::foreach_builtin_function!(libcall);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this error originates in the macro `std::arch::global_asm` which comes from the expansion of the macro `wasmtime_environ::foreach_builtin_function` (in Nightly builds, run with -Z macro-backtrace for more info)

related to this note?

For global asm (https://github.com/rust-lang/rustc_codegen_cranelift/pull/1351, but doesn't work when the function is made private to the codegen unit)

or maybe this was not part of the new deployed rustup component?

bjorn3 commented 11 months ago

related to this note?

Correct. So far I had only checked wasmtime with unstable features enabled (as is the default for building it using ./y.sh in this repo), but not with unstable features disabled (as is the case for the rustc-codegen-cranelift-preview rustup component) With unstable features enabled the entire wasmtime test suite passes with the exception of a couple of tests that need panic=unwind.

repi commented 11 months ago

ah good to know, and fantastic that the full test suite passes!