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

add cross-compilation assistance for linux aarch64 #577

Merged
merged 3 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ separate changelogs for each crate were used. If you need to refer to these old

## [Unreleased]

- libcnb-package: Add cross-compilation assistance for Linux aarch64-unknown-linux-musl

## [0.13.0] 2023-06-21

The highlight of this release is the `cargo libcnb package` changes to support compilation of both buildpacks and meta-buildpacks.
Expand Down
26 changes: 26 additions & 0 deletions libcnb-package/src/cross_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@ The easiest way to install 'musl-gcc' is to install the 'musl-tools' package:
- https://packages.debian.org/bullseye/musl-tools"#,
)),
}
} else if target_triple.as_ref() == AARCH64_UNKNOWN_LINUX_MUSL && cfg!(target_os = "linux") {
let gcc_binary_path = "aarch64-linux-gnu-gcc";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hone Was there a reason this is aarch64-linux-gnu-gcc not aarch64-linux-musl-gcc? We're using MUSL for everything else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #724.

match which(gcc_binary_path) {
Ok(_) => CrossCompileAssistance::Configuration {
cargo_env: vec![
(
OsString::from("CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER"),
OsString::from(gcc_binary_path),
),
(
OsString::from("CC_aarch64_unknown_linux_musl"),
OsString::from(gcc_binary_path),
),
],
},
Err(_) => CrossCompileAssistance::HelpText(String::from(
r#"For cross-compilation from Linux to aarch64-unknown-linux-musl, a C compiler and
linker for the target platform must installed on your computer.

The easiest way to install the 'g++-aarch64-linux-gnu', 'libc6-dev-arm64-cross', and 'musl-tools' packages:
- https://packages.ubuntu.com/focal/g++-aarch64-linux-gnu
- https://packages.ubuntu.com/focal/musl-tools
- https://packages.ubuntu.com/focal/libc6-dev-arm64-cross"#,
)),
}
} else {
CrossCompileAssistance::NoAssistance
}
Expand All @@ -76,4 +101,5 @@ pub enum CrossCompileAssistance {
},
}

const AARCH64_UNKNOWN_LINUX_MUSL: &str = "aarch64-unknown-linux-musl";
const X86_64_UNKNOWN_LINUX_MUSL: &str = "x86_64-unknown-linux-musl";