Skip to content

Commit 16bc86f

Browse files
committed
now add a catch all standard lib
1 parent dbb7941 commit 16bc86f

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
@@ -728,29 +728,19 @@ fn patch_model_for_full_tflite(model_dir: &Path, use_full_tflite: bool) {
728728
}
729729

730730
fn link_with_standard_library() {
731-
#[cfg(all(target_os = "windows", target_env = "msvc"))]
732-
{
733-
println!("cargo:rustc-link-lib=msvcrt"); // MSVC runtime
734-
}
735-
736-
#[cfg(all(target_os = "windows", target_env = "gnu"))]
737-
{
738-
println!("cargo:rustc-link-lib=stdc++"); // MinGW GNU toolchain
739-
}
740-
741-
#[cfg(all(target_os = "linux", target_env = "gnu"))]
742-
{
731+
if cfg!(target_os = "linux") {
732+
println!("cargo:rustc-link-lib=stdc++");
733+
} else if cfg!(target_os = "macos") {
734+
println!("cargo:rustc-link-lib=c++");
735+
} else if cfg!(target_os = "windows") {
736+
if cfg!(target_env = "msvc") {
737+
println!("cargo:rustc-link-lib=msvcrt");
738+
} else {
739+
println!("cargo:rustc-link-lib=stdc++"); // MinGW
740+
}
741+
} else {
742+
println!("cargo:warning=Unknown platform, defaulting to stdc++");
743743
println!("cargo:rustc-link-lib=stdc++");
744-
}
745-
746-
#[cfg(all(target_os = "linux", target_env = "musl"))]
747-
{
748-
println!("cargo:rustc-link-lib=static=stdc++");
749-
}
750-
751-
#[cfg(target_os = "macos")]
752-
{
753-
println!("cargo:rustc-link-lib=c++"); // macOS uses libc++
754744
}
755745
}
756746

0 commit comments

Comments
 (0)