Unable to build with rustc_codegen_cranelift on Apple M1
Trying to compile a project that depends on ring with Cranelift fails. I didn't see any issue filed about it so I thought there should be a place to track progress.
While they plan on implementing a bunch of std::arch SIMD intrinsics, maybe the correct solution is to check for cranelift and not use them?
Versions:
- ring 0.17.8
- cranelift_codegen 0.110.1
- rustc_codegen_cranelift 0.1.0
- rustc 1.82.0-nightly (b5d44db1d 2024-07-26)
error[E0080]: evaluation of constant value failed
--> /Users/nsabovic/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ring-0.17.8/src/cpu/arm.rs:352:54
|
352 | const _AARCH64_APPLE_TARGETS_EXPECTED_FEATURES: () = assert!(
| ______________________________________________________^
353 | | ((ARMCAP_STATIC & _AARCH64_APPLE_FEATURES) == _AARCH64_APPLE_FEATURES)
354 | | || !cfg!(all(target_arch = "aarch64", target_vendor = "apple"))
355 | | );
| |_^ the evaluated program panicked at 'assertion failed: ((ARMCAP_STATIC & _AARCH64_APPLE_FEATURES) == _AARCH64_APPLE_FEATURES) ||
!cfg!(all(target_arch = "aarch64", target_vendor = "apple"))', /Users/nsabovic/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ring-0.17.8/src/cpu/arm.rs:352:54
|
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
Which target features does ring expect that cranelift isn't enabling automatically for these targets?
Similar issue here.
How can we detect cranelift in a cfg expression?
Same issue! macbook Pro M1 rustc 1.84.1 (e71f9a9a9 2025-01-27)
It looks like it is very close to working. Probably somebody should "just" contribute the missing pmull/sha support to cranelift and then this will work OOB.
If cranelift already supports aes then it should be relatively easy for it to support the other two missing crypto extensions. Probably a new contributor to cranelift could look at how they added aes and do a bit of copy-pasta to get the other two working.
I looked at the cranelift repo and saw https://github.com/rust-lang/rustc_codegen_cranelift/issues/1522 which indicates that ring builds with cranelift just fine after they added the target feature detection.