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
318 stars 49 forks source link

Unable to build w/ rustc_codegen_cranelift compiler backend #537

Closed frederikhors closed 2 days ago

frederikhors commented 2 months 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 2 months 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 1 month 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 1 month ago

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

justsmth commented 1 month 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 1 month ago

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

nkokorev commented 1 month ago

Hello! I had the same problem on Windows 10. I tried different versions of cmake, VS Build Tools, it didn't help. There were no problems on the mac.

Fixed after downgraded library versions:

rustls = "0.23.14"  -> "0.22.4" 
tokio-rustls = "0.26" -> "0.25.0"
justinwsmith commented 1 month ago

I had the same problem on Windows 10.

I have Windows 11. I tried uninstalling then reinstalling all of the VS build tools and CMake to see whether I could reproduce this problem. (I chose the Desktop development w/ C++ workload for the installation.) I did get the Missing dependency: cmake error to happen prior to installing CMake, but the build succeeded once I installed it.

I'm wondering whether this problem might be specific to Windows 10. Could that be the case? Any other information you can provide about this would be appreciated. Thanks!

frederikhors commented 1 month ago

I don't think this has something to do with Windows 10 instead of Windows 11.

I just found out the reason (maybe).

I'm using https://github.com/rust-lang/rustc_codegen_cranelift for development and the error appears only with it.

Without it works.

You decide, @justinwsmith, whether to close this issue or not.

justsmth commented 1 month ago

Ok, it looks like someone may have figured out the issue: https://github.com/rust-lang/rustc_codegen_cranelift/issues/1520#issuecomment-2254213030

justsmth commented 1 month ago

Hello -- I updated the title of this issue to reflect that the issue is with using the rustc_codegen_cranelift compiler backend.

justsmth commented 2 days ago

Hello!

I don't see any action that we can take to correct this, so I will close it for now. Feel free to reopen (or open a new issue) if there are specific actions you'd like for us to consider for this. Thanks again for letting us know about this problem!