Skip to content

Commit eae5b8e

Browse files
committed
bender-slang(build): Link stdlibc++ dynamically by default
1 parent 486f11f commit eae5b8e

2 files changed

Lines changed: 1 addition & 30 deletions

File tree

.cargo/config.toml.iis

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[target.x86_64-unknown-linux-gnu]
22
linker = "/usr/pack/gcc-14.2.0-af/bin/gcc"
3+
rustflags = ["-C", "link-arg=-Wl,-rpath,/usr/pack/gcc-14.2.0-af/lib64"]
34

45
[env]
56
CC = "/usr/pack/gcc-14.2.0-af/bin/gcc"

crates/bender-slang/build.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -94,36 +94,6 @@ fn main() {
9494
.include("vendor/slang/external")
9595
.include(dst.join("include"));
9696

97-
// Linux: we try static linking of libstdc++ to avoid issues on older distros.
98-
if target_os == "linux" {
99-
// Determine the C++ compiler to use. Respect the CXX environment variable if set.
100-
let compiler = std::env::var("CXX").unwrap_or_else(|_| "g++".to_string());
101-
// We search for the static libstdc++ file using g++
102-
let output = std::process::Command::new(&compiler)
103-
.args(&["-print-file-name=libstdc++.a"])
104-
.output()
105-
.expect("Failed to run g++");
106-
107-
if output.status.success() {
108-
let path_str = std::str::from_utf8(&output.stdout).unwrap().trim();
109-
let path = std::path::Path::new(path_str);
110-
111-
if path.is_absolute() && path.exists() {
112-
if let Some(parent) = path.parent() {
113-
// Add the directory containing libstdc++.a to the link search path
114-
println!("cargo:rustc-link-search=native={}", parent.display());
115-
}
116-
117-
bridge_build.cpp_set_stdlib(None);
118-
println!("cargo:rustc-link-lib=static=stdc++");
119-
} else {
120-
println!(
121-
"cargo:warning=Could not find static libstdc++.a, falling back to dynamic linking"
122-
);
123-
}
124-
}
125-
}
126-
12797
// Apply common defines and flags to the bridge build as well
12898
for (def, value) in common_cxx_defines.iter() {
12999
bridge_build.define(def, *value);

0 commit comments

Comments
 (0)