]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/native.rs
Rollup merge of #95058 - wcampbell0x2a:use-then-in-unix-process, r=dtolnay
[rust.git] / src / bootstrap / native.rs
index a751a6e3ece7f918ab2df0860c190daca1c5f915..a810a57feb7bb98b88440d109e1c1b579704226e 100644 (file)
 use std::path::{Path, PathBuf};
 use std::process::Command;
 
-use build_helper::{output, t};
-
 use crate::builder::{Builder, RunConfig, ShouldRun, Step};
 use crate::config::TargetSelection;
-use crate::util::{self, exe};
+use crate::util::{self, exe, output, t, up_to_date};
 use crate::{CLang, GitRepo};
-use build_helper::up_to_date;
 
 pub struct Meta {
     stamp: HashStamp,
@@ -262,18 +259,6 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
             cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
         }
 
-        // For distribution we want the LLVM tools to be *statically* linked to libstdc++.
-        // We also do this if the user explicitly requested static libstdc++.
-        if builder.config.llvm_tools_enabled || builder.config.llvm_static_stdcpp {
-            if !target.contains("msvc") && !target.contains("netbsd") {
-                if target.contains("apple") {
-                    ldflags.push_all("-static-libstdc++");
-                } else {
-                    ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++");
-                }
-            }
-        }
-
         if target.starts_with("riscv") && !target.contains("freebsd") {
             // RISC-V GCC erroneously requires linking against
             // `libatomic` when using 1-byte and 2-byte C++
@@ -579,6 +564,18 @@ fn configure_cmake(
         ldflags.push_all(&flags);
     }
 
+    // For distribution we want the LLVM tools to be *statically* linked to libstdc++.
+    // We also do this if the user explicitly requested static libstdc++.
+    if builder.config.llvm_static_stdcpp {
+        if !target.contains("msvc") && !target.contains("netbsd") {
+            if target.contains("apple") {
+                ldflags.push_all("-static-libstdc++");
+            } else {
+                ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++");
+            }
+        }
+    }
+
     cfg.define("CMAKE_SHARED_LINKER_FLAGS", &ldflags.shared);
     cfg.define("CMAKE_MODULE_LINKER_FLAGS", &ldflags.module);
     cfg.define("CMAKE_EXE_LINKER_FLAGS", &ldflags.exe);
@@ -653,8 +650,16 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
         // there's probably a lot of reasons you can't do that other than this.
         let llvm_config_shim = env::current_exe().unwrap().with_file_name("llvm-config-wrapper");
 
+        // Re-use the same flags as llvm to control the level of debug information
+        // generated for lld.
+        let profile = match (builder.config.llvm_optimize, builder.config.llvm_release_debuginfo) {
+            (false, _) => "Debug",
+            (true, false) => "Release",
+            (true, true) => "RelWithDebInfo",
+        };
+
         cfg.out_dir(&out_dir)
-            .profile("Release")
+            .profile(profile)
             .env("LLVM_CONFIG_REAL", &llvm_config)
             .define("LLVM_CONFIG_PATH", llvm_config_shim)
             .define("LLVM_INCLUDE_TESTS", "OFF");