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

libcnb-cargo: Set default target triple based on host architecture #843

Open
edmorley opened this issue Jul 18, 2024 · 0 comments
Open

libcnb-cargo: Set default target triple based on host architecture #843

edmorley opened this issue Jul 18, 2024 · 0 comments

Comments

@edmorley
Copy link
Member

By default, if I run cargo libcnb package on my M1 Macbook, I get:

buildpacks-python $ cargo libcnb package
🚚 Preparing package directory...
πŸ–₯️ Gathering Cargo configuration (for x86_64-unknown-linux-musl)
For cross-compilation from aarch64 macos to x86_64-unknown-linux-musl,
a C compiler and linker for the target platform must be installed:

To install an x86_64 cross-compiler on macOS:
brew install messense/macos-cross-toolchains/x86_64-unknown-linux-musl

You will also need to install the Rust target:
rustup target add x86_64-unknown-linux-musl

❌ Failed to configure Cargo for cross-compilation

I have to instead run this every time:

$ cargo libcnb package --target aarch64-unknown-linux-musl

Now that we're in an era of multi-arch builder images (both for Heroku and Paketo), I think libcnb's development workflows should default to using the host architecture rather than hardcoding x86_64 here:

/// Build for the target triple
#[arg(long, default_value = "x86_64-unknown-linux-musl")]

This will mean that anyone is both developing against a single-arch builder, and also has an ARM machine will need to explicitly pass --target x86_64-unknown-linux-musl - however, we should favour making the multi-arch path the happy path rather than vice versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant