Skip to content

Commit 6494137

Browse files
committed
fix targets with zig toolchain
1 parent bbae474 commit 6494137

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/lib.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,7 +1902,13 @@ impl Build {
19021902

19031903
// Target flags
19041904
match cmd.family {
1905-
ToolFamily::Clang { .. } => {
1905+
ToolFamily::Clang { zig_cc } => {
1906+
let target = if zig_cc {
1907+
Cow::Owned(target.replace("-unknown-", "-"))
1908+
} else {
1909+
Cow::Borrowed(target)
1910+
};
1911+
19061912
if !cmd.has_internal_target_arg
19071913
&& !(target.contains("android")
19081914
&& android_clang_compiler_uses_target_arg_internally(&cmd.path))
@@ -1916,21 +1922,21 @@ impl Build {
19161922

19171923
if target.contains("darwin") {
19181924
if let Some(arch) =
1919-
map_darwin_target_from_rust_to_compiler_architecture(target)
1925+
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
19201926
{
19211927
cmd.args
19221928
.push(format!("--target={}-apple-darwin", arch).into());
19231929
}
19241930
} else if target.contains("macabi") {
19251931
if let Some(arch) =
1926-
map_darwin_target_from_rust_to_compiler_architecture(target)
1932+
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
19271933
{
19281934
cmd.args
19291935
.push(format!("--target={}-apple-ios-macabi", arch).into());
19301936
}
19311937
} else if target.contains("ios-sim") {
19321938
if let Some(arch) =
1933-
map_darwin_target_from_rust_to_compiler_architecture(target)
1939+
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
19341940
{
19351941
let sdk_details =
19361942
apple_os_sdk_parts(AppleOs::Ios, &AppleArchSpec::Simulator(""));
@@ -1946,7 +1952,7 @@ impl Build {
19461952
}
19471953
} else if target.contains("watchos-sim") {
19481954
if let Some(arch) =
1949-
map_darwin_target_from_rust_to_compiler_architecture(target)
1955+
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
19501956
{
19511957
let sdk_details =
19521958
apple_os_sdk_parts(AppleOs::WatchOs, &AppleArchSpec::Simulator(""));
@@ -1965,7 +1971,7 @@ impl Build {
19651971
}
19661972
} else if target.contains("tvos-sim") || target.contains("x86_64-apple-tvos") {
19671973
if let Some(arch) =
1968-
map_darwin_target_from_rust_to_compiler_architecture(target)
1974+
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
19691975
{
19701976
let sdk_details =
19711977
apple_os_sdk_parts(AppleOs::TvOs, &AppleArchSpec::Simulator(""));
@@ -1984,7 +1990,7 @@ impl Build {
19841990
}
19851991
} else if target.contains("aarch64-apple-tvos") {
19861992
if let Some(arch) =
1987-
map_darwin_target_from_rust_to_compiler_architecture(target)
1993+
map_darwin_target_from_rust_to_compiler_architecture(target.as_ref())
19881994
{
19891995
let sdk_details =
19901996
apple_os_sdk_parts(AppleOs::TvOs, &AppleArchSpec::Device(""));
@@ -1998,7 +2004,7 @@ impl Build {
19982004
);
19992005
}
20002006
} else if let Ok(index) = target_info::RISCV_ARCH_MAPPING
2001-
.binary_search_by_key(&arch, |(arch, _)| &arch)
2007+
.binary_search_by_key(&arch, |(arch, _)| arch)
20022008
{
20032009
cmd.args.push(
20042010
format!(

0 commit comments

Comments
 (0)