@@ -109,11 +109,59 @@ pub fn try_find_native_static_library(
109
109
. break_value ( )
110
110
}
111
111
112
+ fn try_find_native_dynamic_library ( sess : & Session , name : & str , verbatim : bool ) -> Option < PathBuf > {
113
+ let formats = if verbatim {
114
+ vec ! [ ( "" . into( ) , "" . into( ) ) ]
115
+ } else {
116
+ // While the official naming convention for MSVC import libraries
117
+ // is foo.lib...
118
+ let os = ( sess. target . staticlib_prefix . clone ( ) , sess. target . staticlib_suffix . clone ( ) ) ;
119
+ // ... Meson follows the libfoo.dll.a convention to
120
+ // disambiguate .a for static libraries
121
+ let meson = ( "lib" . into ( ) , ".dll.a" . into ( ) ) ;
122
+ // and MinGW uses .a altogether
123
+ let mingw = ( "lib" . into ( ) , ".a" . into ( ) ) ;
124
+ vec ! [ os, meson, mingw]
125
+ } ;
126
+
127
+ let path = walk_native_lib_search_dirs (
128
+ sess,
129
+ LinkSelfContainedComponents :: empty ( ) ,
130
+ None ,
131
+ |dir, is_framework| {
132
+ if !is_framework {
133
+ for ( prefix, suffix) in & formats {
134
+ let test = dir. join ( format ! ( "{prefix}{name}{suffix}" ) ) ;
135
+ if test. exists ( ) {
136
+ return ControlFlow :: Break ( test) ;
137
+ }
138
+ }
139
+ }
140
+ ControlFlow :: Continue ( ( ) )
141
+ } ,
142
+ )
143
+ . break_value ( ) ;
144
+
145
+ match path {
146
+ Some ( _) => path,
147
+ None => {
148
+ // Allow the linker to find CRT libs itself
149
+ let crtlib = PathBuf :: from ( format ! ( "{}{}" , name, if verbatim { "" } else { ".lib" } ) ) ;
150
+ Some ( crtlib)
151
+ }
152
+ }
153
+ }
154
+
112
155
pub fn find_native_static_library ( name : & str , verbatim : bool , sess : & Session ) -> PathBuf {
113
156
try_find_native_static_library ( sess, name, verbatim)
114
157
. unwrap_or_else ( || sess. dcx ( ) . emit_fatal ( errors:: MissingNativeLibrary :: new ( name, verbatim) ) )
115
158
}
116
159
160
+ pub fn find_native_dynamic_library ( name : & str , verbatim : bool , sess : & Session ) -> PathBuf {
161
+ try_find_native_dynamic_library ( sess, name, verbatim)
162
+ . unwrap_or_else ( || sess. dcx ( ) . emit_fatal ( errors:: MissingNativeLibrary :: new ( name, verbatim) ) )
163
+ }
164
+
117
165
fn find_bundled_library (
118
166
name : Symbol ,
119
167
verbatim : Option < bool > ,
0 commit comments