Skip to content

Commit 870f13a

Browse files
committed
rustbuild: only autodetect cxx for hosts
Signed-off-by: Marc-Antoine Perennou <[email protected]>
1 parent c682ac9 commit 870f13a

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/bootstrap/cc_detect.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@ pub fn find(build: &mut Build) {
106106
let cxx_configured = if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
107107
cfg.compiler(cxx);
108108
true
109+
} else if build.hosts.contains(&target) {
110+
set_compiler(&mut cfg, Language::CPlusPlus, target, config, build);
111+
true
109112
} else {
110-
set_compiler(&mut cfg, Language::CPlusPlus, target, config, build)
113+
false
111114
};
112115

113-
if cxx_configured || build.hosts.contains(&target) {
116+
if cxx_configured {
114117
let compiler = cfg.get_compiler();
115118
build.cxx.insert(target, compiler);
116119
}
@@ -132,7 +135,7 @@ fn set_compiler(cfg: &mut cc::Build,
132135
compiler: Language,
133136
target: Interned<String>,
134137
config: Option<&Target>,
135-
build: &Build) -> bool {
138+
build: &Build) {
136139
match &*target {
137140
// When compiling for android we may have the NDK configured in the
138141
// config.toml in which case we look there. Otherwise the default
@@ -145,7 +148,6 @@ fn set_compiler(cfg: &mut cc::Build,
145148
.replace("thumbv7", "arm");
146149
let compiler = format!("{}-{}", target, compiler.clang());
147150
cfg.compiler(ndk.join("bin").join(compiler));
148-
return true;
149151
}
150152
}
151153

@@ -155,35 +157,32 @@ fn set_compiler(cfg: &mut cc::Build,
155157
let c = cfg.get_compiler();
156158
let gnu_compiler = compiler.gcc();
157159
if !c.path().ends_with(gnu_compiler) {
158-
return false;
160+
return
159161
}
160162

161163
let output = output(c.to_command().arg("--version"));
162164
let i = match output.find(" 4.") {
163165
Some(i) => i,
164-
None => return false,
166+
None => return,
165167
};
166168
match output[i + 3..].chars().next().unwrap() {
167169
'0' ..= '6' => {}
168-
_ => return false,
170+
_ => return,
169171
}
170172
let alternative = format!("e{}", gnu_compiler);
171173
if Command::new(&alternative).output().is_ok() {
172174
cfg.compiler(alternative);
173-
return true;
174175
}
175176
}
176177

177178
"mips-unknown-linux-musl" => {
178179
if cfg.get_compiler().path().to_str() == Some("gcc") {
179180
cfg.compiler("mips-linux-musl-gcc");
180-
return true;
181181
}
182182
}
183183
"mipsel-unknown-linux-musl" => {
184184
if cfg.get_compiler().path().to_str() == Some("gcc") {
185185
cfg.compiler("mipsel-linux-musl-gcc");
186-
return true;
187186
}
188187
}
189188

@@ -192,14 +191,12 @@ fn set_compiler(cfg: &mut cc::Build,
192191
let guess = root.join("bin/musl-gcc");
193192
if guess.exists() {
194193
cfg.compiler(guess);
195-
return true;
196194
}
197195
}
198196
}
199197

200198
_ => {}
201199
}
202-
false
203200
}
204201

205202
/// The target programming language for a native compiler.

0 commit comments

Comments
 (0)