ring icon indicating copy to clipboard operation
ring copied to clipboard

Unable to build with rustc_codegen_cranelift on Apple M1

Open nsabovic opened this issue 1 year ago • 1 comments

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)

nsabovic avatar Jul 29 '24 10:07 nsabovic

Which target features does ring expect that cranelift isn't enabling automatically for these targets?

briansmith avatar Sep 27 '24 22:09 briansmith

Similar issue here.

LeonardoRosaa avatar Nov 28 '24 23:11 LeonardoRosaa

How can we detect cranelift in a cfg expression?

briansmith avatar Dec 01 '24 19:12 briansmith

Same issue! macbook Pro M1 rustc 1.84.1 (e71f9a9a9 2025-01-27)

Image

askdaddy avatar Feb 14 '25 10:02 askdaddy

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.

briansmith avatar Feb 14 '25 16:02 briansmith

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.

briansmith avatar Feb 14 '25 16:02 briansmith

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.

briansmith avatar May 30 '25 04:05 briansmith