rust-lang / rustc_codegen_cranelift

Cranelift based backend for rustc
Apache License 2.0
1.52k stars 94 forks source link

Cannot run project due error `unsupported llvm intrinsic llvm.prefetch` - `trap at Instance ... llvm.x86.avx2.psad.bw` #1406

Closed qarmin closed 7 months ago

qarmin commented 8 months ago

Steps to reproduce

git clone https://github.com/qarmin/czkawka.git
cd czkawka
git checkout 4ae23037e493bc6af7f5e257f8220fd097e3dba4
cd czkawka_slint_gui
CARGO_PROFILE_DEV_CODEGEN_BACKEND=cranelift cargo +nightly run -Zcodegen-backend

Error

warning: unsupported llvm intrinsic llvm.prefetch; replacing with trap

warning: `czkawka_core` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 2m 00s
rafal@rafal-H87M-D3H:~/Projekty/Rust/czkawka/czkawka_slint_gui$ CARGO_PROFILE_DEV_CODEGEN_BACKEND=cranelift cargo +nightly run -Zcodegen-backend
warning: unsupported llvm intrinsic llvm.prefetch; replacing with trap

warning: `czkawka_core` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 1.80s
     Running `/home/rafal/Projekty/Rust/czkawka/target/debug/czkawka_slint`
trap at Instance { def: Item(DefId(2:14641 ~ core[53bd]::core_arch::x86::avx2::_mm256_sad_epu8)), args: [] } (_ZN4core9core_arch3x864avx215_mm256_sad_epu817h452ea8cc02b4bc52E): llvm.x86.avx2.psad.bw
bjorn3 commented 8 months ago

Turns out cg_clif miscompiled is_x86_feature_detected!() such that AVX is never detected: https://github.com/rust-lang/rustc_codegen_cranelift/issues/1405#issuecomment-1787952058 This has resulted in me not noticing all the AVX intrinsics that crates rely on. When using the rustup component, an LLVM compiled libstd will be used which has a correct is_x86_feature_detected!() which does detect AVX. I will work on implementing this AVX vendor intrinsic tomorrow.

bjorn3 commented 8 months ago

I can't directly reproduce this as I'm testing it on a server without gui support. Assuming this issue originates from the image crate, I can reproduce it using the test suite of the image crate. Working on a fix right now.

bjorn3 commented 8 months ago

If it was indeed the image crate being broken, a fix should now be available on the implement_xgetbv branch.

bjorn3 commented 7 months ago

Can you try again with the latest nightly? The image crate should now fully work.

qarmin commented 7 months ago

I tried day or two day ago to run in after using rustup update, but it was still broken.

But when I run it via - https://github.com/rust-lang/rustc_codegen_cranelift/releases/tag/dev - then everything works fine.

bjorn3 commented 7 months ago

I tried day or two day ago to run in after using rustup update, but it was still broken.

The subtree sync only just landed in the latest nightly.

But when I run it via - https://github.com/rust-lang/rustc_codegen_cranelift/releases/tag/dev - then everything works fine.

Great!