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

Pass LLVM linker flags to librustc_llvm build #61704

Merged
merged 1 commit into from
Jun 16, 2019
Merged
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
4 changes: 4 additions & 0 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,10 @@ pub fn build_codegen_backend(builder: &Builder<'_>,
cargo.env("CFG_LLVM_ROOT", s);
}
}
// Some LLVM linker flags (-L and -l) may be needed to link librustc_llvm.
if let Some(ref s) = builder.config.llvm_ldflags {
petrhosek marked this conversation as resolved.
Show resolved Hide resolved
cargo.env("LLVM_LINKER_FLAGS", s);
}
// Building with a static libstdc++ is only supported on linux right now,
// not for MSVC or macOS
if builder.config.llvm_static_stdcpp &&
Expand Down
15 changes: 15 additions & 0 deletions src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,21 @@ fn main() {
}
}

// Some LLVM linker flags (-L and -l) may be needed even when linking
// librustc_llvm, for example when using static libc++, we may need to
// manually specify the library search path and -ldl -lpthread as link
// dependencies.
let llvm_linker_flags = env::var_os("LLVM_LINKER_FLAGS");
petrhosek marked this conversation as resolved.
Show resolved Hide resolved
if let Some(s) = llvm_linker_flags {
for lib in s.into_string().unwrap().split_whitespace() {
if lib.starts_with("-l") {
println!("cargo:rustc-link-lib={}", &lib[2..]);
} else if lib.starts_with("-L") {
println!("cargo:rustc-link-search=native={}", &lib[2..]);
}
}
}

let llvm_static_stdcpp = env::var_os("LLVM_STATIC_STDCPP");
let llvm_use_libcxx = env::var_os("LLVM_USE_LIBCXX");

Expand Down