@@ -217,7 +217,16 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
217
217
// attributes in LLVM IR as well as native dependencies (in C these
218
218
// correspond to `__declspec(dllimport)`).
219
219
//
220
- // Whenever a dynamic library is built by MSVC it must have its public
220
+ // LD (BFD) in MinGW mode can often correctly guess `dllexport` but
221
+ // relying on that can result in issues like #50176.
222
+ // LLD won't support that and expects symbols with proper attributes.
223
+ // Because of that we make MinGW target emit dllexport just like MSVC.
224
+ // When it comes to dllimport we use it for constants but for functions
225
+ // rely on the linker to do the right thing. Opposed to dllexport this
226
+ // task is easy for them (both LD and LLD) and allows us to easily use
227
+ // symbols from static libraries in shared libraries.
228
+ //
229
+ // Whenever a dynamic library is built on Windows it must have its public
221
230
// interface specified by functions tagged with `dllexport` or otherwise
222
231
// they're not available to be linked against. This poses a few problems
223
232
// for the compiler, some of which are somewhat fundamental, but we use
@@ -254,8 +263,8 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
254
263
// this effect) by marking very little as `dllimport` and praying the
255
264
// linker will take care of everything. Fixing this problem will likely
256
265
// require adding a few attributes to Rust itself (feature gated at the
257
- // start) and then strongly recommending static linkage on MSVC !
258
- let use_dll_storage_attrs = tcx. sess . target . target . options . is_like_msvc ;
266
+ // start) and then strongly recommending static linkage on Windows !
267
+ let use_dll_storage_attrs = tcx. sess . target . target . options . is_like_windows ;
259
268
260
269
let check_overflow = tcx. sess . overflow_checks ( ) ;
261
270
0 commit comments