I tried this code:
#![no_std]
use aes_gcm::Aes256Gcm;
use aes_gcm::aead::{Aead, NewAead};
use generic_array::GenericArray;
pub fn encrypt_data() {
let key = GenericArray::from_slice(b"an example very very secret key.");
let cipher = Aes256Gcm::new(key);
let nonce = GenericArray::from_slice(b"unique nonce"); // 96-bits; unique per message
let ciphertext = cipher.encrypt(nonce, b"plaintext message".as_ref())
.expect("encryption failure!"); // NOTE: handle this error to avoid panics!
let plaintext = cipher.decrypt(nonce, ciphertext.as_ref())
.expect("decryption failure!"); // NOTE: handle this error to avoid panics!
assert_eq!(&plaintext, b"plaintext message");
}
Build command:
cargo build -Z build-std=core,alloc --release --target=x86_64-unknown-none-linuxkernel
Alternate build command (with AES and AVX2 explicitly enabled):
-Ctarget-cpu=native -Ctarget-feature=+aes,+ssse3,+avx2" cargo build -Z build-std=core,alloc --release --target=x86_64-unknown-none-linuxkernel
I expected to see this happen: Compilation without an LLVM error, as this is usage example code from the AES-GCM documentation (https://docs.rs/aes-gcm/0.9.3/aes_gcm/index.html).
Instead, this happened: I got this LLVM error (same error for both commands):
Compiling encryption v0.1.0 (/home/prathik/Code/encryption)
LLVM ERROR: Do not know how to split the result of this operator!
error: could not compile `encryption`
Meta
The issue disappears if I don't set the target to the linuxkernel target. I'm stumped since this is an LLVM error rather than a rustc/cargo error with line numbers. The maintainer of AES-GCM suggested explicitly enabling AES and AVX2 target support, but to no avail (see above).
rustc --version --verbose:
rustc 1.53.0-nightly (968425893 2021-04-26)
binary: rustc
commit-hash: 9684258936dabda2ba49d4c67f041a6baf388348
commit-date: 2021-04-26
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0
Backtrace
prathik@prathiks-buntobox:~/Code/encryption$ RUST_BACKTRACE=1 cargo build -Z build-std=core,alloc --release --target=x86_64-unknown-none-linuxkernel
Compiling encryption v0.1.0 (/home/prathik/Code/encryption)
LLVM ERROR: Do not know how to split the result of this operator!
error: could not compile `encryption`
To learn more, run the command again with --verbose.
I tried this code:
Build command:
Alternate build command (with AES and AVX2 explicitly enabled):
I expected to see this happen: Compilation without an LLVM error, as this is usage example code from the AES-GCM documentation (https://docs.rs/aes-gcm/0.9.3/aes_gcm/index.html).
Instead, this happened: I got this LLVM error (same error for both commands):
Meta
The issue disappears if I don't set the target to the linuxkernel target. I'm stumped since this is an LLVM error rather than a rustc/cargo error with line numbers. The maintainer of AES-GCM suggested explicitly enabling AES and AVX2 target support, but to no avail (see above).
rustc --version --verbose:Backtrace