Skip to content

Commit d8e93c7

Browse files
committed
Rename [default|extra]_cflags -> cc_[|un]handled_clags
Makes it explicit that these are in relation to the cc-rs crate.
1 parent 9fa819e commit d8e93c7

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1582,8 +1582,8 @@ pub fn compiler_file(
15821582
return PathBuf::new();
15831583
}
15841584
let mut cmd = command(compiler);
1585-
cmd.args(builder.default_cflags(target, c));
1586-
cmd.args(builder.extra_cflags(target, GitRepo::Rustc, c));
1585+
cmd.args(builder.cc_handled_clags(target, c));
1586+
cmd.args(builder.cc_unhandled_cflags(target, GitRepo::Rustc, c));
15871587
cmd.arg(format!("-print-file-name={file}"));
15881588
let out = cmd.run_capture_stdout(builder).stdout();
15891589
PathBuf::from(out.trim())

src/bootstrap/src/core/build_steps/llvm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,9 @@ fn configure_cmake(
763763
// Needs `suppressed_compiler_flag_prefixes` to be gone, and hence
764764
// https://github.com/llvm/llvm-project/issues/88780 to be fixed.
765765
let mut cflags: OsString = builder
766-
.default_cflags(target, CLang::C)
766+
.cc_handled_clags(target, CLang::C)
767767
.into_iter()
768-
.chain(builder.extra_cflags(target, GitRepo::Llvm, CLang::C))
768+
.chain(builder.cc_unhandled_cflags(target, GitRepo::Llvm, CLang::C))
769769
.filter(|flag| {
770770
!suppressed_compiler_flag_prefixes
771771
.iter()
@@ -784,9 +784,9 @@ fn configure_cmake(
784784
}
785785
cfg.define("CMAKE_C_FLAGS", cflags);
786786
let mut cxxflags: OsString = builder
787-
.default_cflags(target, CLang::Cxx)
787+
.cc_handled_clags(target, CLang::Cxx)
788788
.into_iter()
789-
.chain(builder.extra_cflags(target, GitRepo::Llvm, CLang::Cxx))
789+
.chain(builder.cc_unhandled_cflags(target, GitRepo::Llvm, CLang::Cxx))
790790
.filter(|flag| {
791791
!suppressed_compiler_flag_prefixes
792792
.iter()

src/bootstrap/src/core/build_steps/test.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2005,10 +2005,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
20052005
// Only pass correct values for these flags for the `run-make` suite as it
20062006
// requires that a C++ compiler was configured which isn't always the case.
20072007
if !builder.config.dry_run() && mode == "run-make" {
2008-
let mut cflags = builder.default_cflags(target, CLang::C);
2009-
cflags.extend(builder.extra_cflags(target, GitRepo::Rustc, CLang::C));
2010-
let mut cxxflags = builder.default_cflags(target, CLang::Cxx);
2011-
cxxflags.extend(builder.extra_cflags(target, GitRepo::Rustc, CLang::Cxx));
2008+
let mut cflags = builder.cc_handled_clags(target, CLang::C);
2009+
cflags.extend(builder.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::C));
2010+
let mut cxxflags = builder.cc_handled_clags(target, CLang::Cxx);
2011+
cxxflags.extend(builder.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::Cxx));
20122012
cmd.arg("--cc")
20132013
.arg(builder.cc(target))
20142014
.arg("--cxx")

src/bootstrap/src/core/builder/cargo.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl Cargo {
317317
let cc = ccacheify(&builder.cc(target));
318318
self.command.env(format!("CC_{triple_underscored}"), &cc);
319319

320-
let cflags = builder.extra_cflags(target, GitRepo::Rustc, CLang::C).join(" ");
320+
let cflags = builder.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::C).join(" ");
321321
self.command.env(format!("CFLAGS_{triple_underscored}"), &cflags);
322322

323323
if let Some(ar) = builder.ar(target) {
@@ -329,7 +329,8 @@ impl Cargo {
329329

330330
if let Ok(cxx) = builder.cxx(target) {
331331
let cxx = ccacheify(&cxx);
332-
let cxxflags = builder.extra_cflags(target, GitRepo::Rustc, CLang::Cxx).join(" ");
332+
let cxxflags =
333+
builder.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::Cxx).join(" ");
333334
self.command
334335
.env(format!("CXX_{triple_underscored}"), &cxx)
335336
.env(format!("CXXFLAGS_{triple_underscored}"), cxxflags);

src/bootstrap/src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ Executed at: {executed_at}"#,
11421142

11431143
/// Returns C flags that `cc-rs` thinks should be enabled for the
11441144
/// specified target by default.
1145-
fn default_cflags(&self, target: TargetSelection, c: CLang) -> Vec<String> {
1145+
fn cc_handled_clags(&self, target: TargetSelection, c: CLang) -> Vec<String> {
11461146
if self.config.dry_run() {
11471147
return Vec::new();
11481148
}
@@ -1161,7 +1161,12 @@ Executed at: {executed_at}"#,
11611161
}
11621162

11631163
/// Returns extra C flags that `cc-rs` doesn't handle.
1164-
fn extra_cflags(&self, target: TargetSelection, which: GitRepo, c: CLang) -> Vec<String> {
1164+
fn cc_unhandled_cflags(
1165+
&self,
1166+
target: TargetSelection,
1167+
which: GitRepo,
1168+
c: CLang,
1169+
) -> Vec<String> {
11651170
let mut base = Vec::new();
11661171

11671172
// If we're compiling C++ on macOS then we add a flag indicating that

src/bootstrap/src/utils/cc_detect.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ pub fn find_target(build: &Build, target: TargetSelection) {
142142
};
143143

144144
build.cc.borrow_mut().insert(target, compiler.clone());
145-
let mut cflags = build.default_cflags(target, CLang::C);
146-
cflags.extend(build.extra_cflags(target, GitRepo::Rustc, CLang::C));
145+
let mut cflags = build.cc_handled_clags(target, CLang::C);
146+
cflags.extend(build.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::C));
147147

148148
// If we use llvm-libunwind, we will need a C++ compiler as well for all targets
149149
// We'll need one anyways if the target triple is also a host triple
@@ -169,8 +169,8 @@ pub fn find_target(build: &Build, target: TargetSelection) {
169169
build.verbose(|| println!("CC_{} = {:?}", target.triple, build.cc(target)));
170170
build.verbose(|| println!("CFLAGS_{} = {cflags:?}", target.triple));
171171
if let Ok(cxx) = build.cxx(target) {
172-
let mut cxxflags = build.default_cflags(target, CLang::Cxx);
173-
cxxflags.extend(build.extra_cflags(target, GitRepo::Rustc, CLang::Cxx));
172+
let mut cxxflags = build.cc_handled_clags(target, CLang::Cxx);
173+
cxxflags.extend(build.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::Cxx));
174174
build.verbose(|| println!("CXX_{} = {cxx:?}", target.triple));
175175
build.verbose(|| println!("CXXFLAGS_{} = {cxxflags:?}", target.triple));
176176
}

0 commit comments

Comments
 (0)