@@ -107,6 +107,9 @@ pub enum Error {
107107 /// Override with `PKG_CONFIG_ALLOW_CROSS=1`.
108108 CrossCompilation ,
109109
110+ /// Attempted to compile using the MSVC ABI build
111+ MSVC ,
112+
110113 /// Failed to run `pkg-config`.
111114 ///
112115 /// Contains the command and the cause.
@@ -130,6 +133,7 @@ impl error::Error for Error {
130133 "pkg-config doesn't handle cross compilation. \
131134 Use PKG_CONFIG_ALLOW_CROSS=1 to override"
132135 }
136+ Error :: MSVC => "pkg-config is incompatible with the MSVC ABI build." ,
133137 Error :: Command { .. } => "failed to run pkg-config" ,
134138 Error :: Failure { .. } => "pkg-config did not exit sucessfully" ,
135139 Error :: __Nonexhaustive => panic ! ( ) ,
@@ -180,6 +184,7 @@ impl fmt::Debug for Error {
180184 . finish ( )
181185 }
182186 Error :: CrossCompilation => write ! ( f, "CrossCompilation" ) ,
187+ Error :: MSVC => write ! ( f, "MSVC" ) ,
183188 Error :: Command { ref command, ref cause } => {
184189 f. debug_struct ( "Command" )
185190 . field ( "command" , command)
@@ -207,6 +212,10 @@ impl fmt::Display for Error {
207212 write ! ( f, "Cross compilation detected. \
208213 Use PKG_CONFIG_ALLOW_CROSS=1 to override")
209214 }
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+ }
210219 Error :: Command { ref command, ref cause } => {
211220 write ! ( f, "Failed to run `{}`: {}" , command, cause)
212221 }
@@ -303,7 +312,12 @@ impl Config {
303312 if env:: var_os ( & abort_var_name) . is_some ( ) {
304313 return Err ( Error :: EnvNoPkgConfig ( abort_var_name) )
305314 } 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+ }
307321 }
308322
309323 let mut library = Library :: new ( ) ;
0 commit comments