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

botan-src does not respect cargo's target triple when invoking configure.py #128

Open
olvrlrnz opened this issue Sep 11, 2024 · 0 comments

Comments

@olvrlrnz
Copy link

I'm trying to build a binary on my Apple Silicon mac mini which depends on botan-rs with enabled features vendored and botan3. Since we want to create a universal binary with lipo, we have to build targets aarch64-apple-darwin and x86_64-apple-darwin.

When botan-src builds the C library, it calls configure.py but the target initially passed to cargo is completely ignored.
Although there is a list of options that can be overridden with BOTAN_CONFIGURE_ env vars, I think --os and --cpu should be set depending on cargo --target and not via BOTAN_CONFIGURE_CPU and BOTAN_CONFIGURE_OS. I cannot think of any situation where setting CPU and OS to something other than what has been passed in --target would make sense.

Dumping the environment in pub fn build() -> (String, String) shows

CARGO_CFG_TARGET_ARCH=aarch64
CARGO_CFG_TARGET_ENDIAN=little
CARGO_CFG_TARGET_ENV=
CARGO_CFG_TARGET_FAMILY=unix
CARGO_CFG_TARGET_OS=macos
CARGO_CFG_TARGET_POINTER_WIDTH=64
CARGO_CFG_TARGET_VENDOR=apple
CARGO_CFG_UNIX=
...
TARGET=aarch64-apple-darwin

So the build script definitely knows what should be built, but doesn't pass the information to configure.py.

  • What I did:

$ cargo build -p botan --features vendored,botan3 --target x86_64-apple-darwin
  • What I expected:

The library is built for x86_64

  • What actually happened:

The library was built for aarch64 according to ld and the log file

   INFO: configure.py invoked with options "--with-build-dir=/Users/username/src/work/botan-rs/target/debug/build/botan-sys-b2a7d959a11e9080/out/botan --build-targets=static --without-documentation --no-install-python-module --distribution-info=https://crates.io/crates/botan-src --with-debug-info"
   INFO: Configuring to build Botan 3.5.0 (revision git:2e5c7d3eb0dcb63d087fc3e7c92010aa82509bbf)
   INFO: Python version: "3.12.5 (main, Aug  6 2024, 19:08:49) [Clang 15.0.0 (clang-1500.3.9.4)]"
   INFO: Autodetected platform information: OS="Darwin" machine="arm64" proc="arm"
   INFO: Guessing target OS is darwin (use --os to set)
   INFO: Guessing to use compiler xcode (use --cc or CXX to set)
   INFO: Guessing target processor is a arm64 (use --cpu to set)
   INFO: Using /etc/ssl/cert.pem as system certificate store
   INFO: Auto-detected compiler version xcode 15.3
   INFO: Auto-detected compiler arch arm64
   INFO: Target is xcode:15.3-macos-arm64
   INFO: Assuming target arm64 is little endian
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

1 participant