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