cross icon indicating copy to clipboard operation
cross copied to clipboard

aws-lc-sys can't compile

Open Error504TimeOut opened this issue 6 months ago • 7 comments

Checklist

Describe your issue

I'm trying to compile a project, which includes [email protected]. In the Cargo.toml, I'm installing some additional packages. Until compiling aws-lc-sys it also works quite well, however once it does, it fails:

  --- stderr
  Consider installing the bindgen-cli: `cargo install --force --locked bindgen-cli`
  See our User Guide for more information about bindgen:https://aws.github.io/aws-lc-rs/index.html
  Failure invoking external bindgen! External bindgen command failed.

~So far so good, however, when I try to install bindgen-cli, that fails with something along the lines of sh: eval: can't find cargo~ After running again, it seems that this magically resolved, however it still states it can't find bindgen at compile time. I'd say it's some issue on my side, but I'm out of ideas on what to try.

What target(s) are you cross-compiling for?

armv7-unknown-linux-gnueabihf

Which operating system is the host (e.g computer cross is on) running?

  • [ ] macOS
  • [ ] Windows
  • [x] Linux / BSD
  • [ ] other OS (specify in description)

What architecture is the host?

  • [x] x86_64 / AMD64
  • [ ] arm32
  • [ ] arm64 (including Mac M1)

What container engine is cross using?

  • [x] docker
  • [ ] podman
  • [ ] other container engine (specify in description)

cross version

cross 0.2.5 (51f46f2 2025-05-24)

Example

No response

Additional information / notes

Running cargo -V also returns [cross] note: Falling back to cargo on the host.. All other requirements for aws-lc-sys are installed. bindgen-cli is also installed on my host (i use arch btw). AWS_LC_SYS_EXTERNAL_BINDGEN on 0 or 1 does not have an effect. Interestingly enough, when I try to get pre-build to print the path of cargo, it does not return anything, yet the install command does not fail. very weird.

Error504TimeOut avatar Jun 12 '25 18:06 Error504TimeOut

As a workaround for now, I have frankensteined a ubuntu container myself, which works (somehow), so this is not an issue for me personally anymore, but might still be worth to look into, so i'll leave this open for now

Error504TimeOut avatar Jun 12 '25 20:06 Error504TimeOut

I'm having same issue here, I tried to install bindgen-cli on the host and I suppose cross mount cargo/bin PATH into the container but I don't know why it's still the issue

ibigbug avatar Jun 26 '25 16:06 ibigbug

For anyone encountering this one. I got it to work by enabling the bindgen feature for aws-lc-sys and by installing clang-8 inside the build container.

I put this line into my Cargo.toml:

aws-lc-rs = { version = "1", features = ["bindgen"] } # This is a workaround for failing builds on arm. See: https://github.com/rustls/rustls/issues/1788

And added these lines into my Cross.toml:

[build.env]
passthrough = ["BINDGEN_EXTRA_CLANG_ARGS", "BINDGEN_EXTRA_CLANG_ARGS=-I/usr/lib/llvm-8/lib/clang/8.0.0/include"]

[target.armv7-unknown-linux-gnueabihf]
pre-build = [
    "apt update",
    "apt remove --assume-yes libclang1-3.8",
    "apt autoremove --assume-yes",
    "apt install --assume-yes --no-install-recommends clang-8"
]

NOTES:

  • --no-install-recommends for clang-8 is important, otherwise some python2.7 package will throw errors on installation
  • Not sure, if the autoremove is totally necessary, though.
  • I was building rumqttc, which depends on rustls which then uses some version of aws-lc-rs I think.
  • Docker image: ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:0.2.5
  • Cross version: 0.2.5

wiebecommajonas avatar Jun 30 '25 14:06 wiebecommajonas

For me (building conduit), just adding the line

aws-lc-rs = { version = "*", features = ["bindgen"] }

to the Cargo.toml was enough to fix the issue. Note that I already had clang added to the container due to other build requirements. My full Cross.toml (which I have not changed) is:

[build]
pre-build = ["apt-get update && apt-get install --assume-yes --no-install-recommends libclang-10-dev clang-10"]

[target.armv7-unknown-linux-gnueabihf]
image = "ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:main"

[target.armv7-unknown-linux-gnueabihf.env]
passthrough = ["LIBCLANG_PATH=/usr/lib/llvm-10/lib", """BINDGEN_EXTRA_CLANG_ARGS_armv7-unknown-linux-gnueabihf=--sysroot=/usr/arm-linux-gnueabihf -idirafter/usr/include"""]

I am also on cross 0.2.5. I wonder why adding the bindgen feature becomes necessary in the container even though the build works fine without it outside of the container.

phesch avatar Jul 01 '25 09:07 phesch

thanks enabling the bindgen feature helped

in my case I don't depend on aws-lc-rs directly so I made an optional dependency with a feature gate to it and that worked too.

but on freebsd bindgen is still having trouble finding headers

https://github.com/Watfaq/clash-rs/actions/runs/16106296957/job/45442292883?pr=829

and I have

[build]
pre-build = [
    "apt update",
    "apt install -y protobuf-compiler libclang-dev clang build-essential"
]

i'm not sure if i should pass in the BINDGEN related env for that just for bsd while other platforms seem working fine

ibigbug avatar Jul 07 '25 03:07 ibigbug

Getting a similar issue, with target windows: /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/aws-lc-sys-0.29.0/aws-lc/include/openssl/digest.h:60:10: fatal error: 'stdbool.h' file not found

Others platforms are fine if I just do the following in Cross.toml:

[target.armv7-unknown-linux-gnueabihf]
image = "ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:main"

[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main"

[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main"
  • the bindgen feature as said above.

Slixe avatar Jul 14 '25 00:07 Slixe

Took me a while to get my project to compile with cross. The dependency that pulls in aws-lc-sys is rustls the native rust tls library in aws-lc-sys mode and not ring mode. (Another alternative for people may be to use ring for Cryptography)

My final Cross.toml is

# Cross configuration for building the workflow runner for VM targets
# Reference: https://github.com/cross-rs/cross
[build.env]
passthrough = ["BINDGEN_EXTRA_CLANG_ARGS", "BINDGEN_EXTRA_CLANG_ARGS=-I/usr/lib/llvm-13/lib/clang/13.0.0/include"]

[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main"

[target.x86_64-unknown-illumos]
image = "ghcr.io/cross-rs/x86_64-unknown-illumos:main"

[build]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update && apt-get install --assume-yes protobuf-compiler libclang-dev clang build-essential",
    "cargo install --force --locked bindgen-cli",
    "update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100",
    "update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100"
]

This sets the compiler to Clang which does not fail with the memcp error found in #1686 and the bindgen error where a fix is documented here.

Toasterson avatar Nov 01 '25 15:11 Toasterson