Skip to content

Commit fa101f5

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 fa101f5

File tree

2 files changed

+0
-53
lines changed

2 files changed

+0
-53
lines changed

compiler/rustc_llvm/build.rs

-36
Original file line numberDiff line numberDiff line change
@@ -327,26 +327,8 @@ 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

333-
let stdcppname = if target.contains("openbsd") {
334-
if target.contains("sparc64") { "estdc++" } else { "c++" }
335-
} else if target.contains("darwin")
336-
|| target.contains("freebsd")
337-
|| target.contains("windows-gnullvm")
338-
|| target.contains("aix")
339-
{
340-
"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"
344-
} else if llvm_use_libcxx.is_some() {
345-
"c++"
346-
} else {
347-
"stdc++"
348-
};
349-
350332
// RISC-V GCC erroneously requires libatomic for sub-word
351333
// atomic operations. Some BSD uses Clang as its system
352334
// compiler and provides no libatomic in its base system so
@@ -355,24 +337,6 @@ fn main() {
355337
println!("cargo:rustc-link-lib=atomic");
356338
}
357339

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-
376340
// libc++abi and libunwind have to be specified explicitly on AIX.
377341
if target.contains("aix") {
378342
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)