You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As noted in #561, I am working on a Rust project that builds C code and is suffering from a missing intrinsic. Luckily, I am building for wasm32-wasi, and I have a C compiler with its own libcompiler-rt implementation for my target platform.
The README for this project says that in that case, I can drop this into my Cargo.toml to use the C library implementations in my project:
[dependencies.compiler_builtins]
git = "https://github.com/rust-lang/compiler-builtins"
features = ["c"]
But this doesn't work at all. I get a bunch of errors about the crate using #![feature].
error[E0554]: `#![feature]` may not be used on the stable release channel
--> /Users/anovak/.cargo/git/checkouts/compiler-builtins-79341f926ffc30b3/2731a48/src/lib.rs:2:38
|
2 | #![cfg_attr(not(feature = "no-asm"), feature(asm))]
| ^^^^^^^^^^^^
error[E0554]: `#![feature]` may not be used on the stable release channel
--> /Users/anovak/.cargo/git/checkouts/compiler-builtins-79341f926ffc30b3/2731a48/src/lib.rs:3:1
|
3 | #![feature(abi_unadjusted)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0554]: `#![feature]` may not be used on the stable release channel
--> /Users/anovak/.cargo/git/checkouts/compiler-builtins-79341f926ffc30b3/2731a48/src/lib.rs:4:38
|
4 | #![cfg_attr(not(feature = "no-asm"), feature(global_asm))]
| ^^^^^^^^^^^^^^^^^^^
If I remove the git line and use whatever release Cargo finds for me, I get the same error. It looks like the #![feature] logic has been in the codebase for years, and there isn't actually a version of the crate available for the stable Rust compiler.
Which leaves me confused as to how, when I don't edit Cargo.toml, the file /Users/anovak/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libcompiler_builtins-a0294efb55e060eb.rlib is getting into my build. How was the library built to be part of the stable-aarch64-apple-darwin Rust toolchain if the library can't build on the stable Rust compiler?
And how do I convince the stable Rust compiler to be able to link with C code that needs intrinsics from my C compiler's compiler-rt library?
The text was updated successfully, but these errors were encountered:
compiler-builtins is an internal implementation detail of Rust and is not intended for use as a normal dependency. It is meant to be built as part of the standard library (which is exempt from feature restrictions since it comes from the same Rust version as the compiler), not as a normal Cargo dependency.
The compiler-builtins from rustup already has the "c" feature enabled. The problem is that our build.rs does not include these function on WASM targets. If you look at build.rs you will see we do have them on AArch64 and MIPS64 targets, perhaps you could try copying that for WASM targets as well?
To actually test this, you will need a nightly compiler and a checkout of compiler-rt from which the C files can be compiled.
Once you have confirmed that this fixes the issue, you can submit a PR here, and then another PR to rust-lang/rust to update the compiler-builtins version in the standard library.
As noted in #561, I am working on a Rust project that builds C code and is suffering from a missing intrinsic. Luckily, I am building for
wasm32-wasi
, and I have a C compiler with its ownlibcompiler-rt
implementation for my target platform.The README for this project says that in that case, I can drop this into my
Cargo.toml
to use the C library implementations in my project:But this doesn't work at all. I get a bunch of errors about the crate using
#![feature]
.If I remove the
git
line and use whatever releaseCargo
finds for me, I get the same error. It looks like the#![feature]
logic has been in the codebase for years, and there isn't actually a version of the crate available for the stable Rust compiler.Which leaves me confused as to how, when I don't edit
Cargo.toml
, the file/Users/anovak/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libcompiler_builtins-a0294efb55e060eb.rlib
is getting into my build. How was the library built to be part of thestable-aarch64-apple-darwin
Rust toolchain if the library can't build on the stable Rust compiler?And how do I convince the stable Rust compiler to be able to link with C code that needs intrinsics from my C compiler's compiler-rt library?
The text was updated successfully, but these errors were encountered: