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
272 stars 50 forks source link

Unable to build aws-lc-sys on Windows #537

Open frederikhors opened 1 week ago

frederikhors commented 1 week ago

Problem:

From https://github.com/rustls/rustls/issues/2133:

On Windows 10 with Microsoft Build Tools latest version as of today I get this error:

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

Caused by:
  process didn't exit successfully: `C:\prj\target\debug\build\aws-lc-sys-19d1ffd36a8f3b39\build-script-main` (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)
  --- stdout
  cargo:rerun-if-env-changed=AWS_LC_SYS_NO_PREFIX
  cargo:rerun-if-env-changed=AWS_LC_SYS_INTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_SYS_EXTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_SYS_NO_ASM
  cargo:rerun-if-env-changed=AWS_LC_SYS_CFLAGS
  cargo:rerun-if-env-changed=AWS_LC_SYS_PREBUILT_NASM
  cargo:rerun-if-env-changed=AWS_LC_SYS_C_STD
  cargo:rustc-cfg=x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=AWS_LC_SYS_CMAKE_BUILDER
  cargo:rerun-if-env-changed=AWS_LC_SYS_STATIC
  default_for Target: 'x86_64-pc-windows-msvc'
  cargo:rerun-if-env-changed=AWS_LC_SYS_STATIC
  cargo:rerun-if-env-changed=CMAKE

  --- stderr
  Missing dependency: cmake
  thread 'main' panicked at C:\Users\fred\.cargo\registry\src\index.crates.io-6f17d22bba15001f\aws-lc-sys-0.21.2\builder/main.rs:315:40:
  called `Result::unwrap()` on an `Err` value: "Required build dependency is missing. Halting build."
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

aws-lc-sys is required by aws-lc-rs@1.9.0 which is required by rustls@0.23.13 which is required by axum-server@0.7.1.

Then I followed what is in here: https://aws.github.io/aws-lc-rs/requirements/windows.html.

I installed C/C++ Compiler and CMake but not NASM and it builds but at the end I get a lot of errors like these:

librustls-01ac9141ee708bf1.rlib(rustls-01ac9141ee708bf1.rustls.78218e420b8f09f3-cgu.13.rcgu.o) : error LNK2001: unresolved external symbol ␁aws_lc_0_21_2_EVP_PKEY_derive_init␍
librustls-01ac9141ee708bf1.rlib(rustls-01ac9141ee708bf1.rustls.78218e420b8f09f3-cgu.13.rcgu.o) : error LNK2001: unresolved external symbol ␁aws_lc_0_21_2_EVP_PKEY_derive_set_peer␍
librustls-01ac9141ee708bf1.rlib(rustls-01ac9141ee708bf1.rustls.78218e420b8f09f3-cgu.13.rcgu.o) : error LNK2001: unresolved external symbol ␁aws_lc_0_21_2_EVP_PKEY_derive␍
librustls-01ac9141ee708bf1.rlib(rustls-01ac9141ee708bf1.rustls.78218e420b8f09f3-cgu.02.rcgu.o) : error LNK2001: unresolved external symbol ␁aws_lc_0_21_2_CRYPTO_memcmp␍
... and a lot more

Everything is fine if I downgrade axum-server to 0.6.0.

Relevant details

justsmth commented 1 week ago

Hello! Thanks for the report. I'm sorry that our build is failing (and our diagnostic output for this seems lacking).

I don't think I've seen an error like this reported before. The functions that the linker is unable to find are defined in C code (e.g., EVP_PKEY_derive_init) so I don't think this is related to our prebuilt NASM objects. But to be sure, you might try installing NASM as well: https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/

One thought I had was that the "prefixing" (e.g, adding the aws_lc_0_21_2_ to the front of function names, etc.) for our build might not be working as expected?

Also, I'm wondering whether you might be able to send us the aws-lc-sys build log from your environment?

-- From your development workspace, run a cargo clean then cargo build; wait for the failure, then search for the aws-lc-sys build log under your workspace directory. It should have a path similar to target\debug\build\aws-lc-sys-XXXXXX\output, where the XXXXXX is some random hex digits. (There will actually be two "aws-lc-sys-XXXXXX" directories, one will have the "build-script-main" executable, but the other will have the output from when the build script was executed.) There should also be a aws_lc_0_21_2_crypto.lib file under target\debug\build\aws-lc-sys-XXXXXX\out\build\artifacts\ that might be helpful to verify that it wasn't place in a diffeerent location.

Thanks for your help!

justsmth commented 5 days ago

It appears the downstream issue has been closed: https://github.com/programatik29/axum-server/issues/152. So, I will close this issue as well.

Feel free to open this issue again if you're still experiencing this failure. Thanks!

frederikhors commented 5 days ago

@justsmth the downstream was closed by myself because this was opened! 🤣

justsmth commented 5 days ago

Oh. Sorry! :-)

Is there any other information you can provide for this? We've been unable to reproduce it. Is it still occurring in your build environment?

frederikhors commented 5 days ago

I'll re-try in a few hours with more time available to better understand (I downgraded for now).