diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 071dbdfd4..85249ebbf 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -2289,7 +2289,7 @@ class SharedLibrary(BuildTarget):
             suffix = 'dll'
             # Shared library is of the form cygfoo.dll
             # (ld --dll-search-prefix=cyg is the default)
-            prefix = 'cyg'
+            prefix = 'msys-'
             # Import library is called libfoo.dll.a
             import_prefix = self.prefix if self.prefix is not None else 'lib'
             import_filename_tpl = import_prefix + '{0.name}.dll.a'
--- meson-1.7.0/mesonbuild/compilers/mixins/clike.py.orig	2025-01-27 06:40:16.476400700 +0100
+++ meson-1.7.0/mesonbuild/compilers/mixins/clike.py	2025-01-27 06:44:23.897492200 +0100
@@ -1048,7 +1048,7 @@
             stlibext += ['lib']
         elif env.machines[self.for_machine].is_cygwin():
             shlibext = ['dll', 'dll.a']
-            prefixes = ['cyg'] + prefixes
+            prefixes = ['msys-', 'cyg'] + prefixes
         elif self.id.lower() in {'c6000', 'c2000', 'ti'}:
             # TI C28x compilers can use both extensions for static or dynamic libs.
             stlibext = ['a', 'lib']
