Skip to content
Open
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
5 changes: 3 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,11 @@ version = "0.1.0"

[[package]]
name = "cc"
version = "1.2.16"
version = "1.2.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c"
checksum = "9f50d563227a1c37cc0a263f64eca3334388c01c5e4c4861a9def205c614383c"
dependencies = [
"find-msvc-tools",
"jobserver",
"libc",
"shlex",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ libc = "0.2.73"
[build-dependencies]
# tidy-alphabetical-start
# `cc` updates often break things, so we pin it here.
cc = "=1.2.16"
cc = "=1.2.50"
shlex = "1.3.0"
# tidy-alphabetical-end

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ pub fn compiler_file(
return PathBuf::new();
}
let mut cmd = command(compiler);
cmd.args(builder.cc_handled_clags(target, c));
cmd.args(builder.cc_handled_cflags(target, c));
cmd.args(builder.cc_unhandled_cflags(target, GitRepo::Rustc, c));
cmd.arg(format!("-print-file-name={file}"));
let out = cmd.run_capture_stdout(builder).stdout();
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ fn configure_cmake(
// Needs `suppressed_compiler_flag_prefixes` to be gone, and hence
// https://github.com/llvm/llvm-project/issues/88780 to be fixed.
for flag in builder
.cc_handled_clags(target, CLang::C)
.cc_handled_cflags(target, CLang::C)
.into_iter()
.chain(builder.cc_unhandled_cflags(target, GitRepo::Llvm, CLang::C))
.filter(|flag| !suppressed_compiler_flag_prefixes.iter().any(|p| flag.starts_with(p)))
Expand All @@ -821,7 +821,7 @@ fn configure_cmake(
cfg.define("CMAKE_C_FLAGS", cflags);
let mut cxxflags = ccflags.cxxflags.clone();
for flag in builder
.cc_handled_clags(target, CLang::Cxx)
.cc_handled_cflags(target, CLang::Cxx)
.into_iter()
.chain(builder.cc_unhandled_cflags(target, GitRepo::Llvm, CLang::Cxx))
.filter(|flag| {
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2428,9 +2428,9 @@ Please disable assertions with `rust.debug-assertions = false`.
// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
if !builder.config.dry_run() && mode == CompiletestMode::RunMake {
let mut cflags = builder.cc_handled_clags(target, CLang::C);
let mut cflags = builder.cc_handled_cflags(target, CLang::C);
cflags.extend(builder.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::C));
let mut cxxflags = builder.cc_handled_clags(target, CLang::Cxx);
let mut cxxflags = builder.cc_handled_cflags(target, CLang::Cxx);
cxxflags.extend(builder.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::Cxx));
cmd.arg("--cc")
.arg(builder.cc(target))
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ impl Build {

/// Returns C flags that `cc-rs` thinks should be enabled for the
/// specified target by default.
fn cc_handled_clags(&self, target: TargetSelection, c: CLang) -> Vec<String> {
fn cc_handled_cflags(&self, target: TargetSelection, c: CLang) -> Vec<String> {
if self.config.dry_run() {
return Vec::new();
}
Expand Down
15 changes: 12 additions & 3 deletions src/bootstrap/src/utils/cc_detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::collections::HashSet;
use std::iter;
use std::path::{Path, PathBuf};

use crate::core::config::TargetSelection;
use crate::core::config::{RustcLto, TargetSelection};
use crate::utils::exec::{BootstrapCommand, command};
use crate::{Build, CLang, GitRepo};

Expand Down Expand Up @@ -53,6 +53,15 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build {
}
}
}
match build.config.rust_lto {
RustcLto::Off | RustcLto::ThinLocal => {}
RustcLto::Thin => {
cfg.flag_if_supported("-flto=thin");
}
RustcLto::Fat => {
cfg.flag_if_supported("-flto=full");
}
}
cfg
}

Expand Down Expand Up @@ -113,7 +122,7 @@ pub fn fill_target_compiler(build: &mut Build, target: TargetSelection) {
};

build.cc.insert(target, compiler.clone());
let mut cflags = build.cc_handled_clags(target, CLang::C);
let mut cflags = build.cc_handled_cflags(target, CLang::C);
cflags.extend(build.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::C));

// If we use llvm-libunwind, we will need a C++ compiler as well for all targets
Expand All @@ -140,7 +149,7 @@ pub fn fill_target_compiler(build: &mut Build, target: TargetSelection) {
build.do_if_verbose(|| println!("CC_{} = {:?}", target.triple, build.cc(target)));
build.do_if_verbose(|| println!("CFLAGS_{} = {cflags:?}", target.triple));
if let Ok(cxx) = build.cxx(target) {
let mut cxxflags = build.cc_handled_clags(target, CLang::Cxx);
let mut cxxflags = build.cc_handled_cflags(target, CLang::Cxx);
cxxflags.extend(build.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::Cxx));
build.do_if_verbose(|| println!("CXX_{} = {cxx:?}", target.triple));
build.do_if_verbose(|| println!("CXXFLAGS_{} = {cxxflags:?}", target.triple));
Expand Down
Loading