Skip to content

Commit

Permalink
Add -mcpu option for arm* targets
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Sep 11, 2022
1 parent d5c2834 commit 631691d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ jobs:
run: |
rustup target add aarch64-unknown-linux-gnu
rustup target add arm-unknown-linux-gnueabihf
rustup target add armv7-unknown-linux-gnueabihf
cargo run zigbuild --target aarch64-unknown-linux-gnu
cargo run zigbuild --target aarch64-unknown-linux-gnu.2.17
cargo run zigbuild --target arm-unknown-linux-gnueabihf
cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/hello-rustls/Cargo.toml
cargo run zigbuild --target armv7-unknown-linux-gnueabihf --manifest-path tests/hello-rustls/Cargo.toml
cargo run zigbuild --target arm-unknown-linux-gnueabihf --manifest-path tests/hello-rustls/Cargo.toml
# Test building shared library
cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/libhello/Cargo.toml
Expand Down
25 changes: 21 additions & 4 deletions src/zig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,27 @@ pub fn prepare_zig_linker(target: &str) -> Result<ZigWrapper> {
let zig_cxx = format!("zigcxx-{}.{}", file_target, file_ext);
let cc_args = "-g"; // prevent stripping
let mut cc_args = match triple.operating_system {
OperatingSystem::Linux => format!(
"-target {}-linux-{}{} {}",
arch, target_env, abi_suffix, cc_args,
),
OperatingSystem::Linux => {
let (zig_arch, zig_cpu) = match arch.as_str() {
// zig uses _ instead of - in cpu features
"arm" => match target_env {
Environment::Gnueabi | Environment::Musleabi => {
("arm", "-mcpu=generic+v6+strict_align")
}
Environment::Gnueabihf | Environment::Musleabihf => {
("arm", "-mcpu=generic+v6+strict_align+vfp2-d32")
}
_ => ("arm", ""),
},
"armv5te" => ("arm", "-mcpu=generic+soft_float+strict_align"),
"armv7" => ("arm", "-mcpu=generic+v7a+vfp3-d32+thumb2-neon"),
_ => (arch.as_str(), ""),
};
format!(
"-target {}-linux-{}{} {} {}",
zig_arch, target_env, abi_suffix, zig_cpu, cc_args,
)
}
OperatingSystem::MacOSX { .. } | OperatingSystem::Darwin => {
let zig_version = Zig::zig_version()?;
// Zig 0.10.0 switched macOS ABI to none
Expand Down

0 comments on commit 631691d

Please sign in to comment.