Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build w/ rustc_codegen_cranelift compiler backend #537

Open
frederikhors opened this issue Sep 25, 2024 · 10 comments
Open

Unable to build w/ rustc_codegen_cranelift compiler backend #537

frederikhors opened this issue Sep 25, 2024 · 10 comments

Comments

@frederikhors
Copy link

frederikhors commented Sep 25, 2024

Problem:

From rustls/rustls#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 [email protected] which is required by [email protected] which is required by [email protected].

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

  • CPU architecture: x86-64
  • CPU name: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
  • OS: Windows 10 x64
@justsmth
Copy link
Contributor

justsmth commented Sep 25, 2024

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
Copy link
Contributor

It appears the downstream issue has been closed: programatik29/axum-server#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
Copy link
Author

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

@justsmth justsmth reopened this Sep 30, 2024
@justsmth
Copy link
Contributor

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
Copy link
Author

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

@nkokorev
Copy link

nkokorev commented Oct 6, 2024

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

justsmth commented Oct 7, 2024

Ok, it looks like someone may have figured out the issue: rust-lang/rustc_codegen_cranelift#1520 (comment)

@justsmth justsmth changed the title Unable to build aws-lc-sys on Windows Unable to build w/ rustc_codegen_cranelift compiler backend Oct 9, 2024
@justsmth
Copy link
Contributor

justsmth commented Oct 9, 2024

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

@justsmth justsmth changed the title Unable to build w/ rustc_codegen_cranelift compiler backend Unable to build w/ rustc_codegen_cranelift compiler backend Oct 9, 2024
@justsmth justsmth changed the title Unable to build w/ rustc_codegen_cranelift compiler backend Unable to build w/ rustc_codegen_cranelift compiler backend Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants