@@ -106,11 +106,14 @@ pub fn find(build: &mut Build) {
106
106
let cxx_configured = if let Some ( cxx) = config. and_then ( |c| c. cxx . as_ref ( ) ) {
107
107
cfg. compiler ( cxx) ;
108
108
true
109
+ } else if build. hosts . contains ( & target) {
110
+ set_compiler ( & mut cfg, Language :: CPlusPlus , target, config, build) ;
111
+ true
109
112
} else {
110
- set_compiler ( & mut cfg , Language :: CPlusPlus , target , config , build )
113
+ false
111
114
} ;
112
115
113
- if cxx_configured || build . hosts . contains ( & target ) {
116
+ if cxx_configured {
114
117
let compiler = cfg. get_compiler ( ) ;
115
118
build. cxx . insert ( target, compiler) ;
116
119
}
@@ -132,7 +135,7 @@ fn set_compiler(cfg: &mut cc::Build,
132
135
compiler : Language ,
133
136
target : Interned < String > ,
134
137
config : Option < & Target > ,
135
- build : & Build ) -> bool {
138
+ build : & Build ) {
136
139
match & * target {
137
140
// When compiling for android we may have the NDK configured in the
138
141
// config.toml in which case we look there. Otherwise the default
@@ -145,7 +148,6 @@ fn set_compiler(cfg: &mut cc::Build,
145
148
. replace ( "thumbv7" , "arm" ) ;
146
149
let compiler = format ! ( "{}-{}" , target, compiler. clang( ) ) ;
147
150
cfg. compiler ( ndk. join ( "bin" ) . join ( compiler) ) ;
148
- return true ;
149
151
}
150
152
}
151
153
@@ -155,35 +157,32 @@ fn set_compiler(cfg: &mut cc::Build,
155
157
let c = cfg. get_compiler ( ) ;
156
158
let gnu_compiler = compiler. gcc ( ) ;
157
159
if !c. path ( ) . ends_with ( gnu_compiler) {
158
- return false ;
160
+ return
159
161
}
160
162
161
163
let output = output ( c. to_command ( ) . arg ( "--version" ) ) ;
162
164
let i = match output. find ( " 4." ) {
163
165
Some ( i) => i,
164
- None => return false ,
166
+ None => return ,
165
167
} ;
166
168
match output[ i + 3 ..] . chars ( ) . next ( ) . unwrap ( ) {
167
169
'0' ..= '6' => { }
168
- _ => return false ,
170
+ _ => return ,
169
171
}
170
172
let alternative = format ! ( "e{}" , gnu_compiler) ;
171
173
if Command :: new ( & alternative) . output ( ) . is_ok ( ) {
172
174
cfg. compiler ( alternative) ;
173
- return true ;
174
175
}
175
176
}
176
177
177
178
"mips-unknown-linux-musl" => {
178
179
if cfg. get_compiler ( ) . path ( ) . to_str ( ) == Some ( "gcc" ) {
179
180
cfg. compiler ( "mips-linux-musl-gcc" ) ;
180
- return true ;
181
181
}
182
182
}
183
183
"mipsel-unknown-linux-musl" => {
184
184
if cfg. get_compiler ( ) . path ( ) . to_str ( ) == Some ( "gcc" ) {
185
185
cfg. compiler ( "mipsel-linux-musl-gcc" ) ;
186
- return true ;
187
186
}
188
187
}
189
188
@@ -192,14 +191,12 @@ fn set_compiler(cfg: &mut cc::Build,
192
191
let guess = root. join ( "bin/musl-gcc" ) ;
193
192
if guess. exists ( ) {
194
193
cfg. compiler ( guess) ;
195
- return true ;
196
194
}
197
195
}
198
196
}
199
197
200
198
_ => { }
201
199
}
202
- false
203
200
}
204
201
205
202
/// The target programming language for a native compiler.
0 commit comments