Skip to content

Unable to build w/ rustc_codegen_cranelift compiler backend #537

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

Closed
frederikhors opened this issue Sep 25, 2024 · 14 comments
Closed

Unable to build w/ rustc_codegen_cranelift compiler backend #537

frederikhors opened this issue Sep 25, 2024 · 14 comments
Labels
wontfix This will not be worked on

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
@justsmth justsmth added the wontfix This will not be worked on label Nov 22, 2024
@justsmth
Copy link
Contributor

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!

@humaita-github
Copy link

Hi, I am having a similar problem, but when cross-compiling on Ubuntu 24.04. for targets mips-unknown-linux-musl and mipsel-unknown-linux-musl.

I also get tons of messages like this when trying to link.

(...) undefined reference to '␁aws_lc_0_24_1_EVP_DigestUpdate'

Below are the commands to setup cross-compiling build environment and to compile. We need to use +nightly and -Z build-std since mips and mipsel are Tier 3 in Rust.

Any ideas how to fix this? Please let me know if you need detailed log files.

Install SDK for cross-compiling
wget https://downloads.openwrt.org/releases/24.10.0-rc7/targets/ramips/mt7621/openwrt-sdk-24.10.0-rc7-ramips-mt7621_gcc-13.3.0_musl.Linux-x86_64.tar.zst
tar -axf openwrt-sdk-24.10.0-rc7-ramips-mt7621_gcc-13.3.0_musl.Linux-x86_64.tar.zst

Clone repository
git clone https://github.com/humaita-github/librespot-atomic_shim/
cd librespot-atomic_shim/

Setup cross-compilation
TARGET=mipsel-unknown-linux-musl
STAGING_DIR=$HOME/openwrt-sdk-24.10.0-rc7-ramips-mt7621_gcc-13.3.0_musl.Linux-x86_64
TARGET_CC=$STAGING_DIR/staging_dir/toolchain-mipsel_24kc_gcc-13.3.0_musl/bin/mipsel-openwrt-linux-musl-gcc
PATH=$STAGING_DIR/staging_dir/toolchain-mipsel_24kc_gcc-13.3.0_musl/bin:$HOME/.cargo/bin:$PATH

mkdir .cargo
echo -e "[build]\ntarget = \"$TARGET\"\n[target.$TARGET]\nlinker = \"mipsel-openwrt-linux-musl-gcc\"" > .cargo/config.toml
echo -e "[toolchain]\nchannel = \"nightly\"" > ./rust-toolchain.toml

Build
rustup +nightly component add rust-src
cargo build -Z build-std --release --target $TARGET --locked --no-default-features

@Logarithmus
Copy link

Logarithmus commented Feb 21, 2025

For those who encounter this issue, you can just do this:

rustls = { version = "0.23", default-features = false, features = ["ring"] }

For unknown reason, rustls decided to use super slow to compile aws-lc-sys instead of ring. So when you disable default features, it will use ring again.

@simonsan
Copy link

@Logarithmus ring just got an unmaintained advisory: https://rustsec.org/advisories/RUSTSEC-2025-0007.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

7 participants