Skip to content

Commit

Permalink
fix targets with zig toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinPerez committed Mar 22, 2024
1 parent bbae474 commit 6494137
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,13 @@ impl Build {

// Target flags
match cmd.family {
ToolFamily::Clang { .. } => {
ToolFamily::Clang { zig_cc } => {
let target = if zig_cc {
Cow::Owned(target.replace("-unknown-", "-"))
} else {
Cow::Borrowed(target)
};

if !cmd.has_internal_target_arg
&& !(target.contains("android")
&& android_clang_compiler_uses_target_arg_internally(&cmd.path))
Expand All @@ -1916,21 +1922,21 @@ impl Build {

if target.contains("darwin") {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
{
cmd.args
.push(format!("--target={}-apple-darwin", arch).into());
}
} else if target.contains("macabi") {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
{
cmd.args
.push(format!("--target={}-apple-ios-macabi", arch).into());
}
} else if target.contains("ios-sim") {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
{
let sdk_details =
apple_os_sdk_parts(AppleOs::Ios, &AppleArchSpec::Simulator(""));
Expand All @@ -1946,7 +1952,7 @@ impl Build {
}
} else if target.contains("watchos-sim") {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
{
let sdk_details =
apple_os_sdk_parts(AppleOs::WatchOs, &AppleArchSpec::Simulator(""));
Expand All @@ -1965,7 +1971,7 @@ impl Build {
}
} else if target.contains("tvos-sim") || target.contains("x86_64-apple-tvos") {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
{
let sdk_details =
apple_os_sdk_parts(AppleOs::TvOs, &AppleArchSpec::Simulator(""));
Expand All @@ -1984,7 +1990,7 @@ impl Build {
}
} else if target.contains("aarch64-apple-tvos") {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
{
let sdk_details =
apple_os_sdk_parts(AppleOs::TvOs, &AppleArchSpec::Device(""));
Expand All @@ -1998,7 +2004,7 @@ impl Build {
);
}
} else if let Ok(index) = target_info::RISCV_ARCH_MAPPING
.binary_search_by_key(&arch, |(arch, _)| &arch)
.binary_search_by_key(&arch, |(arch, _)| arch)
{
cmd.args.push(
format!(
Expand Down

0 comments on commit 6494137

Please sign in to comment.