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

Build fails due to external bindgen dependency in aws-lc-rs (x86 to arm) #1368

Closed
ansemjo opened this issue Oct 11, 2024 · 1 comment
Closed
Labels

Comments

@ansemjo
Copy link

ansemjo commented Oct 11, 2024

Description

I am building librespot as part of a buildroot configuration for a Raspberry Pi Zero W and using the current dev commit 1ac238e fails due to the "custom build command for aws-lc-sys v0.21.2".

Error output
The following warnings were emitted during compilation:

warning: CMAKE environment variable set: cmake
warning: Generating bindings - external bindgen. Platform: arm-unknown-linux-gnueabihf

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

Caused by:
  process didn't exit successfully: `/dacspot/buildroot-2024.02.5/output/build/librespot-dev/target/release/build/aws-lc-sys-a46c324d9798eef6/build-script-main` (exit status: 101)
  --- 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:rerun-if-env-changed=AWS_LC_SYS_CMAKE_BUILDER
  cargo:rerun-if-env-changed=AWS_LC_SYS_STATIC
  cargo:rerun-if-env-changed=CMAKE
  cargo:rerun-if-env-changed=CMAKE
  cargo:warning=CMAKE environment variable set: cmake
  cargo:warning=Generating bindings - external bindgen. Platform: arm-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=AWS_LC_SYS_INCLUDES

  --- stderr
  bindgen-cli was used. Detected version was: 0.60.1 
  If this is not the latest version, consider upgrading : `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! 

  bindgen-PARAMS: --prefix-link-name aws_lc_0_21_2_ --allowlist-file .*(/|\\)openssl((/|\\)[^/\\]+)+\.h --allowlist-file .*(/|\\)rust_wrapper\.h --rustified-enum point_conversion_form_t --default-macro-constant-type signed --with-derive-default --with-derive-partialeq --with-derive-eq --raw-line 
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  // SPDX-License-Identifier: Apache-2.0 OR ISC
   --generate functions,types,vars,methods,constructors,destructors /dacspot/buildroot-2024.02.5/output/build/librespot-dev/VENDOR/aws-lc-sys/include/rust_wrapper.h --rust-target 1.59 --output /dacspot/buildroot-2024.02.5/output/build/librespot-dev/target/arm-unknown-linux-gnueabihf/release/build/aws-lc-sys-da45e5a6cee12077/out/bindings.rs --formatter rustfmt -- -I /dacspot/buildroot-2024.02.5/output/build/librespot-dev/VENDOR/aws-lc-sys/include -I /dacspot/buildroot-2024.02.5/output/build/librespot-dev/VENDOR/aws-lc-sys/aws-lc/include
  bindgen-STDOUT: 
  bindgen-STDERR: error: Found argument '--prefix-link-name' which wasn't expected, or isn't valid in this context

  	If you tried to supply `--prefix-link-name` as a value rather than a flag, use `-- --prefix-link-name`

  USAGE:
      bindgen [FLAGS] [OPTIONS] <header> -- <clang-args>...

  For more information try --help

  thread 'main' panicked at /dacspot/buildroot-2024.02.5/output/build/librespot-dev/VENDOR/aws-lc-sys/builder/main.rs:559:5:
  aws-lc-sys build failed. Please enable the 'bindgen' feature on aws-lc-rs or aws-lc-sys.For more information, see the aws-lc-rs User Guide: https://aws.github.io/aws-lc-rs/index.html
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Using a commit before 3e85d77 ("Update hyper-rustls to 0.27.2") or installing bindgen on the host system with cargo install --force --locked bindgen-cli, as suggested by the error message, succeeds.

The message links to https://aws.github.io/aws-lc-rs/platform_support.html and asks to enable the bindgen feature on the crate, though I don't know my way around Rust well enough to figure out how to do that for a dependency of another package.

Possibly related but I'm not sure because the errors are different: #1326, #1346

I also found #1318 but I'm not sure how to integrate that in the buildroot configuration cleanly. Is there a way around this that avoids these additional dependencies on the host?

Version

Current dev branch, since commit 3e85d77.

How to reproduce

I'm sure there is a simpler reproducer but this is the exact environment I'm currently building in (without needing to build all of buildroot first):

  • Checkout branch systemd / commit 2f1a221 of dacspot
  • Start a Debian 12 container with docker run --rm -it -v "$PWD:/dacspot" -w /dacspot debian:12
  • Then within the container:
tar xf buildroot-2024.02.5.tar.gz
cd buildroot-2024.02.5/
make BR2_EXTERNAL=../ dacspot_defconfig
make librespot-rebuild

Host (what you are running building librespot on):

  • OS: Linux 6.11.2-arch1-1 --> Docker: Debian 12
  • Platform: x86_64, cross-compiling to arm (Raspberry Pi Zero W) within buildroot-2024.02.5
  • Cargo: cargo 1.74.1 (ecb9851af 2023-10-18), as far as I can tell
@ansemjo ansemjo added the bug label Oct 11, 2024
@ansemjo
Copy link
Author

ansemjo commented Oct 11, 2024

Aha! The bindgen-cli is already packaged for buildroot, so (I thought) I just need to add it as a dependency in my package/librespot/librespot.mk:

LIBRESPOT_DEPENDENCIES = host-rust-bindgen

Unfortunately, the packaged version 0.65.1 is still too old and I needed to patch rust-bindgen.{mk,hash} manually. But with RUST_BINDGEN_VERSION = 0.70.1 and an appropriate hash I can now compile librespot all within the buildroot framework.


Since my particular problem is now solved, I'll close this issue. I'll leave it up to you if you want to reopen for other cross-compilation use(r)s. ☺️

@ansemjo ansemjo closed this as completed Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant