Skip to content

Commit 374e943

Browse files
committed
skip the linkage of libstdc++ in rustc_llvm
Since we already statically link to libLLVM.so (which includes libstdc++), we shouldn't need to link libstdc++ again for rustc_llvm. Signed-off-by: onur-ozkan <[email protected]>
1 parent e875391 commit 374e943

File tree

2 files changed

+0
-39
lines changed

2 files changed

+0
-39
lines changed

compiler/rustc_llvm/build.rs

-22
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ fn main() {
327327
}
328328
}
329329

330-
let llvm_static_stdcpp = tracked_env_var_os("LLVM_STATIC_STDCPP");
331330
let llvm_use_libcxx = tracked_env_var_os("LLVM_USE_LIBCXX");
332331

333332
let stdcppname = if target.contains("openbsd") {
@@ -338,9 +337,6 @@ fn main() {
338337
|| target.contains("aix")
339338
{
340339
"c++"
341-
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
342-
// NetBSD uses a separate library when relocation is required
343-
"stdc++_p"
344340
} else if llvm_use_libcxx.is_some() {
345341
"c++"
346342
} else {
@@ -355,24 +351,6 @@ fn main() {
355351
println!("cargo:rustc-link-lib=atomic");
356352
}
357353

358-
// C++ runtime library
359-
if !target.contains("msvc") {
360-
if let Some(s) = llvm_static_stdcpp {
361-
assert!(!cxxflags.contains("stdlib=libc++"));
362-
let path = PathBuf::from(s);
363-
println!("cargo:rustc-link-search=native={}", path.parent().unwrap().display());
364-
if target.contains("windows") {
365-
println!("cargo:rustc-link-lib=static:-bundle={stdcppname}");
366-
} else {
367-
println!("cargo:rustc-link-lib=static={stdcppname}");
368-
}
369-
} else if cxxflags.contains("stdlib=libc++") {
370-
println!("cargo:rustc-link-lib=c++");
371-
} else {
372-
println!("cargo:rustc-link-lib={stdcppname}");
373-
}
374-
}
375-
376354
// libc++abi and libunwind have to be specified explicitly on AIX.
377355
if target.contains("aix") {
378356
println!("cargo:rustc-link-lib=c++abi");

src/bootstrap/src/core/build_steps/compile.rs

-17
Original file line numberDiff line numberDiff line change
@@ -1201,23 +1201,6 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
12011201
cargo.env("LLVM_LINKER_FLAGS", llvm_linker_flags);
12021202
}
12031203

1204-
// Building with a static libstdc++ is only supported on linux right now,
1205-
// not for MSVC or macOS
1206-
if builder.config.llvm_static_stdcpp
1207-
&& !target.contains("freebsd")
1208-
&& !target.is_msvc()
1209-
&& !target.contains("apple")
1210-
&& !target.contains("solaris")
1211-
{
1212-
let file = compiler_file(
1213-
builder,
1214-
&builder.cxx(target).unwrap(),
1215-
target,
1216-
CLang::Cxx,
1217-
"libstdc++.a",
1218-
);
1219-
cargo.env("LLVM_STATIC_STDCPP", file);
1220-
}
12211204
if builder.llvm_link_shared() {
12221205
cargo.env("LLVM_LINK_SHARED", "1");
12231206
}

0 commit comments

Comments
 (0)