aws / aws-lc-rs

aws-lc-rs is a cryptographic library using AWS-LC for its cryptographic operations. The library strives to be API-compatible with the popular Rust library named ring.
Other
270 stars 49 forks source link

Cross-compiling Linux->Windows fails with prebuilt NASM #524

Open davids-work opened 1 week ago

davids-work commented 1 week ago

Problem:

Cross-compiling from a Linux system to x86_64-pc-windows-gnu fails if the prebuilt-nasm feature is included, and a nasm compiler is not installed on the system:

--- stderr
  Copying platform assembly files from /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/aws-lc/generated-src/win-x86_64/crypto/ to /home/davidsm/repos/temp/aws-lc-bug/target/x86_64-pc-windows-gnu/release/build/aws-lc-sys-beb7399d9c5ede0d/out/build/aws-lc/crypto
  /bin/sh: line 1: /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/prebuilt-nasm.bat: Permission denied
  /bin/sh: line 1: /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/prebuilt-nasm.bat: Permission denied
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:120: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/aesni-gcm-avx512.asm.obj] Error 126
  gmake[2]: *** Waiting for unfinished jobs....
  /bin/sh: line 1: /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/prebuilt-nasm.bat: Permission denied
  /bin/sh: line 1: /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/prebuilt-nasm.bat: Permission denied
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:125: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/aesni-gcm-x86_64.asm.obj] Error 126
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:130: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/aesni-xts-avx512.asm.obj] Error 126
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:140: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/ghash-ssse3-x86_64.asm.obj] Error 126
  /bin/sh: line 1: /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/prebuilt-nasm.bat: Permission denied
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:145: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/ghash-x86_64.asm.obj] Error 126
  /bin/sh: line 1: /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/prebuilt-nasm.bat: Permission denied
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:135: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/aesni-x86_64.asm.obj] Error 126
  /bin/sh: line 1: /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/prebuilt-nasm.bat: Permission denied
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:3780: aws-lc/crypto/CMakeFiles/crypto_objects.dir/chacha/chacha-x86_64.asm.obj] Error 126
  gmake[2]: *** Waiting for unfinished jobs....
  /bin/sh: line 1: /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/prebuilt-nasm.bat: Permission denied
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:3785: aws-lc/crypto/CMakeFiles/crypto_objects.dir/cipher_extra/chacha20_poly1305_x86_64.asm.obj] Error 126
  gmake[1]: *** [CMakeFiles/Makefile2:204: aws-lc/crypto/CMakeFiles/crypto_objects.dir/all] Error 2
  gmake[1]: *** Waiting for unfinished jobs....
  gmake[1]: *** [CMakeFiles/Makefile2:258: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/all] Error 2
  gmake: *** [Makefile:136: all] Error 2
  thread 'main' panicked at /home/davidsm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.51/src/lib.rs:1100:5:

  command did not execute successfully, got: exit status: 2

It looks to me like it tries to execute a .bat file, which I guess won't work on Linux.

To reproduce:

[dependencies] aws-lc-rs = { version = "1.9.0", default-features = false, features = ["aws-lc-sys", "prebuilt-nasm"] }


* Make sure that `nasm` is not installed
* Run `cargo build --release --target x86_64-pc-windows-gnu`. You'll need to install the appropriate toolchain via rustup or similar.

#### Relevant details
AWS-LC for Rust versions or commit: 1.9.0

System information: for linux, below info can be collected by running `uname -srvmp`
 * CPU architecture: x86_64
 * OS: Ubuntu 22.04
kerosina commented 1 week ago

I just got this error trying to cross compile too

justsmth commented 1 week ago

Hello!

So, one quick solution for this is to install NASM:

sudo apt-get install nasm

This is how I've been doing it locally. I'm working on a patch so that won't be required.