Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trap at Instance error with codegen-backend = "cranelift" #572

Closed
dimitri-lenkov opened this issue Jan 8, 2024 · 2 comments
Closed

trap at Instance error with codegen-backend = "cranelift" #572

dimitri-lenkov opened this issue Jan 8, 2024 · 2 comments

Comments

@dimitri-lenkov
Copy link

Hi there,

I've created a super-minimal repository that reproduces the problem I'm running into:

https://github.com/dimitri-lenkov/cranelift_aead

Basically I'm seeing the following error while running tests. The text llvm.x86.avx2.permd (at the very end) caught my eye.

trap at Instance { def: Item(DefId(0:45 ~ poly1305[38f7]::backend::avx2::helpers::prepare_keys)), args: [] } (_ZN8poly13057backend4avx27helpers12prepare_keys17hede810be5c1ed765E): llvm.x86.avx2.permd

I did not expect any reference to LLVM when using cranelift. Is this library depending on some instruction that exists within LLVM? Have I mis-configured something?

I found this related issue which is why I'm asking those questions:

RustCrypto/block-ciphers#391

Feel free to close if this is considered spam or if I need to ask the folks in the cranelift repository anything. I just don't know how to proceed so thought I would ask here first. Thank you for your time.

@tarcieri
Copy link
Member

tarcieri commented Jan 8, 2024

You might want to report this to cranelift. It's another missing x86 intrinsic which needs an inline ASM implementation, similar to rust-lang/rustc_codegen_cranelift#1425

llvm.x86.avx2.permd looks correct, although it's probably not the only one which needs to be implemented for the poly1305 AVX2 backend to work.

I believe setting the poly1305_force_soft cfg attribute will disable AVX2 support. Alternatively if there's some way to detect cranelift we can at least temporarily disable the AVX2 backend when compiling there.

@dimitri-lenkov
Copy link
Author

dimitri-lenkov commented Jan 9, 2024

Thank you @tarcieri

I saw added the following [build] section in my .cargo/config.toml (link to rustflags docs) and see that it's working as expected now:

[build]
rustflags = [ "--cfg", "poly1305_force_soft" ]

But I ended up using RUSTFLAGS like this (and not the the above solution) because I really only want to use cranelift for a quick builds when testing:

RUSTFLAGS='--cfg=poly1305_force_soft' cargo test

Thanks for helping out this noob ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants