Skip to content

Commit b486397

Browse files
committed
now add a catch all standard lib
1 parent 5e909dd commit b486397

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

build.rs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -907,29 +907,19 @@ fn patch_model_for_full_tflite(model_dir: &Path, use_full_tflite: bool) {
907907
}
908908

909909
fn link_with_standard_library() {
910-
#[cfg(all(target_os = "windows", target_env = "msvc"))]
911-
{
912-
println!("cargo:rustc-link-lib=msvcrt"); // MSVC runtime
913-
}
914-
915-
#[cfg(all(target_os = "windows", target_env = "gnu"))]
916-
{
917-
println!("cargo:rustc-link-lib=stdc++"); // MinGW GNU toolchain
918-
}
919-
920-
#[cfg(all(target_os = "linux", target_env = "gnu"))]
921-
{
910+
if cfg!(target_os = "linux") {
911+
println!("cargo:rustc-link-lib=stdc++");
912+
} else if cfg!(target_os = "macos") {
913+
println!("cargo:rustc-link-lib=c++");
914+
} else if cfg!(target_os = "windows") {
915+
if cfg!(target_env = "msvc") {
916+
println!("cargo:rustc-link-lib=msvcrt");
917+
} else {
918+
println!("cargo:rustc-link-lib=stdc++"); // MinGW
919+
}
920+
} else {
921+
println!("cargo:warning=Unknown platform, defaulting to stdc++");
922922
println!("cargo:rustc-link-lib=stdc++");
923-
}
924-
925-
#[cfg(all(target_os = "linux", target_env = "musl"))]
926-
{
927-
println!("cargo:rustc-link-lib=static=stdc++");
928-
}
929-
930-
#[cfg(target_os = "macos")]
931-
{
932-
println!("cargo:rustc-link-lib=c++"); // macOS uses libc++
933923
}
934924
}
935925

0 commit comments

Comments
 (0)