@@ -107,6 +107,9 @@ pub enum Error {
107
107
/// Override with `PKG_CONFIG_ALLOW_CROSS=1`.
108
108
CrossCompilation ,
109
109
110
+ /// Attempted to compile using the MSVC ABI build
111
+ MSVC ,
112
+
110
113
/// Failed to run `pkg-config`.
111
114
///
112
115
/// Contains the command and the cause.
@@ -130,6 +133,7 @@ impl error::Error for Error {
130
133
"pkg-config doesn't handle cross compilation. \
131
134
Use PKG_CONFIG_ALLOW_CROSS=1 to override"
132
135
}
136
+ Error :: MSVC => "pkg-config is incompatible with the MSVC ABI build." ,
133
137
Error :: Command { .. } => "failed to run pkg-config" ,
134
138
Error :: Failure { .. } => "pkg-config did not exit sucessfully" ,
135
139
Error :: __Nonexhaustive => panic ! ( ) ,
@@ -180,6 +184,7 @@ impl fmt::Debug for Error {
180
184
. finish ( )
181
185
}
182
186
Error :: CrossCompilation => write ! ( f, "CrossCompilation" ) ,
187
+ Error :: MSVC => write ! ( f, "MSVC" ) ,
183
188
Error :: Command { ref command, ref cause } => {
184
189
f. debug_struct ( "Command" )
185
190
. field ( "command" , command)
@@ -207,6 +212,10 @@ impl fmt::Display for Error {
207
212
write ! ( f, "Cross compilation detected. \
208
213
Use PKG_CONFIG_ALLOW_CROSS=1 to override")
209
214
}
215
+ Error :: MSVC => {
216
+ write ! ( f, "MSVC target detected. If you are using the MSVC ABI \
217
+ rust build, please use the GNU ABI build instead.")
218
+ }
210
219
Error :: Command { ref command, ref cause } => {
211
220
write ! ( f, "Failed to run `{}`: {}" , command, cause)
212
221
}
@@ -303,7 +312,12 @@ impl Config {
303
312
if env:: var_os ( & abort_var_name) . is_some ( ) {
304
313
return Err ( Error :: EnvNoPkgConfig ( abort_var_name) )
305
314
} else if !target_supported ( ) {
306
- return Err ( Error :: CrossCompilation ) ;
315
+ if env:: var ( "TARGET" ) . unwrap_or ( String :: new ( ) ) . contains ( "msvc" ) {
316
+ return Err ( Error :: MSVC ) ;
317
+ }
318
+ else {
319
+ return Err ( Error :: CrossCompilation ) ;
320
+ }
307
321
}
308
322
309
323
let mut library = Library :: new ( ) ;
0 commit comments