about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-01-07 16:25:38 +0100
committerGitHub <noreply@github.com>2019-01-07 16:25:38 +0100
commit5cfc8458847fead508e8986b8e4cc62218dbc93f (patch)
tree689775e85cdb2cd03ca5ca62de72d20177b80022 /src
parent14fb35fa4f6bbcefe8cd28fe5dc3dd53b59a1201 (diff)
parent7306b87f129197177ffac57139839d18fe93a8f6 (diff)
downloadrust-5cfc8458847fead508e8986b8e4cc62218dbc93f.tar.gz
rust-5cfc8458847fead508e8986b8e4cc62218dbc93f.zip
Rollup merge of #57369 - petrhosek:llvm-libcxx, r=alexcrichton
Provide the option to use libc++ even on all platforms

This is the default on platforms which use libc++ as the default C++
library but this option allows using libc++ on others as well.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/compile.rs3
-rw-r--r--src/bootstrap/config.rs4
-rwxr-xr-xsrc/bootstrap/configure.py1
-rw-r--r--src/librustc_llvm/build.rs3
4 files changed, 11 insertions, 0 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 0d2546a0e9c..8bc7c5838ed 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -723,6 +723,9 @@ pub fn build_codegen_backend(builder: &Builder,
             {
                 cargo.env("LLVM_LINK_SHARED", "1");
             }
+            if builder.config.llvm_use_libcxx {
+                cargo.env("LLVM_USE_LIBCXX", "1");
+            }
         }
         _ => panic!("unknown backend: {}", backend),
     }
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 8655cf0eb30..9421817ae6d 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -82,6 +82,8 @@ pub struct Config {
     pub lldb_enabled: bool,
     pub llvm_tools_enabled: bool,
 
+    pub llvm_use_libcxx: bool,
+
     // rust codegen options
     pub rust_optimize: bool,
     pub rust_codegen_units: Option<u32>,
@@ -252,6 +254,7 @@ struct Llvm {
     link_shared: Option<bool>,
     version_suffix: Option<String>,
     clang_cl: Option<String>,
+    use_libcxx: Option<bool>,
 }
 
 #[derive(Deserialize, Default, Clone)]
@@ -513,6 +516,7 @@ impl Config {
             config.llvm_link_jobs = llvm.link_jobs;
             config.llvm_version_suffix = llvm.version_suffix.clone();
             config.llvm_clang_cl = llvm.clang_cl.clone();
+            set(&mut config.llvm_use_libcxx, llvm.use_libcxx);
         }
 
         if let Some(ref rust) = toml.rust {
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index d13a3dc7834..b0c3c970249 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -62,6 +62,7 @@ o("full-tools", None, "enable all tools")
 o("lld", "rust.lld", "build lld")
 o("lldb", "rust.lldb", "build lldb")
 o("missing-tools", "dist.missing-tools", "allow failures when building tools")
+o("use-libcxx", "llvm.use_libcxx", "build LLVM with libc++")
 
 # Optimization and debugging options. These may be overridden by the release
 # channel, etc.
diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs
index 98cf20a7ba7..d4a3ae273fc 100644
--- a/src/librustc_llvm/build.rs
+++ b/src/librustc_llvm/build.rs
@@ -236,6 +236,7 @@ fn main() {
     }
 
     let llvm_static_stdcpp = env::var_os("LLVM_STATIC_STDCPP");
+    let llvm_use_libcxx = env::var_os("LLVM_USE_LIBCXX");
 
     let stdcppname = if target.contains("openbsd") {
         // llvm-config on OpenBSD doesn't mention stdlib=libc++
@@ -245,6 +246,8 @@ fn main() {
     } else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
         // NetBSD uses a separate library when relocation is required
         "stdc++_pic"
+    } else if llvm_use_libcxx.is_some() {
+        "c++"
     } else {
         "stdc++"
     };