Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip the linkage of libstdc++ in rustc_llvm #125400

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 2 additions & 36 deletions compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,26 +327,6 @@ fn main() {
}
}

let llvm_static_stdcpp = tracked_env_var_os("LLVM_STATIC_STDCPP");
let llvm_use_libcxx = tracked_env_var_os("LLVM_USE_LIBCXX");

let stdcppname = if target.contains("openbsd") {
if target.contains("sparc64") { "estdc++" } else { "c++" }
} else if target.contains("darwin")
|| target.contains("freebsd")
|| target.contains("windows-gnullvm")
|| target.contains("aix")
{
"c++"
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
// NetBSD uses a separate library when relocation is required
"stdc++_p"
} else if llvm_use_libcxx.is_some() {
"c++"
} else {
"stdc++"
};

// RISC-V GCC erroneously requires libatomic for sub-word
// atomic operations. Some BSD uses Clang as its system
// compiler and provides no libatomic in its base system so
Expand All @@ -355,22 +335,8 @@ fn main() {
println!("cargo:rustc-link-lib=atomic");
}

// C++ runtime library
if !target.contains("msvc") {
if let Some(s) = llvm_static_stdcpp {
assert!(!cxxflags.contains("stdlib=libc++"));
let path = PathBuf::from(s);
println!("cargo:rustc-link-search=native={}", path.parent().unwrap().display());
if target.contains("windows") {
println!("cargo:rustc-link-lib=static:-bundle={stdcppname}");
} else {
println!("cargo:rustc-link-lib=static={stdcppname}");
}
} else if cxxflags.contains("stdlib=libc++") {
println!("cargo:rustc-link-lib=c++");
} else {
println!("cargo:rustc-link-lib={stdcppname}");
}
if !target.contains("msvc") && tracked_env_var_os("LLVM_USE_LIBCXX").is_some() {
println!("cargo:rustc-link-lib=c++");
}

// libc++abi and libunwind have to be specified explicitly on AIX.
Expand Down
17 changes: 0 additions & 17 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,23 +1201,6 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
cargo.env("LLVM_LINKER_FLAGS", llvm_linker_flags);
}

// Building with a static libstdc++ is only supported on linux right now,
// not for MSVC or macOS
if builder.config.llvm_static_stdcpp
&& !target.contains("freebsd")
&& !target.is_msvc()
&& !target.contains("apple")
&& !target.contains("solaris")
{
let file = compiler_file(
builder,
&builder.cxx(target).unwrap(),
target,
CLang::Cxx,
"libstdc++.a",
);
cargo.env("LLVM_STATIC_STDCPP", file);
}
if builder.llvm_link_shared() {
cargo.env("LLVM_LINK_SHARED", "1");
}
Expand Down
Loading