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

Error cross-compiling Linux->Windows with "fips" feature #534

Open eliad-wiz opened 3 days ago

eliad-wiz commented 3 days ago

Problem:

Cross compiling from linux to x86_64-pc-windows-gnu target fails when "fips" feature is enabled.

   Compiling aws-lc-fips-sys v0.12.11
The following warnings were emitted during compilation:

warning: aws-lc-fips-sys@0.12.11: Generating bindings - external bindgen. Platform: x86_64-pc-windows-gnu

error: failed to run custom build command for `aws-lc-fips-sys v0.12.11`

Caused by:
  process didn't exit successfully: `/tmp/rust/wintest/target/debug/build/aws-lc-fips-sys-b42c249ef2f3928a/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=AWS_LC_FIPS_SYS_NO_PREFIX
  cargo:rerun-if-env-changed=AWS_LC_FIPS_SYS_INTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_FIPS_SYS_EXTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_FIPS_SYS_NO_ASM
  cargo:rerun-if-env-changed=AWS_LC_FIPS_SYS_STATIC
  cargo:warning=Generating bindings - external bindgen. Platform: x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=AWS_LC_FIPS_SYS_INCLUDES
  cargo:rustc-cfg=use_bindgen_generated
  cargo:rerun-if-env-changed=AWS_LC_FIPS_SYS_STATIC
  cargo:rerun-if-env-changed=CMAKE_TOOLCHAIN_FILE
  cargo:rerun-if-env-changed=CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu

  --- stderr

  thread 'main' panicked at /home/eliad/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-fips-sys-0.12.11/builder/cmake_builder.rs:171:30:
  Failed to run vcvarsall.bat.
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

looks like it tries executing vcvarsall.bat locally

To reproduce, use the following Cargo.toml

[package]
name = "wintest"
version = "0.1.0"
edition = "2021"

[dependencies]
aws-lc-rs = { version = "1.9.0", features = ["fips"] }

and run cargo build --target x86_64-pc-windows-gnu

Relevant details

AWS-LC for Rust versions or commit: 1.9.0

System information:

justsmth commented 3 days ago

Hello!

I see in the output this message:

Failed to run vcvarsall.bat

Do you have Visual Studio (Community Edition) installed on the build host? Do you know the location of the vcvarsall.bat script on that host?

eliad-wiz commented 3 days ago

i'm cross compiling on a linux host. no visual studio (i don't even see such option), not batch files.

i guess this script is intended for local windows compilation, not for cross-compilation.

justsmth commented 3 days ago

Ahhh, of course.

Cross compilation is not a something that we test for FIPS builds. But it might be possible with a little effort.

We utilize that batch script to setup the build environment properly for Ninja. I'm not sure what alternative we would have when cross compiling from Linux.

We will look into this.