From 6b394a87d51a0ee19be57acdcca8e1f2894a64cc Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Fri, 16 Jan 2026 10:43:48 +0800 Subject: [PATCH 01/13] Revert "strace.cc: Don't set MSYS=noglob" This reverts commit 97de8bae327ca9f3f241d4e5273e773f578e18db. --- winsup/utils/mingw/strace.cc | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/winsup/utils/mingw/strace.cc b/winsup/utils/mingw/strace.cc index a6b2e5d548..2b5d7ca2b8 100644 --- a/winsup/utils/mingw/strace.cc +++ b/winsup/utils/mingw/strace.cc @@ -356,28 +356,10 @@ create_child (char **argv) printf ("create_child: %s\n", one_line.buf); SetConsoleCtrlHandler (NULL, 0); -/* Commit message for this code was: -"* strace.cc (create_child): Set CYGWIN=noglob when starting new process so that - - Cygwin will leave already-parsed the command line alonw." - - I can see no reason for it and it badly breaks the ability to use - strace.exe to investigate calling a Cygwin program from a Windows - program, for example: - strace mingw32-make.exe - .. where mingw32-make.exe finds sh.exe and uses it as the shell. - The reason it badly breaks this use-case is because dcrt0.cc depends - on globbing to happen to parse commandlines from Windows programs; - irrespective of whether they contain any glob patterns or not. - - See quoted () comment: - "This must have been run from a Windows shell, so preserve - quotes for globify to play with later." - const char *cygwin_env = getenv ("MSYS"); const char *space; - if (cygwin_env && strlen (cygwin_env) <= 256) // sanity check + if (cygwin_env && strlen (cygwin_env) <= 256) /* sanity check */ space = " "; else space = cygwin_env = ""; @@ -385,7 +367,6 @@ create_child (char **argv) + strlen (space) + strlen (cygwin_env)); sprintf (newenv, "MSYS=noglob%s%s", space, cygwin_env); _putenv (newenv); -*/ ret = CreateProcess (0, one_line.buf, /* command line */ NULL, /* Security */ NULL, /* thread */ From d2fdc8a16dfcdac1998a1ea0d5d10c1e1ed01882 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Fri, 16 Jan 2026 10:43:58 +0800 Subject: [PATCH 02/13] Revert "Rename dll from cygwin to msys" This reverts commit dae2b5bc659d8fdec13f6d7e864277bbbce9dd1a. --- winsup/cygserver/transport_pipes.h | 4 --- winsup/cygwin/Makefile.am | 27 +++++++++---------- winsup/cygwin/crt0.c | 8 ------ winsup/cygwin/cygwin.din | 6 ++--- winsup/cygwin/cygwin.sc.in | 4 --- winsup/cygwin/dcrt0.cc | 4 --- winsup/cygwin/dlfcn.cc | 5 ---- winsup/cygwin/dll_init.cc | 4 --- winsup/cygwin/dtable.cc | 6 ----- winsup/cygwin/exceptions.cc | 4 +-- winsup/cygwin/fhandler/pipe.cc | 4 --- winsup/cygwin/fhandler/pty.cc | 26 ------------------ winsup/cygwin/hookapi.cc | 4 --- winsup/cygwin/include/cygwin/cygwin_dll.h | 10 +++---- winsup/cygwin/include/cygwin/version.h | 8 ------ winsup/cygwin/lib/_cygwin_crt0_common.cc | 4 --- winsup/cygwin/lib/crt0.h | 4 --- winsup/cygwin/lib/cygwin_attach_dll.c | 8 ------ winsup/cygwin/lib/cygwin_crt0.c | 8 ------ .../cygwin/local_includes/cygserver_setpwd.h | 4 --- winsup/cygwin/scripts/mkvers.sh | 6 ++--- winsup/cygwin/sec/auth.cc | 8 +++--- winsup/cygwin/syscalls.cc | 4 +-- winsup/cygwin/syslog.cc | 4 --- winsup/cygwin/winver.rc | 2 +- winsup/testsuite/winsup.api/cygload.cc | 10 +++---- winsup/testsuite/winsup.api/cygload.h | 2 +- winsup/utils/ldd.cc | 2 +- winsup/utils/loadlib.h | 6 ++--- winsup/utils/mingw/cygcheck.cc | 27 ++++++++++--------- winsup/utils/mingw/strace.cc | 9 ++++--- winsup/utils/path.cc | 12 ++++----- winsup/utils/ssp.c | 8 +++--- 33 files changed, 72 insertions(+), 180 deletions(-) diff --git a/winsup/cygserver/transport_pipes.h b/winsup/cygserver/transport_pipes.h index 66272bc86c..e101623d24 100644 --- a/winsup/cygserver/transport_pipes.h +++ b/winsup/cygserver/transport_pipes.h @@ -11,11 +11,7 @@ details. */ #ifndef _TRANSPORT_PIPES_H #define _TRANSPORT_PIPES_H -#ifdef __MSYS__ -#define PIPE_NAME_PREFIX L"\\\\.\\pipe\\msys-" -#else #define PIPE_NAME_PREFIX L"\\\\.\\pipe\\cygwin-" -#endif #define PIPE_NAME_SUFFIX L"-lpc" /* Named pipes based transport, for security on NT */ diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am index 41190bdb7a..86b2c51019 100644 --- a/winsup/cygwin/Makefile.am +++ b/winsup/cygwin/Makefile.am @@ -42,12 +42,12 @@ newlib_build=$(target_builddir)/newlib toollibdir=$(tooldir)/lib toolincludedir=$(tooldir)/include -# Parameters used in building the msys-2.0.dll. +# Parameters used in building the cygwin.dll. -DLL_NAME=msys-2.0.dll -NEW_DLL_NAME=new-msys-2.0.dll -DEF_FILE=msys.def -LIB_NAME=libmsys-2.0.a +DLL_NAME=cygwin1.dll +NEW_DLL_NAME=new-cygwin1.dll +DEF_FILE=cygwin.def +LIB_NAME=libcygwin.a # # sources @@ -595,16 +595,16 @@ LIBSERVER = $(cygserver_blddir)/libcygserver.a $(LIBSERVER): $(MAKE) -C $(cygserver_blddir) libcygserver.a -# We build as new-msys-2.0.dll and rename at install time to overcome native +# We build as new-cygwin1.dll and rename at install time to overcome native # rebuilding issues (we don't want the build tools to see a partially built -# msys-2.0.dll and attempt to use it instead of the old one). +# cygwin1.dll and attempt to use it instead of the old one). # linker script LDSCRIPT=cygwin.sc $(LDSCRIPT): $(LDSCRIPT).in $(AM_V_GEN)$(CC) -E - -P < $^ -o $@ -# msys-2.0 dll +# cygwin dll # Set PE and export table header timestamps to zero for reproducible builds. $(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) $(LIBSERVER)\ $(newlib_build)/libm.a $(newlib_build)/libc.a @@ -612,18 +612,18 @@ $(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) $(LIBSERVER)\ -mno-use-libstdc-wrappers \ -Wl,--gc-sections -nostdlib -Wl,-T$(LDSCRIPT) -static \ $${SOURCE_DATE_EPOCH:+-Wl,--no-insert-timestamp} \ - -Wl,--heap=0 -Wl,--out-implib,msysdll.a -shared -o $@ \ + -Wl,--heap=0 -Wl,--out-implib,cygdll.a -shared -o $@ \ -e @DLL_ENTRY@ $(DEF_FILE) \ -Wl,-whole-archive libdll.a -Wl,-no-whole-archive \ $(VERSION_OFILES) \ $(LIBSERVER) \ $(newlib_build)/libm.a \ $(newlib_build)/libc.a \ - -lgcc -lkernel32 -lntdll -Wl,-Map,msys.map + -lgcc -lkernel32 -lntdll -Wl,-Map,cygwin.map @$(MKDIR_P) ${target_builddir}/winsup/testsuite/testinst/bin/ $(AM_V_at)$(INSTALL_PROGRAM) $(NEW_DLL_NAME) ${target_builddir}/winsup/testsuite/testinst/bin/$(DLL_NAME) -# msys-2.0 import library +# cygwin import library toolopts=--cpu=@target_cpu@ --ar=@AR@ --as=@AS@ --nm=@NM@ --objcopy=@OBJCOPY@ $(DEF_FILE): scripts/gendef cygwin.din @@ -636,14 +636,13 @@ sigfe.s: $(DEF_FILE) tlsoffsets LIBCOS=$(addsuffix .o,$(basename $(LIB_FILES))) $(LIB_NAME): $(DEF_FILE) $(LIBCOS) | $(NEW_DLL_NAME) - $(AM_V_GEN)$(srcdir)/scripts/mkimport $(toolopts) $(NEW_FUNCTIONS) $@ msysdll.a $(wordlist 2,99,$^) + $(AM_V_GEN)$(srcdir)/scripts/mkimport $(toolopts) $(NEW_FUNCTIONS) $@ cygdll.a $(wordlist 2,99,$^) # sublibs # import libraries for some subset of symbols indicated by given objects speclib=\ $(srcdir)/scripts/speclib $(toolopts) \ --exclude='cygwin' \ - --exclude='msys' \ --exclude='(?i:dll)' \ --exclude='reloc' \ --exclude='^main$$' \ @@ -693,7 +692,7 @@ all-local: $(LIB_NAME) $(SUBLIBS) clean-local: -rm -f $(BUILT_SOURCES) -rm -f $(DEF_FILE) sigfe.s - -rm -f cygwin.sc msysdll.a msys.map + -rm -f cygwin.sc cygdll.a cygwin.map -rm -f $(NEW_DLL_NAME) -rm -f $(LIB_NAME) $(SUBLIBS) -rm -f version.cc diff --git a/winsup/cygwin/crt0.c b/winsup/cygwin/crt0.c index 3160df4491..1096e58970 100644 --- a/winsup/cygwin/crt0.c +++ b/winsup/cygwin/crt0.c @@ -9,20 +9,12 @@ details. */ extern int main (int argc, char **argv); -#ifdef __MSYS__ -void msys_crt0 (int (*main) (int, char **)); -#else void cygwin_crt0 (int (*main) (int, char **)); -#endif void mainCRTStartup () { -#ifdef __MSYS__ - msys_crt0 (main); -#else cygwin_crt0 (main); -#endif /* These are never actually called. They are just here to force the inclusion of things like -lbinmode. */ diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 073b8d07f4..deac201c08 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -1,4 +1,4 @@ -LIBRARY "msys-2.0.dll" BASE=0x180040000 +LIBRARY "cygwin1.dll" BASE=0x180040000 EXPORTS # Exported variables @@ -404,8 +404,8 @@ cygwin_attach_handle_to_fd SIGFE cygwin_conv_path SIGFE cygwin_conv_path_list SIGFE cygwin_create_path SIGFE -msys_detach_dll SIGFE_MAYBE -msys_dll_init NOSIGFE +cygwin_detach_dll SIGFE_MAYBE +cygwin_dll_init NOSIGFE cygwin_internal NOSIGFE cygwin_logon_user SIGFE cygwin_posix_path_list_p NOSIGFE diff --git a/winsup/cygwin/cygwin.sc.in b/winsup/cygwin/cygwin.sc.in index 4dc5daed8d..69526f5d8a 100644 --- a/winsup/cygwin/cygwin.sc.in +++ b/winsup/cygwin/cygwin.sc.in @@ -1,10 +1,6 @@ #ifdef __x86_64__ OUTPUT_FORMAT(pei-x86-64) -# ifdef __MSYS__ -SEARCH_DIR("/usr/x86_64-pc-msys/lib/w32api"); SEARCH_DIR("=/usr/lib/w32api"); -# else SEARCH_DIR("/usr/x86_64-pc-cygwin/lib/w32api"); SEARCH_DIR("=/usr/lib/w32api"); -# endif #else #error unimplemented for this target #endif diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 33cad1e3fe..bb864b0204 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -1090,11 +1090,7 @@ dll_crt0 (per_process *uptr) See winsup/testsuite/cygload for an example of how to use cygwin1.dll from MSVC and non-cygwin MinGW applications. */ extern "C" void -#ifdef __MSYS__ -msys_dll_init () -#else cygwin_dll_init () -#endif { static int _fmode; diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index 40d99ddeff..e06616d7fa 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -148,13 +148,8 @@ collect_basenames (pathfinder::basenamelist & basenames, /* If the basename starts with "lib", ... */ if (!strncmp (basename, "lib", 3)) { -#ifdef __MSYS__ - /* ... replace "lib" with "msys-", before ... */ - basenames.appendv ("msys-", 5, basename+3, baselen-3, ext, extlen, NULL); -#else /* ... replace "lib" with "cyg", before ... */ basenames.appendv ("cyg", 3, basename+3, baselen-3, ext, extlen, NULL); -#endif } /* ... using original basename with new suffix. */ basenames.appendv (basename, baselen, ext, extlen, NULL); diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 4a7c338cf1..6fae8f1456 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -913,11 +913,7 @@ dll_dllcrt0_1 (VOID *x) } extern "C" void -#ifdef __MSYS__ -msys_detach_dll (dll *) -#else cygwin_detach_dll (dll *) -#endif { HANDLE retaddr; if (_my_tls.isinitialized ()) diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 6ccc19a715..7303f7eacc 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -997,15 +997,9 @@ handle_to_fn (HANDLE h, char *posix_fn) if (wcsncasecmp (w32, DEV_NAMED_PIPE, DEV_NAMED_PIPE_LEN) == 0) { w32 += DEV_NAMED_PIPE_LEN; -#ifdef __MSYS__ - if (wcsncmp (w32, L"msys-", WCLEN (L"msys-")) != 0) - return false; - w32 += WCLEN (L"msys-"); -#else if (wcsncmp (w32, L"cygwin-", WCLEN (L"cygwin-")) != 0) return false; w32 += WCLEN (L"cygwin-"); -#endif /* Check for installation key and trailing dash. */ w32len = cygheap->installation_key.Length / sizeof (WCHAR); if (w32len diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index bdbf443c9b..5e05f6fbbb 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -529,14 +529,14 @@ int exec_prepared_command (PWCHAR command) PWCHAR rawenv = GetEnvironmentStringsW () ; for (PWCHAR p = rawenv; *p != L'\0'; p = wcschr (p, L'\0') + 1) { - if (wcsncmp (p, L"MSYS=", wcslen (L"MSYS=")) == 0) + if (wcsncmp (p, L"CYGWIN=", wcslen (L"CYGWIN=")) == 0) { PWCHAR q = wcsstr (p, L"error_start") ; /* replace 'error_start=...' with '_rror_start=...' */ if (q) { *q = L'_' ; - SetEnvironmentVariableW (L"MSYS", p + wcslen (L"MSYS=")) ; + SetEnvironmentVariableW (L"CYGWIN", p + wcslen (L"CYGWIN=")) ; } break; } diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc index 11ef78c73b..2ff5dfa2f7 100644 --- a/winsup/cygwin/fhandler/pipe.cc +++ b/winsup/cygwin/fhandler/pipe.cc @@ -798,11 +798,7 @@ fhandler_pipe::close (int flag) return ret; } -#ifdef __MSYS__ -#define PIPE_INTRO "\\\\.\\pipe\\msys-" -#else #define PIPE_INTRO "\\\\.\\pipe\\cygwin-" -#endif /* Create a pipe, and return handles to the read and write ends, just like CreatePipe, but ensure that the write end permits diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index 9c3ef2192a..90f58671c2 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -879,11 +879,7 @@ fhandler_pty_slave::open (int flags, mode_t) pipe_reply repl; DWORD len; -#ifdef __MSYS__ - __small_sprintf (buf, "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", -#else __small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", -#endif &cygheap->installation_key, get_minor ()); termios_printf ("dup handles via master control pipe %s", buf); if (!CallNamedPipe (buf, &req, sizeof req, &repl, sizeof repl, @@ -1145,11 +1141,7 @@ fhandler_pty_slave::reset_switch_to_nat_pipe (void) { char pipe[MAX_PATH]; __small_sprintf (pipe, -#ifdef __MSYS__ - "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", -#else "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", -#endif &cygheap->installation_key, get_minor ()); pipe_request req = { GET_HANDLES, GetCurrentProcessId () }; pipe_reply repl; @@ -1610,15 +1602,9 @@ fhandler_pty_slave::tcflush (int queue) if (queue == TCIFLUSH || queue == TCIOFLUSH) { char pipe[MAX_PATH]; -#ifdef __MSYS__ - __small_sprintf (pipe, - "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", - &cygheap->installation_key, get_minor ()); -#else __small_sprintf (pipe, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", &cygheap->installation_key, get_minor ()); -#endif pipe_request req = { FLUSH_INPUT, GetCurrentProcessId () }; pipe_reply repl; DWORD n; @@ -2050,11 +2036,7 @@ fhandler_pty_master::close (int flag) pipe_reply repl; DWORD len; -#ifdef __MSYS__ - __small_sprintf (buf, "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", -#else __small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", -#endif &cygheap->installation_key, get_minor ()); acquire_output_mutex (mutex_timeout); if (master_ctl) @@ -3025,11 +3007,7 @@ fhandler_pty_master::setup () /* Create master control pipe which allows the master to duplicate the pty pipe handles to processes which deserve it. */ -#ifdef __MSYS__ - __small_sprintf (buf, "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", -#else __small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", -#endif &cygheap->installation_key, unit); master_ctl = CreateNamedPipe (buf, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE, @@ -3919,11 +3897,7 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir, HANDLE from, tty *ttyp, { char pipe[MAX_PATH]; __small_sprintf (pipe, -#ifdef __MSYS__ - "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", -#else "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", -#endif &cygheap->installation_key, ttyp->get_minor ()); pipe_request req = { GET_HANDLES, GetCurrentProcessId () }; pipe_reply repl; diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc index 9f31a716c4..ee2edbafee 100644 --- a/winsup/cygwin/hookapi.cc +++ b/winsup/cygwin/hookapi.cc @@ -379,11 +379,7 @@ hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h) for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++) { if (!ascii_strcasematch (rva (PSTR, map ?: (char *) hm, pd->Name - delta), -#ifdef __MSYS__ - "msys-2.0.dll")) -#else "cygwin1.dll")) -#endif continue; if (!fn) { diff --git a/winsup/cygwin/include/cygwin/cygwin_dll.h b/winsup/cygwin/include/cygwin/cygwin_dll.h index b77598bb63..1e4cf98ba5 100644 --- a/winsup/cygwin/include/cygwin/cygwin_dll.h +++ b/winsup/cygwin/include/cygwin/cygwin_dll.h @@ -24,8 +24,8 @@ details. */ CDECL_BEGIN \ int Entry (HINSTANCE h, DWORD reason, void *ptr); \ typedef int (*mainfunc) (int, char **, char **); \ - extern PVOID msys_attach_dll (HMODULE, mainfunc); \ - extern void msys_detach_dll (PVOID); \ + extern PVOID cygwin_attach_dll (HMODULE, mainfunc); \ + extern void cygwin_detach_dll (PVOID); \ CDECL_END \ \ static HINSTANCE storedHandle; \ @@ -42,7 +42,7 @@ static int __dllMain (int a __attribute__ ((__unused__)), \ \ static PVOID dll_index; \ \ -int _msys_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ +int _cygwin_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ { \ int ret; \ ret = 1; \ @@ -55,7 +55,7 @@ int _msys_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ storedReason = reason; \ storedPtr = ptr; \ __dynamically_loaded = (ptr == NULL); \ - dll_index = msys_attach_dll (h, &__dllMain); \ + dll_index = cygwin_attach_dll (h, &__dllMain); \ if (dll_index == (PVOID) -1) \ ret = 0; \ } \ @@ -66,7 +66,7 @@ int _msys_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ ret = Entry (h, reason, ptr); \ if (ret) \ { \ - msys_detach_dll (dll_index); \ + cygwin_detach_dll (dll_index); \ dll_index = (PVOID) -1; \ } \ } \ diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 9e20cbaf3b..a0e00c4801 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -510,11 +510,7 @@ details. */ names include the CYGWIN_VERSION_SHARED_DATA version as well as this identifier. */ -#ifdef __MSYS__ -#define CYGWIN_VERSION_DLL_IDENTIFIER "msys-2.0" -#else #define CYGWIN_VERSION_DLL_IDENTIFIER "cygwin1" -#endif /* The Cygwin mount table interface in the Win32 registry also has a version number associated with it in case that is changed in a non-backwards @@ -530,11 +526,7 @@ details. */ /* Identifiers used in the Win32 registry. */ -#ifdef __MSYS__ -#define CYGWIN_INFO_CYGWIN_REGISTRY_NAME "MSYS" -#else #define CYGWIN_INFO_CYGWIN_REGISTRY_NAME "Cygwin" -#endif #define CYGWIN_INFO_INSTALLATIONS_NAME "Installations" /* The default cygdrive prefix. */ diff --git a/winsup/cygwin/lib/_cygwin_crt0_common.cc b/winsup/cygwin/lib/_cygwin_crt0_common.cc index 801b6f91ca..d356a50fba 100644 --- a/winsup/cygwin/lib/_cygwin_crt0_common.cc +++ b/winsup/cygwin/lib/_cygwin_crt0_common.cc @@ -73,11 +73,7 @@ struct per_process_cxx_malloc __cygwin_cxx_malloc = and then jump to the dll. */ int -#ifdef __MSYS__ -_msys_crt0_common (MainFunc f, per_process *u) -#else _cygwin_crt0_common (MainFunc f, per_process *u) -#endif { per_process *newu = (per_process *) cygwin_internal (CW_USER_DATA); bool uwasnull; diff --git a/winsup/cygwin/lib/crt0.h b/winsup/cygwin/lib/crt0.h index e81750032b..e599b44934 100644 --- a/winsup/cygwin/lib/crt0.h +++ b/winsup/cygwin/lib/crt0.h @@ -13,11 +13,7 @@ extern "C" { #include "winlean.h" struct per_process; typedef int (*MainFunc) (int argc, char *argv[], char **env); -#ifdef __MSYS__ -int _msys_crt0_common (MainFunc, struct per_process *); -#else int _cygwin_crt0_common (MainFunc, struct per_process *); -#endif PVOID dll_dllcrt0 (HMODULE, struct per_process *); #ifdef __cplusplus diff --git a/winsup/cygwin/lib/cygwin_attach_dll.c b/winsup/cygwin/lib/cygwin_attach_dll.c index 82679c4a97..866bfd80fa 100644 --- a/winsup/cygwin/lib/cygwin_attach_dll.c +++ b/winsup/cygwin/lib/cygwin_attach_dll.c @@ -15,18 +15,10 @@ details. */ /* for a loaded dll */ PVOID -#ifdef __MSYS__ -msys_attach_dll (HMODULE h, MainFunc f) -#else cygwin_attach_dll (HMODULE h, MainFunc f) -#endif { static struct per_process u; -#ifdef __MSYS__ - (void) _msys_crt0_common (f, &u); -#else (void) _cygwin_crt0_common (f, &u); -#endif /* jump into the dll. */ return dll_dllcrt0 (h, &u); diff --git a/winsup/cygwin/lib/cygwin_crt0.c b/winsup/cygwin/lib/cygwin_crt0.c index 396447e52e..7020a639dd 100644 --- a/winsup/cygwin/lib/cygwin_crt0.c +++ b/winsup/cygwin/lib/cygwin_crt0.c @@ -14,16 +14,8 @@ extern void _dll_crt0 () /* for main module */ void -#ifdef __MSYS__ -msys_crt0 (MainFunc f) -#else cygwin_crt0 (MainFunc f) -#endif { -#ifdef __MSYS__ - _msys_crt0_common (f, NULL); -#else _cygwin_crt0_common (f, NULL); -#endif _dll_crt0 (); /* Jump into the dll, never to return */ } diff --git a/winsup/cygwin/local_includes/cygserver_setpwd.h b/winsup/cygwin/local_includes/cygserver_setpwd.h index b2975111cf..fc1576b059 100644 --- a/winsup/cygwin/local_includes/cygserver_setpwd.h +++ b/winsup/cygwin/local_includes/cygserver_setpwd.h @@ -12,11 +12,7 @@ details. */ #include #include "cygserver.h" -#ifdef __MSYS__ -#define CYGWIN_LSA_KEY_PREFIX L"L$MSYS_" -#else #define CYGWIN_LSA_KEY_PREFIX L"L$CYGWIN_" -#endif #ifndef __INSIDE_CYGWIN__ class transport_layer_base; diff --git a/winsup/cygwin/scripts/mkvers.sh b/winsup/cygwin/scripts/mkvers.sh index 34d8d6dce1..2fba214318 100755 --- a/winsup/cygwin/scripts/mkvers.sh +++ b/winsup/cygwin/scripts/mkvers.sh @@ -127,7 +127,7 @@ dir=$(echo $dir | sed -e 's%/include/cygwin.*$%%' -e 's%include/cygwin.*$%.%') ) | while read var; do read val cat <&9 @@ -139,9 +139,9 @@ trap "rm -f /tmp/mkvers.$$" 0 1 2 15 # cat <&9 #ifdef DEBUGGING - "%%% MSYS shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n" + "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n" #else - "%%% MSYS shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n" + "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n" #endif "END_CYGWIN_VERSION_INFO\n\0"; cygwin_version_info cygwin_version = diff --git a/winsup/cygwin/sec/auth.cc b/winsup/cygwin/sec/auth.cc index 2361ae5ff9..f9906a55c6 100644 --- a/winsup/cygwin/sec/auth.cc +++ b/winsup/cygwin/sec/auth.cc @@ -462,7 +462,7 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern) if (!NT_SUCCESS (status)) debug_printf ("NtQueryInformationToken(), %y", status); else - *pintern = intern = !memcmp (ts.SourceName, "MSYS.2", 6); + *pintern = intern = !memcmp (ts.SourceName, "Cygwin.1", 8); } /* Verify usersid */ cygsid tok_usersid (NO_SID); @@ -747,7 +747,7 @@ s4uauth (bool logon, PCWSTR domain, PCWSTR user, NTSTATUS &ret_status) { /* Register as logon process. */ debug_printf ("Impersonation requested"); - RtlInitAnsiString (&name, "MSYS"); + RtlInitAnsiString (&name, "Cygwin"); status = LsaRegisterLogonProcess (&name, &lsa_hdl, &sec_mode); } else @@ -786,11 +786,11 @@ s4uauth (bool logon, PCWSTR domain, PCWSTR user, NTSTATUS &ret_status) } /* Create origin. */ - stpcpy (origin.buf, "MSYS"); + stpcpy (origin.buf, "Cygwin"); RtlInitAnsiString (&origin.str, origin.buf); /* Create token source. */ - memcpy (ts.SourceName, "MSYS.2", 6); + memcpy (ts.SourceName, "Cygwin.1", 8); ts.SourceIdentifier.HighPart = 0; ts.SourceIdentifier.LowPart = kerberos_auth ? 0x0105 : 0x0106; diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 6a935aac63..94eba9bdc0 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -339,7 +339,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) } else { - /* Create unique filename. Start with a dot, followed by "msys" + /* Create unique filename. Start with a dot, followed by "cyg" transposed to the Unicode private use area in the U+f700 area on file systems supporting Unicode (except Samba), followed by the inode number in hex, followed by a path hash in hex. The @@ -347,7 +347,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) RtlAppendUnicodeToString (&recycler, (pc.fs_flags () & FILE_UNICODE_ON_DISK && !pc.fs_is_samba ()) - ? L".\xf76d\xf773\xf779\xf773" : L".msys"); + ? L".\xf763\xf779\xf767" : L".cyg"); pfii = (PFILE_INTERNAL_INFORMATION) infobuf; status = NtQueryInformationFile (fh, &io, pfii, sizeof *pfii, FileInternalInformation); diff --git a/winsup/cygwin/syslog.cc b/winsup/cygwin/syslog.cc index 431f9d2396..6a295501f1 100644 --- a/winsup/cygwin/syslog.cc +++ b/winsup/cygwin/syslog.cc @@ -26,11 +26,7 @@ details. */ #include "cygtls.h" #include "tls_pbuf.h" -#ifdef __MSYS__ -#define CYGWIN_LOG_NAME L"MSYS" -#else #define CYGWIN_LOG_NAME L"Cygwin" -#endif static struct { diff --git a/winsup/cygwin/winver.rc b/winsup/cygwin/winver.rc index 58878d41bd..980d51204c 100644 --- a/winsup/cygwin/winver.rc +++ b/winsup/cygwin/winver.rc @@ -35,7 +35,7 @@ BEGIN VALUE "InternalName", CYGWIN_DLL_NAME VALUE "LegalCopyright", "Copyright \251 Cygwin Authors 1996-" STRINGIFY(CYGWIN_BUILD_YEAR) VALUE "OriginalFilename", CYGWIN_DLL_NAME - VALUE "ProductName", "MSYS2" + VALUE "ProductName", "Cygwin" VALUE "ProductVersion", STRINGIFY(CYGWIN_VERSION) VALUE "APIVersion", CYGWIN_API_VERSION VALUE "SharedMemoryVersion", STRINGIFY(CYGWIN_VERSION_SHARED_DATA) diff --git a/winsup/testsuite/winsup.api/cygload.cc b/winsup/testsuite/winsup.api/cygload.cc index 1b2f79dc05..afd3ee90fc 100644 --- a/winsup/testsuite/winsup.api/cygload.cc +++ b/winsup/testsuite/winsup.api/cygload.cc @@ -25,7 +25,7 @@ save for errors. -testinterrupts Pauses the program for 30 seconds so you can demonstrate that it handles ^C properly. - -cygwin Name of DLL to load. Defaults to "msys-2.0.dll". */ + -cygwin Name of DLL to load. Defaults to "cygwin1.dll". */ #include "cygload.h" #include @@ -154,13 +154,13 @@ cygwin::connector::connector (const char *dll) *out << "Initializing cygwin..." << endl; - // This calls dcrt0.cc:msys_dll_init(), which calls dll_crt0_1(), + // This calls dcrt0.cc:cygwin_dll_init(), which calls dll_crt0_1(), // which will, among other things: // * spawn the cygwin signal handling thread from sigproc_init() // * initialize the thread-local storage for this thread and overwrite // the first 4K of the stack void (*cyginit) (); - get_symbol ("msys_dll_init", cyginit); + get_symbol ("cygwin_dll_init", cyginit); (*cyginit) (); *out << "Loading symbols..." << endl; @@ -224,7 +224,7 @@ cygwin::connector::~connector () // This should call init.cc:dll_entry() with DLL_PROCESS_DETACH. if (!FreeLibrary (_library)) - throw windows_error ("FreeLibrary", "msys-2.0.dll"); + throw windows_error ("FreeLibrary", "cygwin1.dll"); } catch (std::exception &x) { @@ -490,7 +490,7 @@ main (int argc, char *argv[]) std::ostringstream output; bool verbose = false, testinterrupts = false; - const char *dll = "msys-2.0.dll"; + const char *dll = "cygwin1.dll"; out = &output; diff --git a/winsup/testsuite/winsup.api/cygload.h b/winsup/testsuite/winsup.api/cygload.h index 0f2aacda9a..30154048b0 100644 --- a/winsup/testsuite/winsup.api/cygload.h +++ b/winsup/testsuite/winsup.api/cygload.h @@ -76,7 +76,7 @@ namespace cygwin // spawns a thread to let you receive signals from cygwin. class connector { public: - connector (const char *dll = "msys-2.0.dll"); + connector (const char *dll = "cygwin1.dll"); ~connector (); // A wrapper around GetProcAddress() for fetching symbols from the diff --git a/winsup/utils/ldd.cc b/winsup/utils/ldd.cc index a31c4c6e44..0d073c2989 100644 --- a/winsup/utils/ldd.cc +++ b/winsup/utils/ldd.cc @@ -249,7 +249,7 @@ tocyg (wchar_t *win_fn) return fn; } -#define CYGWIN_DLL_LEN (wcslen (L"\\msys-2.0.dll")) +#define CYGWIN_DLL_LEN (wcslen (L"\\cygwin1.dll")) static int print_dlls (dlls *dll, const wchar_t *dllfn, const wchar_t *process_fn) { diff --git a/winsup/utils/loadlib.h b/winsup/utils/loadlib.h index 42ffbfdc03..c83b76478f 100644 --- a/winsup/utils/loadlib.h +++ b/winsup/utils/loadlib.h @@ -13,7 +13,7 @@ #include /* Load all system libs from the windows system directory by prepending the - full path. This doesn't work for loadling msys-2.0.dll. For this case, + full path. This doesn't work for loadling cygwin1.dll. For this case, instead of prepending the path, make sure that the CWD is removed from the DLL search path, if possible (XP SP1++, Vista++). */ static HMODULE _load_sys_library (const wchar_t *dll) __attribute__ ((used)); @@ -45,8 +45,8 @@ _load_sys_library (const wchar_t *dll) set_dll_directory (L""); } - if (wcscmp (dll, L"msys-2.0.dll") == 0) - return LoadLibraryExW (L"msys-2.0.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (wcscmp (dll, L"cygwin1.dll") == 0) + return LoadLibraryExW (L"cygwin1.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH); wcscpy (dllpath, sysdir); wcscpy (dllpath + sysdir_len, dll); diff --git a/winsup/utils/mingw/cygcheck.cc b/winsup/utils/mingw/cygcheck.cc index 1637683c26..89a08e560f 100644 --- a/winsup/utils/mingw/cygcheck.cc +++ b/winsup/utils/mingw/cygcheck.cc @@ -95,7 +95,8 @@ static const char *known_env_vars[] = { "c_include_path", "compiler_path", "cxx_include_path", - "msys", + "cygwin", + "cygwin32", "dejagnu", "expect", "gcc_default_options", @@ -553,7 +554,7 @@ struct ImpDirectory static bool track_down (const char *file, const char *suffix, int lvl); -#define CYGPREFIX (sizeof ("%%% Msys ") - 1) +#define CYGPREFIX (sizeof ("%%% Cygwin ") - 1) static void cygwin_info (HANDLE h) { @@ -585,7 +586,7 @@ cygwin_info (HANDLE h) while (buf < bufend) if ((buf = (char *) memchr (buf, '%', bufend - buf)) == NULL) break; - else if (strncmp ("%%% Msys ", buf, CYGPREFIX) != 0) + else if (strncmp ("%%% Cygwin ", buf, CYGPREFIX) != 0) buf++; else { @@ -779,7 +780,7 @@ dll_info (const char *path, HANDLE fh, int lvl, int recurse) } } } - if (strstr (path, "\\msys-2.0.dll")) + if (strstr (path, "\\cygwin1.dll")) cygwin_info (fh); } @@ -1026,7 +1027,7 @@ scan_registry (RegInfo * prev, HKEY hKey, char *name, int cygwin, bool wow64) char *cp; for (cp = name; *cp; cp++) - if (strncasecmp (cp, "Msys", 4) == 0) + if (strncasecmp (cp, "Cygwin", 6) == 0) cygwin = 1; DWORD num_subkeys, max_subkey_len, num_values; @@ -1308,7 +1309,7 @@ handle_reg_installation (handle_reg_t what) printf ("Cygwin installations found in the registry:\n"); for (int i = 0; i < 2; ++i) if (RegOpenKeyEx (i ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, - "SOFTWARE\\Msys\\Installations", 0, + "SOFTWARE\\Cygwin\\Installations", 0, what == DELETE_KEY ? KEY_READ | KEY_WRITE : KEY_READ, &key) == ERROR_SUCCESS) @@ -1330,7 +1331,7 @@ handle_reg_installation (handle_reg_t what) if (what == PRINT_KEY) printf (" %s Key: %s Path: %s", i ? "User: " : "System:", name, path); - strcat (path, "\\bin\\msys-2.0.dll"); + strcat (path, "\\bin\\cygwin1.dll"); if (what == PRINT_KEY) printf ("%s\n", access (path, F_OK) ? " (ORPHANED)" : ""); else if (access (path, F_OK)) @@ -1784,7 +1785,7 @@ dump_sysinfo () if (registry) { if (givehelp) - printf ("Scanning registry for keys with 'Msys' in them...\n"); + printf ("Scanning registry for keys with 'Cygwin' in them...\n"); scan_registry (0, HKEY_CURRENT_USER, (char *) "HKEY_CURRENT_USER", 0, false); scan_registry (0, HKEY_LOCAL_MACHINE, @@ -1979,10 +1980,10 @@ dump_sysinfo () wcstombs (f, ffinfo.cFileName, sizeof f); if (strcasecmp (f + strlen (f) - 4, ".dll") == 0) { - if (strncasecmp (f, "msys-", 5) == 0) + if (strncasecmp (f, "cyg", 3) == 0) { sprintf (tmp, "%s%s", pth->dir, f); - if (strcasecmp (f, "msys-2.0.dll") == 0) + if (strcasecmp (f, "cygwin1.dll") == 0) { if (!cygwin_dll_count) strcpy (cygdll_path, pth->dir); @@ -2006,9 +2007,9 @@ dump_sysinfo () FindClose (ff); } if (cygwin_dll_count > 1) - puts ("Warning: There are multiple msys-2.0.dlls on your path"); + puts ("Warning: There are multiple cygwin1.dlls on your path"); if (!cygwin_dll_count) - puts ("Warning: msys-2.0.dll not found on your path"); + puts ("Warning: cygwin1.dll not found on your path"); dump_dodgy_apps (verbose); @@ -3022,7 +3023,7 @@ load_cygwin (int& argc, char **&argv) { HMODULE h; - if (!(h = LoadLibrary ("msys-2.0.dll"))) + if (!(h = LoadLibrary ("cygwin1.dll"))) return; GetModuleFileNameW (h, cygwin_dll_path, 32768); if ((cygwin_internal = (uintptr_t (*) (cygwin_getinfo_types, ...)) diff --git a/winsup/utils/mingw/strace.cc b/winsup/utils/mingw/strace.cc index 2b5d7ca2b8..4f294372e7 100644 --- a/winsup/utils/mingw/strace.cc +++ b/winsup/utils/mingw/strace.cc @@ -284,7 +284,7 @@ load_cygwin () if (h) return 0; - if (!(h = LoadLibrary ("msys-2.0.dll"))) + if (!(h = LoadLibrary ("cygwin1.dll"))) { errno = ENOENT; return 0; @@ -356,16 +356,17 @@ create_child (char **argv) printf ("create_child: %s\n", one_line.buf); SetConsoleCtrlHandler (NULL, 0); - const char *cygwin_env = getenv ("MSYS"); + + const char *cygwin_env = getenv ("CYGWIN"); const char *space; if (cygwin_env && strlen (cygwin_env) <= 256) /* sanity check */ space = " "; else space = cygwin_env = ""; - char *newenv = (char *) malloc (sizeof ("MSYS=noglob") + char *newenv = (char *) malloc (sizeof ("CYGWIN=noglob") + strlen (space) + strlen (cygwin_env)); - sprintf (newenv, "MSYS=noglob%s%s", space, cygwin_env); + sprintf (newenv, "CYGWIN=noglob%s%s", space, cygwin_env); _putenv (newenv); ret = CreateProcess (0, one_line.buf, /* command line */ NULL, /* Security */ diff --git a/winsup/utils/path.cc b/winsup/utils/path.cc index 323e4c784b..fe55a646d9 100644 --- a/winsup/utils/path.cc +++ b/winsup/utils/path.cc @@ -585,14 +585,14 @@ read_mounts () } max_mount_entry = 0; - /* First fetch the msys-2.0.dll path from the LoadLibrary call in load_cygwin. - This utilizes the DLL search order to find a matching msys-2.0.dll and to + /* First fetch the cygwin1.dll path from the LoadLibrary call in load_cygwin. + This utilizes the DLL search order to find a matching cygwin1.dll and to compute the installation path from that DLL's path. */ if (cygwin_dll_path[0]) wcscpy (path, cygwin_dll_path); - /* If we can't load msys-2.0.dll, check where cygcheck is living itself and - try to fetch installation path from here. Does msys-2.0.dll exist in the - same path? This should only kick in if the msys-2.0.dll in the same path + /* If we can't load cygwin1.dll, check where cygcheck is living itself and + try to fetch installation path from here. Does cygwin1.dll exist in the + same path? This should only kick in if the cygwin1.dll in the same path has been made non-executable for the current user accidentally. */ else if (!GetModuleFileNameW (NULL, path, 32768)) return; @@ -601,7 +601,7 @@ read_mounts () { if (!cygwin_dll_path[0]) { - wcscpy (path_end, L"\\msys-2.0.dll"); + wcscpy (path_end, L"\\cygwin1.dll"); DWORD attr = GetFileAttributesW (path); if (attr == (DWORD) -1 || (attr & (FILE_ATTRIBUTE_DIRECTORY diff --git a/winsup/utils/ssp.c b/winsup/utils/ssp.c index 95045e1e8b..96a90a1d98 100644 --- a/winsup/utils/ssp.c +++ b/winsup/utils/ssp.c @@ -710,15 +710,15 @@ usage (FILE * stream) "You must specify the range of memory addresses to keep track of\n" "manually, but it's not hard to figure out what to specify. Use the\n" "\"objdump\" program to determine the bounds of the target's \".text\"\n" - "section. Let's say we're profiling msys-2.0.dll. Make sure you've\n" + "section. Let's say we're profiling cygwin1.dll. Make sure you've\n" "built it with debug symbols (else gprof won't run) and run objdump\n" "like this:\n" "\n" - " objdump -h msys-2.0.dll\n" + " objdump -h cygwin1.dll\n" "\n" "It will print a report like this:\n" "\n" - "msys-2.0.dll: file format pei-i386\n" + "cygwin1.dll: file format pei-i386\n" "\n" "Sections:\n" "Idx Name Size VMA LMA File off Algn\n" @@ -749,7 +749,7 @@ usage (FILE * stream) "\"gmon.out\". You can turn this data file into a readable report with\n" "gprof:\n" "\n" - " gprof -b msys-2.0.dll\n" + " gprof -b cygwin1.dll\n" "\n" "The \"-b\" means 'skip the help pages'. You can omit this until you're\n" "familiar with the report layout. The gprof documentation explains\n" From 1cc96c72577719b02c8ac5128e04041ec8bf05cd Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Fri, 16 Jan 2026 11:30:31 +0800 Subject: [PATCH 03/13] Revert "uname: allow setting the system name to CYGWIN" This reverts commit a32cbc84049b69d38801e75a92938c4fde433292. --- winsup/cygwin/uname.cc | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc index 8f984fac9b..b0b939a301 100644 --- a/winsup/cygwin/uname.cc +++ b/winsup/cygwin/uname.cc @@ -24,24 +24,6 @@ extern "C" int getdomainname (char *__name, size_t __len); #define ATTRIBUTE_NONSTRING #endif -static const char* -get_sysname() -{ -#ifdef __MSYS__ - char* msystem = getenv("MSYSTEM"); - if (!msystem || strcmp(msystem, "MSYS") == 0) - return "MSYS"; - else if (strcmp(msystem, "CYGWIN") == 0) - return "CYGWIN"; - else if (strstr(msystem, "32") != NULL) - return "MINGW32"; - else - return "MINGW64"; -#else - return "CYGWIN"; -#endif -} - /* uname: POSIX 4.4.1.1 */ /* New entrypoint for applications since API 335 */ @@ -55,9 +37,12 @@ uname_x (struct utsname *name) memset (name, 0, sizeof (*name)); /* sysname */ - const char* sysname = get_sysname(); + char* msystem = getenv("MSYSTEM"); + const char* msystem_sysname = "MSYS"; + if (msystem != NULL && *msystem && strcmp(msystem, "MSYS") != 0) + msystem_sysname = (strstr(msystem, "32") != NULL) ? "MINGW32" : "MINGW64";; n = __small_sprintf (name->sysname, "%s_%s-%u", - sysname, + msystem_sysname, wincap.osname (), wincap.build_number ()); if (wincap.host_machine () != wincap.cygwin_machine ()) { @@ -139,8 +124,15 @@ uname (struct utsname *in_name) __try { memset (name, 0, sizeof (*name)); - const char* sysname = get_sysname(); - __small_sprintf (name->sysname, "%s_%s", sysname, wincap.osname ()); +#ifdef __MSYS__ + char* msystem = getenv("MSYSTEM"); + const char* msystem_sysname = "MSYS"; + if (msystem != NULL && *msystem && strcmp(msystem, "MSYS") != 0) + msystem_sysname = (strstr(msystem, "32") != NULL) ? "MINGW32" : "MINGW64"; + __small_sprintf (name->sysname, "%s_%s", msystem_sysname, wincap.osname ()); +#else + __small_sprintf (name->sysname, "CYGWIN_%s", wincap.osname ()); +#endif /* Computer name */ cygwin_gethostname (name->nodename, sizeof (name->nodename) - 1); From f4de5f486b67aacaf086cd4818970ebab60c9982 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Fri, 16 Jan 2026 11:31:10 +0800 Subject: [PATCH 04/13] Revert "Add functionality for changing OS name via MSYSTEM environment variables." This reverts commit b91f7928d2292a402d3fdfe9a3983780a387dc28. --- winsup/cygserver/cygserver-config | 4 ++-- winsup/cygwin/environ.cc | 34 +++-------------------------- winsup/cygwin/include/sys/utsname.h | 2 +- winsup/cygwin/uname.cc | 17 ++------------- 4 files changed, 8 insertions(+), 49 deletions(-) diff --git a/winsup/cygserver/cygserver-config b/winsup/cygserver/cygserver-config index 1f0603f68c..abda186449 100755 --- a/winsup/cygserver/cygserver-config +++ b/winsup/cygserver/cygserver-config @@ -86,7 +86,7 @@ done # Check if running on NT _sys="`uname`" -_nt=`expr "${_sys}" : "MSYS_NT"` +_nt=`expr "${_sys}" : "CYGWIN_NT"` # Check for running cygserver processes first. if ps -e | grep -v grep | grep -q ${service_name} @@ -178,7 +178,7 @@ then echo "Do you want to install cygserver as service?" if request "(Say \"no\" if it's already installed as service)" then - if ! cygrunsrv -I ${service_name} -d "MSYS cygserver" -p /usr/sbin/cygserver + if ! cygrunsrv -I ${service_name} -d "CYGWIN cygserver" -p /usr/sbin/cygserver then echo echo "Installation of cygserver as service failed. Please check the" diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 4e049211e9..e9aa0c9f05 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -201,11 +201,7 @@ parse_options (const char *inbuf) if (export_settings) { debug_printf ("%s", newbuf + 1); -#ifdef __MSYS__ - setenv ("MSYS", newbuf + 1, 1); -#else setenv ("CYGWIN", newbuf + 1, 1); -#endif } return; } @@ -678,7 +674,7 @@ _addenv (const char *name, const char *value, int overwrite) win_env *spenv; if ((spenv = getwinenv (envhere))) spenv->add_cache (value); - if (strcmp (name, "MSYS") == 0) + if (strcmp (name, "CYGWIN") == 0) parse_options (value); return 0; @@ -781,9 +777,6 @@ static struct renv { } renv_arr[] = { { NL("COMMONPROGRAMFILES=") }, // 0 { NL("COMSPEC=") }, -#ifdef __MSYS__ - { NL("MSYSTEM=") }, // 2 -#endif /* __MSYS__ */ { NL("PATH=") }, // 2 { NL("PROGRAMFILES=") }, { NL("SYSTEMDRIVE=") }, // 4 @@ -795,21 +788,10 @@ static struct renv { #define RENV_SIZE (sizeof (renv_arr) / sizeof (renv_arr[0])) /* Set of first characters of the above list of variables. */ -static const char idx_arr[] = -#ifdef __MSYS__ - "CMPSTW"; -#else - "CPSTW"; -#endif +static const char idx_arr[] = "CPSTW"; /* Index into renv_arr at which the variables with this specific character starts. */ -static const int start_at[] = { -#ifdef __MSYS__ - 0, 2, 3, 5, 7, 9 -#else - 0, 2, 4, 6, 8 -#endif - }; +static const int start_at[] = { 0, 2, 4, 6, 8 }; /* Turn environment variable part of a=b string into uppercase - for some environment variables only. */ @@ -877,11 +859,7 @@ environ_init (char **envp, int envc) dumper_init (); if (envp_passed_in) { -#ifdef __MSYS__ - p = getenv ("MSYS"); -#else p = getenv ("CYGWIN"); -#endif if (p) parse_options (p); } @@ -937,13 +915,8 @@ win32env_to_cygenv (PWCHAR rawenv, bool posify) } sawTERM = 1; } -#ifdef __MSYS__ - else if (*newp == 'M' && strncmp (newp, "MSYS=", 5) == 0) - parse_options (newp + 5); -#else else if (*newp == 'C' && strncmp (newp, "CYGWIN=", 7) == 0) parse_options (newp + 7); -#endif if (*eq && posify) posify_maybe (envp + i, *++eq ? eq : --eq, tmpbuf); debug_printf ("%p: %s", envp[i], envp[i]); @@ -1018,7 +991,6 @@ static NO_COPY spenv spenvs[] = {NL ("HOMEPATH="), false, false, &cygheap_user::env_homepath}, {NL ("LOGONSERVER="), false, false, &cygheap_user::env_logsrv}, {NL ("PATH="), false, true, NULL}, - {NL ("MSYSTEM="), true, true, NULL}, {NL ("SYSTEMDRIVE="), false, true, NULL}, {NL ("SYSTEMROOT="), true, true, &cygheap_user::env_systemroot}, {NL ("USERDOMAIN="), false, false, &cygheap_user::env_domain}, diff --git a/winsup/cygwin/include/sys/utsname.h b/winsup/cygwin/include/sys/utsname.h index 730cb731a5..d6b3be96f7 100644 --- a/winsup/cygwin/include/sys/utsname.h +++ b/winsup/cygwin/include/sys/utsname.h @@ -17,7 +17,7 @@ extern "C" { struct utsname { - char sysname[_UTSNAME_LENGTH + 1]; + char sysname[_UTSNAME_LENGTH]; char nodename[_UTSNAME_LENGTH]; char release[_UTSNAME_LENGTH]; char version[_UTSNAME_LENGTH]; diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc index b0b939a301..069690e5fa 100644 --- a/winsup/cygwin/uname.cc +++ b/winsup/cygwin/uname.cc @@ -37,12 +37,7 @@ uname_x (struct utsname *name) memset (name, 0, sizeof (*name)); /* sysname */ - char* msystem = getenv("MSYSTEM"); - const char* msystem_sysname = "MSYS"; - if (msystem != NULL && *msystem && strcmp(msystem, "MSYS") != 0) - msystem_sysname = (strstr(msystem, "32") != NULL) ? "MINGW32" : "MINGW64";; - n = __small_sprintf (name->sysname, "%s_%s-%u", - msystem_sysname, + n = __small_sprintf (name->sysname, "CYGWIN_%s-%u", wincap.osname (), wincap.build_number ()); if (wincap.host_machine () != wincap.cygwin_machine ()) { @@ -110,7 +105,7 @@ uname_x (struct utsname *name) /* Old entrypoint for applications up to API 334 */ struct old_utsname { - char sysname[21]; + char sysname[20]; char nodename[20]; char release[20]; char version[20]; @@ -124,15 +119,7 @@ uname (struct utsname *in_name) __try { memset (name, 0, sizeof (*name)); -#ifdef __MSYS__ - char* msystem = getenv("MSYSTEM"); - const char* msystem_sysname = "MSYS"; - if (msystem != NULL && *msystem && strcmp(msystem, "MSYS") != 0) - msystem_sysname = (strstr(msystem, "32") != NULL) ? "MINGW32" : "MINGW64"; - __small_sprintf (name->sysname, "%s_%s", msystem_sysname, wincap.osname ()); -#else __small_sprintf (name->sysname, "CYGWIN_%s", wincap.osname ()); -#endif /* Computer name */ cygwin_gethostname (name->nodename, sizeof (name->nodename) - 1); From 5a976d7fd37768ea2b46cc10b8e5cffcd3cc2ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B8=CC=86=20=D0=9F?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=BE=D0=B2?= Date: Mon, 15 Apr 2019 02:29:01 +0800 Subject: [PATCH 05/13] Add functionality for changing OS name via MSYSTEM environment variables. allow setting the system name to CYGWIN We are currently trying to move our cygwin build environment closer to cygwin and some autotools/bash based build systems call "uname -s" to figure out the OS and in many cases only handle the cygwin case, so we have to patch them. With this instead of patching we can set MSYSTEM=CYGWIN and change uname output that way. The next step would be to always output CYGWIN in an msys env by default, but for now this allows us to get rid of all the patches without affecting users. --- winsup/cygserver/cygserver-config | 4 ++-- winsup/cygwin/environ.cc | 19 +++++++++++++++++-- winsup/cygwin/include/sys/utsname.h | 2 +- winsup/cygwin/uname.cc | 27 ++++++++++++++++++++++++--- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/winsup/cygserver/cygserver-config b/winsup/cygserver/cygserver-config index abda186449..1f0603f68c 100755 --- a/winsup/cygserver/cygserver-config +++ b/winsup/cygserver/cygserver-config @@ -86,7 +86,7 @@ done # Check if running on NT _sys="`uname`" -_nt=`expr "${_sys}" : "CYGWIN_NT"` +_nt=`expr "${_sys}" : "MSYS_NT"` # Check for running cygserver processes first. if ps -e | grep -v grep | grep -q ${service_name} @@ -178,7 +178,7 @@ then echo "Do you want to install cygserver as service?" if request "(Say \"no\" if it's already installed as service)" then - if ! cygrunsrv -I ${service_name} -d "CYGWIN cygserver" -p /usr/sbin/cygserver + if ! cygrunsrv -I ${service_name} -d "MSYS cygserver" -p /usr/sbin/cygserver then echo echo "Installation of cygserver as service failed. Please check the" diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index e9aa0c9f05..6233ab76a3 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -777,6 +777,9 @@ static struct renv { } renv_arr[] = { { NL("COMMONPROGRAMFILES=") }, // 0 { NL("COMSPEC=") }, +#ifdef __MSYS__ + { NL("MSYSTEM=") }, // 2 +#endif /* __MSYS__ */ { NL("PATH=") }, // 2 { NL("PROGRAMFILES=") }, { NL("SYSTEMDRIVE=") }, // 4 @@ -788,10 +791,21 @@ static struct renv { #define RENV_SIZE (sizeof (renv_arr) / sizeof (renv_arr[0])) /* Set of first characters of the above list of variables. */ -static const char idx_arr[] = "CPSTW"; +static const char idx_arr[] = +#ifdef __MSYS__ + "CMPSTW"; +#else + "CPSTW"; +#endif /* Index into renv_arr at which the variables with this specific character starts. */ -static const int start_at[] = { 0, 2, 4, 6, 8 }; +static const int start_at[] = { +#ifdef __MSYS__ + 0, 2, 3, 5, 7, 9 +#else + 0, 2, 4, 6, 8 +#endif + }; /* Turn environment variable part of a=b string into uppercase - for some environment variables only. */ @@ -991,6 +1005,7 @@ static NO_COPY spenv spenvs[] = {NL ("HOMEPATH="), false, false, &cygheap_user::env_homepath}, {NL ("LOGONSERVER="), false, false, &cygheap_user::env_logsrv}, {NL ("PATH="), false, true, NULL}, + {NL ("MSYSTEM="), true, true, NULL}, {NL ("SYSTEMDRIVE="), false, true, NULL}, {NL ("SYSTEMROOT="), true, true, &cygheap_user::env_systemroot}, {NL ("USERDOMAIN="), false, false, &cygheap_user::env_domain}, diff --git a/winsup/cygwin/include/sys/utsname.h b/winsup/cygwin/include/sys/utsname.h index d6b3be96f7..730cb731a5 100644 --- a/winsup/cygwin/include/sys/utsname.h +++ b/winsup/cygwin/include/sys/utsname.h @@ -17,7 +17,7 @@ extern "C" { struct utsname { - char sysname[_UTSNAME_LENGTH]; + char sysname[_UTSNAME_LENGTH + 1]; char nodename[_UTSNAME_LENGTH]; char release[_UTSNAME_LENGTH]; char version[_UTSNAME_LENGTH]; diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc index 069690e5fa..8f984fac9b 100644 --- a/winsup/cygwin/uname.cc +++ b/winsup/cygwin/uname.cc @@ -24,6 +24,24 @@ extern "C" int getdomainname (char *__name, size_t __len); #define ATTRIBUTE_NONSTRING #endif +static const char* +get_sysname() +{ +#ifdef __MSYS__ + char* msystem = getenv("MSYSTEM"); + if (!msystem || strcmp(msystem, "MSYS") == 0) + return "MSYS"; + else if (strcmp(msystem, "CYGWIN") == 0) + return "CYGWIN"; + else if (strstr(msystem, "32") != NULL) + return "MINGW32"; + else + return "MINGW64"; +#else + return "CYGWIN"; +#endif +} + /* uname: POSIX 4.4.1.1 */ /* New entrypoint for applications since API 335 */ @@ -37,7 +55,9 @@ uname_x (struct utsname *name) memset (name, 0, sizeof (*name)); /* sysname */ - n = __small_sprintf (name->sysname, "CYGWIN_%s-%u", + const char* sysname = get_sysname(); + n = __small_sprintf (name->sysname, "%s_%s-%u", + sysname, wincap.osname (), wincap.build_number ()); if (wincap.host_machine () != wincap.cygwin_machine ()) { @@ -105,7 +125,7 @@ uname_x (struct utsname *name) /* Old entrypoint for applications up to API 334 */ struct old_utsname { - char sysname[20]; + char sysname[21]; char nodename[20]; char release[20]; char version[20]; @@ -119,7 +139,8 @@ uname (struct utsname *in_name) __try { memset (name, 0, sizeof (*name)); - __small_sprintf (name->sysname, "CYGWIN_%s", wincap.osname ()); + const char* sysname = get_sysname(); + __small_sprintf (name->sysname, "%s_%s", sysname, wincap.osname ()); /* Computer name */ cygwin_gethostname (name->nodename, sizeof (name->nodename) - 1); From 3e941b8ea19d21cf95d55f97770e530045e258f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B8=CC=86=20=D0=9F?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=BE=D0=B2?= Date: Mon, 15 Apr 2019 02:29:01 +0800 Subject: [PATCH 06/13] Add support for MSYS environment variable instead of CYGWIN Changes of winsup/cygwin/environ.cc is split from "Add functionality for changing OS name via MSYSTEM environment variables." Changes of winsup/cygwin/exceptions.cc, winsup/utils/mingw/cygcheck.cc is split from "Rename dll from cygwin to msys" known_env_vars is sorted, update it --- winsup/cygwin/environ.cc | 15 ++++++++++++++- winsup/cygwin/exceptions.cc | 4 ++-- winsup/utils/mingw/cygcheck.cc | 3 +-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 6233ab76a3..4e049211e9 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -201,7 +201,11 @@ parse_options (const char *inbuf) if (export_settings) { debug_printf ("%s", newbuf + 1); +#ifdef __MSYS__ + setenv ("MSYS", newbuf + 1, 1); +#else setenv ("CYGWIN", newbuf + 1, 1); +#endif } return; } @@ -674,7 +678,7 @@ _addenv (const char *name, const char *value, int overwrite) win_env *spenv; if ((spenv = getwinenv (envhere))) spenv->add_cache (value); - if (strcmp (name, "CYGWIN") == 0) + if (strcmp (name, "MSYS") == 0) parse_options (value); return 0; @@ -873,7 +877,11 @@ environ_init (char **envp, int envc) dumper_init (); if (envp_passed_in) { +#ifdef __MSYS__ + p = getenv ("MSYS"); +#else p = getenv ("CYGWIN"); +#endif if (p) parse_options (p); } @@ -929,8 +937,13 @@ win32env_to_cygenv (PWCHAR rawenv, bool posify) } sawTERM = 1; } +#ifdef __MSYS__ + else if (*newp == 'M' && strncmp (newp, "MSYS=", 5) == 0) + parse_options (newp + 5); +#else else if (*newp == 'C' && strncmp (newp, "CYGWIN=", 7) == 0) parse_options (newp + 7); +#endif if (*eq && posify) posify_maybe (envp + i, *++eq ? eq : --eq, tmpbuf); debug_printf ("%p: %s", envp[i], envp[i]); diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 5e05f6fbbb..bdbf443c9b 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -529,14 +529,14 @@ int exec_prepared_command (PWCHAR command) PWCHAR rawenv = GetEnvironmentStringsW () ; for (PWCHAR p = rawenv; *p != L'\0'; p = wcschr (p, L'\0') + 1) { - if (wcsncmp (p, L"CYGWIN=", wcslen (L"CYGWIN=")) == 0) + if (wcsncmp (p, L"MSYS=", wcslen (L"MSYS=")) == 0) { PWCHAR q = wcsstr (p, L"error_start") ; /* replace 'error_start=...' with '_rror_start=...' */ if (q) { *q = L'_' ; - SetEnvironmentVariableW (L"CYGWIN", p + wcslen (L"CYGWIN=")) ; + SetEnvironmentVariableW (L"MSYS", p + wcslen (L"MSYS=")) ; } break; } diff --git a/winsup/utils/mingw/cygcheck.cc b/winsup/utils/mingw/cygcheck.cc index 89a08e560f..857e8bda1f 100644 --- a/winsup/utils/mingw/cygcheck.cc +++ b/winsup/utils/mingw/cygcheck.cc @@ -95,8 +95,6 @@ static const char *known_env_vars[] = { "c_include_path", "compiler_path", "cxx_include_path", - "cygwin", - "cygwin32", "dejagnu", "expect", "gcc_default_options", @@ -108,6 +106,7 @@ static const char *known_env_vars[] = { "lpath", "make_mode", "makeflags", + "msys", "path", "pwd", "strace", From 44453741eb8586ecadefac275fa40f275427578b Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Fri, 16 Jan 2026 10:46:30 +0800 Subject: [PATCH 07/13] strace.cc: Don't set CYGWIN=noglob Commit message for this code was: * strace.cc (create_child): Set CYGWIN=noglob when starting new process so that Cygwin will leave already-parsed the command line alonw." I can see no reason for it and it badly breaks the ability to use strace.exe to investigate calling a Cygwin program from a Windows program, for example: strace mingw32-make.exe .. where mingw32-make.exe finds sh.exe and uses it as the shell. The reason it badly breaks this use-case is because dcrt0.cc depends on globbing to happen to parse commandlines from Windows programs; irrespective of whether they contain any glob patterns or not. See quoted () comment: "This must have been run from a Windows shell, so preserve quotes for globify to play with later." --- winsup/utils/mingw/strace.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/winsup/utils/mingw/strace.cc b/winsup/utils/mingw/strace.cc index 4f294372e7..c239937be2 100644 --- a/winsup/utils/mingw/strace.cc +++ b/winsup/utils/mingw/strace.cc @@ -357,6 +357,7 @@ create_child (char **argv) SetConsoleCtrlHandler (NULL, 0); +#if 0 const char *cygwin_env = getenv ("CYGWIN"); const char *space; @@ -368,6 +369,8 @@ create_child (char **argv) + strlen (space) + strlen (cygwin_env)); sprintf (newenv, "CYGWIN=noglob%s%s", space, cygwin_env); _putenv (newenv); +#endif + ret = CreateProcess (0, one_line.buf, /* command line */ NULL, /* Security */ NULL, /* thread */ From a9ea83f889499305b637a3819b266af49311b320 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Fri, 16 Jan 2026 10:51:12 +0800 Subject: [PATCH 08/13] Convert to use msys'style named pipe This is split from "Rename dll from cygwin to msys" --- winsup/cygserver/transport_pipes.h | 4 +++ winsup/cygwin/cygwin.sc.in | 4 +++ winsup/cygwin/dtable.cc | 6 +++++ winsup/cygwin/fhandler/pipe.cc | 4 +++ winsup/cygwin/fhandler/pty.cc | 26 +++++++++++++++++++ winsup/cygwin/include/cygwin/version.h | 4 +++ .../cygwin/local_includes/cygserver_setpwd.h | 4 +++ winsup/cygwin/scripts/mkvers.sh | 6 ++--- winsup/cygwin/sec/auth.cc | 8 +++--- winsup/cygwin/syscalls.cc | 4 +-- winsup/cygwin/syslog.cc | 4 +++ winsup/utils/mingw/cygcheck.cc | 10 +++---- 12 files changed, 70 insertions(+), 14 deletions(-) diff --git a/winsup/cygserver/transport_pipes.h b/winsup/cygserver/transport_pipes.h index e101623d24..66272bc86c 100644 --- a/winsup/cygserver/transport_pipes.h +++ b/winsup/cygserver/transport_pipes.h @@ -11,7 +11,11 @@ details. */ #ifndef _TRANSPORT_PIPES_H #define _TRANSPORT_PIPES_H +#ifdef __MSYS__ +#define PIPE_NAME_PREFIX L"\\\\.\\pipe\\msys-" +#else #define PIPE_NAME_PREFIX L"\\\\.\\pipe\\cygwin-" +#endif #define PIPE_NAME_SUFFIX L"-lpc" /* Named pipes based transport, for security on NT */ diff --git a/winsup/cygwin/cygwin.sc.in b/winsup/cygwin/cygwin.sc.in index 69526f5d8a..4dc5daed8d 100644 --- a/winsup/cygwin/cygwin.sc.in +++ b/winsup/cygwin/cygwin.sc.in @@ -1,6 +1,10 @@ #ifdef __x86_64__ OUTPUT_FORMAT(pei-x86-64) +# ifdef __MSYS__ +SEARCH_DIR("/usr/x86_64-pc-msys/lib/w32api"); SEARCH_DIR("=/usr/lib/w32api"); +# else SEARCH_DIR("/usr/x86_64-pc-cygwin/lib/w32api"); SEARCH_DIR("=/usr/lib/w32api"); +# endif #else #error unimplemented for this target #endif diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 7303f7eacc..6ccc19a715 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -997,9 +997,15 @@ handle_to_fn (HANDLE h, char *posix_fn) if (wcsncasecmp (w32, DEV_NAMED_PIPE, DEV_NAMED_PIPE_LEN) == 0) { w32 += DEV_NAMED_PIPE_LEN; +#ifdef __MSYS__ + if (wcsncmp (w32, L"msys-", WCLEN (L"msys-")) != 0) + return false; + w32 += WCLEN (L"msys-"); +#else if (wcsncmp (w32, L"cygwin-", WCLEN (L"cygwin-")) != 0) return false; w32 += WCLEN (L"cygwin-"); +#endif /* Check for installation key and trailing dash. */ w32len = cygheap->installation_key.Length / sizeof (WCHAR); if (w32len diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc index 2ff5dfa2f7..11ef78c73b 100644 --- a/winsup/cygwin/fhandler/pipe.cc +++ b/winsup/cygwin/fhandler/pipe.cc @@ -798,7 +798,11 @@ fhandler_pipe::close (int flag) return ret; } +#ifdef __MSYS__ +#define PIPE_INTRO "\\\\.\\pipe\\msys-" +#else #define PIPE_INTRO "\\\\.\\pipe\\cygwin-" +#endif /* Create a pipe, and return handles to the read and write ends, just like CreatePipe, but ensure that the write end permits diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index 90f58671c2..9c3ef2192a 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -879,7 +879,11 @@ fhandler_pty_slave::open (int flags, mode_t) pipe_reply repl; DWORD len; +#ifdef __MSYS__ + __small_sprintf (buf, "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", +#else __small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", +#endif &cygheap->installation_key, get_minor ()); termios_printf ("dup handles via master control pipe %s", buf); if (!CallNamedPipe (buf, &req, sizeof req, &repl, sizeof repl, @@ -1141,7 +1145,11 @@ fhandler_pty_slave::reset_switch_to_nat_pipe (void) { char pipe[MAX_PATH]; __small_sprintf (pipe, +#ifdef __MSYS__ + "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", +#else "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", +#endif &cygheap->installation_key, get_minor ()); pipe_request req = { GET_HANDLES, GetCurrentProcessId () }; pipe_reply repl; @@ -1602,9 +1610,15 @@ fhandler_pty_slave::tcflush (int queue) if (queue == TCIFLUSH || queue == TCIOFLUSH) { char pipe[MAX_PATH]; +#ifdef __MSYS__ + __small_sprintf (pipe, + "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", + &cygheap->installation_key, get_minor ()); +#else __small_sprintf (pipe, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", &cygheap->installation_key, get_minor ()); +#endif pipe_request req = { FLUSH_INPUT, GetCurrentProcessId () }; pipe_reply repl; DWORD n; @@ -2036,7 +2050,11 @@ fhandler_pty_master::close (int flag) pipe_reply repl; DWORD len; +#ifdef __MSYS__ + __small_sprintf (buf, "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", +#else __small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", +#endif &cygheap->installation_key, get_minor ()); acquire_output_mutex (mutex_timeout); if (master_ctl) @@ -3007,7 +3025,11 @@ fhandler_pty_master::setup () /* Create master control pipe which allows the master to duplicate the pty pipe handles to processes which deserve it. */ +#ifdef __MSYS__ + __small_sprintf (buf, "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", +#else __small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", +#endif &cygheap->installation_key, unit); master_ctl = CreateNamedPipe (buf, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE, @@ -3897,7 +3919,11 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir, HANDLE from, tty *ttyp, { char pipe[MAX_PATH]; __small_sprintf (pipe, +#ifdef __MSYS__ + "\\\\.\\pipe\\msys-%S-pty%d-master-ctl", +#else "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl", +#endif &cygheap->installation_key, ttyp->get_minor ()); pipe_request req = { GET_HANDLES, GetCurrentProcessId () }; pipe_reply repl; diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index a0e00c4801..52ed1813de 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -526,7 +526,11 @@ details. */ /* Identifiers used in the Win32 registry. */ +#ifdef __MSYS__ +#define CYGWIN_INFO_CYGWIN_REGISTRY_NAME "MSYS" +#else #define CYGWIN_INFO_CYGWIN_REGISTRY_NAME "Cygwin" +#endif #define CYGWIN_INFO_INSTALLATIONS_NAME "Installations" /* The default cygdrive prefix. */ diff --git a/winsup/cygwin/local_includes/cygserver_setpwd.h b/winsup/cygwin/local_includes/cygserver_setpwd.h index fc1576b059..b2975111cf 100644 --- a/winsup/cygwin/local_includes/cygserver_setpwd.h +++ b/winsup/cygwin/local_includes/cygserver_setpwd.h @@ -12,7 +12,11 @@ details. */ #include #include "cygserver.h" +#ifdef __MSYS__ +#define CYGWIN_LSA_KEY_PREFIX L"L$MSYS_" +#else #define CYGWIN_LSA_KEY_PREFIX L"L$CYGWIN_" +#endif #ifndef __INSIDE_CYGWIN__ class transport_layer_base; diff --git a/winsup/cygwin/scripts/mkvers.sh b/winsup/cygwin/scripts/mkvers.sh index 2fba214318..34d8d6dce1 100755 --- a/winsup/cygwin/scripts/mkvers.sh +++ b/winsup/cygwin/scripts/mkvers.sh @@ -127,7 +127,7 @@ dir=$(echo $dir | sed -e 's%/include/cygwin.*$%%' -e 's%include/cygwin.*$%.%') ) | while read var; do read val cat <&9 @@ -139,9 +139,9 @@ trap "rm -f /tmp/mkvers.$$" 0 1 2 15 # cat <&9 #ifdef DEBUGGING - "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n" + "%%% MSYS shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n" #else - "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n" + "%%% MSYS shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n" #endif "END_CYGWIN_VERSION_INFO\n\0"; cygwin_version_info cygwin_version = diff --git a/winsup/cygwin/sec/auth.cc b/winsup/cygwin/sec/auth.cc index f9906a55c6..2361ae5ff9 100644 --- a/winsup/cygwin/sec/auth.cc +++ b/winsup/cygwin/sec/auth.cc @@ -462,7 +462,7 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern) if (!NT_SUCCESS (status)) debug_printf ("NtQueryInformationToken(), %y", status); else - *pintern = intern = !memcmp (ts.SourceName, "Cygwin.1", 8); + *pintern = intern = !memcmp (ts.SourceName, "MSYS.2", 6); } /* Verify usersid */ cygsid tok_usersid (NO_SID); @@ -747,7 +747,7 @@ s4uauth (bool logon, PCWSTR domain, PCWSTR user, NTSTATUS &ret_status) { /* Register as logon process. */ debug_printf ("Impersonation requested"); - RtlInitAnsiString (&name, "Cygwin"); + RtlInitAnsiString (&name, "MSYS"); status = LsaRegisterLogonProcess (&name, &lsa_hdl, &sec_mode); } else @@ -786,11 +786,11 @@ s4uauth (bool logon, PCWSTR domain, PCWSTR user, NTSTATUS &ret_status) } /* Create origin. */ - stpcpy (origin.buf, "Cygwin"); + stpcpy (origin.buf, "MSYS"); RtlInitAnsiString (&origin.str, origin.buf); /* Create token source. */ - memcpy (ts.SourceName, "Cygwin.1", 8); + memcpy (ts.SourceName, "MSYS.2", 6); ts.SourceIdentifier.HighPart = 0; ts.SourceIdentifier.LowPart = kerberos_auth ? 0x0105 : 0x0106; diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 94eba9bdc0..6a935aac63 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -339,7 +339,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) } else { - /* Create unique filename. Start with a dot, followed by "cyg" + /* Create unique filename. Start with a dot, followed by "msys" transposed to the Unicode private use area in the U+f700 area on file systems supporting Unicode (except Samba), followed by the inode number in hex, followed by a path hash in hex. The @@ -347,7 +347,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) RtlAppendUnicodeToString (&recycler, (pc.fs_flags () & FILE_UNICODE_ON_DISK && !pc.fs_is_samba ()) - ? L".\xf763\xf779\xf767" : L".cyg"); + ? L".\xf76d\xf773\xf779\xf773" : L".msys"); pfii = (PFILE_INTERNAL_INFORMATION) infobuf; status = NtQueryInformationFile (fh, &io, pfii, sizeof *pfii, FileInternalInformation); diff --git a/winsup/cygwin/syslog.cc b/winsup/cygwin/syslog.cc index 6a295501f1..431f9d2396 100644 --- a/winsup/cygwin/syslog.cc +++ b/winsup/cygwin/syslog.cc @@ -26,7 +26,11 @@ details. */ #include "cygtls.h" #include "tls_pbuf.h" +#ifdef __MSYS__ +#define CYGWIN_LOG_NAME L"MSYS" +#else #define CYGWIN_LOG_NAME L"Cygwin" +#endif static struct { diff --git a/winsup/utils/mingw/cygcheck.cc b/winsup/utils/mingw/cygcheck.cc index 857e8bda1f..8a5329026f 100644 --- a/winsup/utils/mingw/cygcheck.cc +++ b/winsup/utils/mingw/cygcheck.cc @@ -553,7 +553,7 @@ struct ImpDirectory static bool track_down (const char *file, const char *suffix, int lvl); -#define CYGPREFIX (sizeof ("%%% Cygwin ") - 1) +#define CYGPREFIX (sizeof ("%%% Msys ") - 1) static void cygwin_info (HANDLE h) { @@ -585,7 +585,7 @@ cygwin_info (HANDLE h) while (buf < bufend) if ((buf = (char *) memchr (buf, '%', bufend - buf)) == NULL) break; - else if (strncmp ("%%% Cygwin ", buf, CYGPREFIX) != 0) + else if (strncmp ("%%% Msys ", buf, CYGPREFIX) != 0) buf++; else { @@ -1026,7 +1026,7 @@ scan_registry (RegInfo * prev, HKEY hKey, char *name, int cygwin, bool wow64) char *cp; for (cp = name; *cp; cp++) - if (strncasecmp (cp, "Cygwin", 6) == 0) + if (strncasecmp (cp, "Msys", 4) == 0) cygwin = 1; DWORD num_subkeys, max_subkey_len, num_values; @@ -1308,7 +1308,7 @@ handle_reg_installation (handle_reg_t what) printf ("Cygwin installations found in the registry:\n"); for (int i = 0; i < 2; ++i) if (RegOpenKeyEx (i ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, - "SOFTWARE\\Cygwin\\Installations", 0, + "SOFTWARE\\Msys\\Installations", 0, what == DELETE_KEY ? KEY_READ | KEY_WRITE : KEY_READ, &key) == ERROR_SUCCESS) @@ -1784,7 +1784,7 @@ dump_sysinfo () if (registry) { if (givehelp) - printf ("Scanning registry for keys with 'Cygwin' in them...\n"); + printf ("Scanning registry for keys with 'Msys' in them...\n"); scan_registry (0, HKEY_CURRENT_USER, (char *) "HKEY_CURRENT_USER", 0, false); scan_registry (0, HKEY_LOCAL_MACHINE, From 9482d18c096192b9ac84ce8df88aab0d8476b523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B8=CC=86=20=D0=9F?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=BE=D0=B2?= Date: Sun, 14 Apr 2019 21:09:17 +0300 Subject: [PATCH 09/13] Rename dll from cygwin to msys --- winsup/cygwin/Makefile.am | 27 ++++++++++++----------- winsup/cygwin/crt0.c | 8 +++++++ winsup/cygwin/cygwin.din | 6 ++--- winsup/cygwin/dcrt0.cc | 4 ++++ winsup/cygwin/dlfcn.cc | 5 +++++ winsup/cygwin/dll_init.cc | 4 ++++ winsup/cygwin/hookapi.cc | 4 ++++ winsup/cygwin/include/cygwin/cygwin_dll.h | 10 ++++----- winsup/cygwin/include/cygwin/version.h | 4 ++++ winsup/cygwin/lib/_cygwin_crt0_common.cc | 4 ++++ winsup/cygwin/lib/crt0.h | 4 ++++ winsup/cygwin/lib/cygwin_attach_dll.c | 8 +++++++ winsup/cygwin/lib/cygwin_crt0.c | 8 +++++++ winsup/cygwin/winver.rc | 2 +- winsup/testsuite/winsup.api/cygload.cc | 10 ++++----- winsup/testsuite/winsup.api/cygload.h | 2 +- winsup/utils/ldd.cc | 2 +- winsup/utils/loadlib.h | 6 ++--- winsup/utils/mingw/cygcheck.cc | 14 ++++++------ winsup/utils/mingw/strace.cc | 2 +- winsup/utils/path.cc | 12 +++++----- winsup/utils/ssp.c | 8 +++---- 22 files changed, 104 insertions(+), 50 deletions(-) diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am index 86b2c51019..41190bdb7a 100644 --- a/winsup/cygwin/Makefile.am +++ b/winsup/cygwin/Makefile.am @@ -42,12 +42,12 @@ newlib_build=$(target_builddir)/newlib toollibdir=$(tooldir)/lib toolincludedir=$(tooldir)/include -# Parameters used in building the cygwin.dll. +# Parameters used in building the msys-2.0.dll. -DLL_NAME=cygwin1.dll -NEW_DLL_NAME=new-cygwin1.dll -DEF_FILE=cygwin.def -LIB_NAME=libcygwin.a +DLL_NAME=msys-2.0.dll +NEW_DLL_NAME=new-msys-2.0.dll +DEF_FILE=msys.def +LIB_NAME=libmsys-2.0.a # # sources @@ -595,16 +595,16 @@ LIBSERVER = $(cygserver_blddir)/libcygserver.a $(LIBSERVER): $(MAKE) -C $(cygserver_blddir) libcygserver.a -# We build as new-cygwin1.dll and rename at install time to overcome native +# We build as new-msys-2.0.dll and rename at install time to overcome native # rebuilding issues (we don't want the build tools to see a partially built -# cygwin1.dll and attempt to use it instead of the old one). +# msys-2.0.dll and attempt to use it instead of the old one). # linker script LDSCRIPT=cygwin.sc $(LDSCRIPT): $(LDSCRIPT).in $(AM_V_GEN)$(CC) -E - -P < $^ -o $@ -# cygwin dll +# msys-2.0 dll # Set PE and export table header timestamps to zero for reproducible builds. $(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) $(LIBSERVER)\ $(newlib_build)/libm.a $(newlib_build)/libc.a @@ -612,18 +612,18 @@ $(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) $(LIBSERVER)\ -mno-use-libstdc-wrappers \ -Wl,--gc-sections -nostdlib -Wl,-T$(LDSCRIPT) -static \ $${SOURCE_DATE_EPOCH:+-Wl,--no-insert-timestamp} \ - -Wl,--heap=0 -Wl,--out-implib,cygdll.a -shared -o $@ \ + -Wl,--heap=0 -Wl,--out-implib,msysdll.a -shared -o $@ \ -e @DLL_ENTRY@ $(DEF_FILE) \ -Wl,-whole-archive libdll.a -Wl,-no-whole-archive \ $(VERSION_OFILES) \ $(LIBSERVER) \ $(newlib_build)/libm.a \ $(newlib_build)/libc.a \ - -lgcc -lkernel32 -lntdll -Wl,-Map,cygwin.map + -lgcc -lkernel32 -lntdll -Wl,-Map,msys.map @$(MKDIR_P) ${target_builddir}/winsup/testsuite/testinst/bin/ $(AM_V_at)$(INSTALL_PROGRAM) $(NEW_DLL_NAME) ${target_builddir}/winsup/testsuite/testinst/bin/$(DLL_NAME) -# cygwin import library +# msys-2.0 import library toolopts=--cpu=@target_cpu@ --ar=@AR@ --as=@AS@ --nm=@NM@ --objcopy=@OBJCOPY@ $(DEF_FILE): scripts/gendef cygwin.din @@ -636,13 +636,14 @@ sigfe.s: $(DEF_FILE) tlsoffsets LIBCOS=$(addsuffix .o,$(basename $(LIB_FILES))) $(LIB_NAME): $(DEF_FILE) $(LIBCOS) | $(NEW_DLL_NAME) - $(AM_V_GEN)$(srcdir)/scripts/mkimport $(toolopts) $(NEW_FUNCTIONS) $@ cygdll.a $(wordlist 2,99,$^) + $(AM_V_GEN)$(srcdir)/scripts/mkimport $(toolopts) $(NEW_FUNCTIONS) $@ msysdll.a $(wordlist 2,99,$^) # sublibs # import libraries for some subset of symbols indicated by given objects speclib=\ $(srcdir)/scripts/speclib $(toolopts) \ --exclude='cygwin' \ + --exclude='msys' \ --exclude='(?i:dll)' \ --exclude='reloc' \ --exclude='^main$$' \ @@ -692,7 +693,7 @@ all-local: $(LIB_NAME) $(SUBLIBS) clean-local: -rm -f $(BUILT_SOURCES) -rm -f $(DEF_FILE) sigfe.s - -rm -f cygwin.sc cygdll.a cygwin.map + -rm -f cygwin.sc msysdll.a msys.map -rm -f $(NEW_DLL_NAME) -rm -f $(LIB_NAME) $(SUBLIBS) -rm -f version.cc diff --git a/winsup/cygwin/crt0.c b/winsup/cygwin/crt0.c index 1096e58970..3160df4491 100644 --- a/winsup/cygwin/crt0.c +++ b/winsup/cygwin/crt0.c @@ -9,12 +9,20 @@ details. */ extern int main (int argc, char **argv); +#ifdef __MSYS__ +void msys_crt0 (int (*main) (int, char **)); +#else void cygwin_crt0 (int (*main) (int, char **)); +#endif void mainCRTStartup () { +#ifdef __MSYS__ + msys_crt0 (main); +#else cygwin_crt0 (main); +#endif /* These are never actually called. They are just here to force the inclusion of things like -lbinmode. */ diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index deac201c08..073b8d07f4 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -1,4 +1,4 @@ -LIBRARY "cygwin1.dll" BASE=0x180040000 +LIBRARY "msys-2.0.dll" BASE=0x180040000 EXPORTS # Exported variables @@ -404,8 +404,8 @@ cygwin_attach_handle_to_fd SIGFE cygwin_conv_path SIGFE cygwin_conv_path_list SIGFE cygwin_create_path SIGFE -cygwin_detach_dll SIGFE_MAYBE -cygwin_dll_init NOSIGFE +msys_detach_dll SIGFE_MAYBE +msys_dll_init NOSIGFE cygwin_internal NOSIGFE cygwin_logon_user SIGFE cygwin_posix_path_list_p NOSIGFE diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index bb864b0204..33cad1e3fe 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -1090,7 +1090,11 @@ dll_crt0 (per_process *uptr) See winsup/testsuite/cygload for an example of how to use cygwin1.dll from MSVC and non-cygwin MinGW applications. */ extern "C" void +#ifdef __MSYS__ +msys_dll_init () +#else cygwin_dll_init () +#endif { static int _fmode; diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index e06616d7fa..40d99ddeff 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -148,8 +148,13 @@ collect_basenames (pathfinder::basenamelist & basenames, /* If the basename starts with "lib", ... */ if (!strncmp (basename, "lib", 3)) { +#ifdef __MSYS__ + /* ... replace "lib" with "msys-", before ... */ + basenames.appendv ("msys-", 5, basename+3, baselen-3, ext, extlen, NULL); +#else /* ... replace "lib" with "cyg", before ... */ basenames.appendv ("cyg", 3, basename+3, baselen-3, ext, extlen, NULL); +#endif } /* ... using original basename with new suffix. */ basenames.appendv (basename, baselen, ext, extlen, NULL); diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 6fae8f1456..4a7c338cf1 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -913,7 +913,11 @@ dll_dllcrt0_1 (VOID *x) } extern "C" void +#ifdef __MSYS__ +msys_detach_dll (dll *) +#else cygwin_detach_dll (dll *) +#endif { HANDLE retaddr; if (_my_tls.isinitialized ()) diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc index ee2edbafee..9f31a716c4 100644 --- a/winsup/cygwin/hookapi.cc +++ b/winsup/cygwin/hookapi.cc @@ -379,7 +379,11 @@ hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h) for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++) { if (!ascii_strcasematch (rva (PSTR, map ?: (char *) hm, pd->Name - delta), +#ifdef __MSYS__ + "msys-2.0.dll")) +#else "cygwin1.dll")) +#endif continue; if (!fn) { diff --git a/winsup/cygwin/include/cygwin/cygwin_dll.h b/winsup/cygwin/include/cygwin/cygwin_dll.h index 1e4cf98ba5..b77598bb63 100644 --- a/winsup/cygwin/include/cygwin/cygwin_dll.h +++ b/winsup/cygwin/include/cygwin/cygwin_dll.h @@ -24,8 +24,8 @@ details. */ CDECL_BEGIN \ int Entry (HINSTANCE h, DWORD reason, void *ptr); \ typedef int (*mainfunc) (int, char **, char **); \ - extern PVOID cygwin_attach_dll (HMODULE, mainfunc); \ - extern void cygwin_detach_dll (PVOID); \ + extern PVOID msys_attach_dll (HMODULE, mainfunc); \ + extern void msys_detach_dll (PVOID); \ CDECL_END \ \ static HINSTANCE storedHandle; \ @@ -42,7 +42,7 @@ static int __dllMain (int a __attribute__ ((__unused__)), \ \ static PVOID dll_index; \ \ -int _cygwin_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ +int _msys_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ { \ int ret; \ ret = 1; \ @@ -55,7 +55,7 @@ int _cygwin_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ storedReason = reason; \ storedPtr = ptr; \ __dynamically_loaded = (ptr == NULL); \ - dll_index = cygwin_attach_dll (h, &__dllMain); \ + dll_index = msys_attach_dll (h, &__dllMain); \ if (dll_index == (PVOID) -1) \ ret = 0; \ } \ @@ -66,7 +66,7 @@ int _cygwin_dll_entry (HINSTANCE h, DWORD reason, void *ptr) \ ret = Entry (h, reason, ptr); \ if (ret) \ { \ - cygwin_detach_dll (dll_index); \ + msys_detach_dll (dll_index); \ dll_index = (PVOID) -1; \ } \ } \ diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 52ed1813de..9e20cbaf3b 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -510,7 +510,11 @@ details. */ names include the CYGWIN_VERSION_SHARED_DATA version as well as this identifier. */ +#ifdef __MSYS__ +#define CYGWIN_VERSION_DLL_IDENTIFIER "msys-2.0" +#else #define CYGWIN_VERSION_DLL_IDENTIFIER "cygwin1" +#endif /* The Cygwin mount table interface in the Win32 registry also has a version number associated with it in case that is changed in a non-backwards diff --git a/winsup/cygwin/lib/_cygwin_crt0_common.cc b/winsup/cygwin/lib/_cygwin_crt0_common.cc index d356a50fba..801b6f91ca 100644 --- a/winsup/cygwin/lib/_cygwin_crt0_common.cc +++ b/winsup/cygwin/lib/_cygwin_crt0_common.cc @@ -73,7 +73,11 @@ struct per_process_cxx_malloc __cygwin_cxx_malloc = and then jump to the dll. */ int +#ifdef __MSYS__ +_msys_crt0_common (MainFunc f, per_process *u) +#else _cygwin_crt0_common (MainFunc f, per_process *u) +#endif { per_process *newu = (per_process *) cygwin_internal (CW_USER_DATA); bool uwasnull; diff --git a/winsup/cygwin/lib/crt0.h b/winsup/cygwin/lib/crt0.h index e599b44934..e81750032b 100644 --- a/winsup/cygwin/lib/crt0.h +++ b/winsup/cygwin/lib/crt0.h @@ -13,7 +13,11 @@ extern "C" { #include "winlean.h" struct per_process; typedef int (*MainFunc) (int argc, char *argv[], char **env); +#ifdef __MSYS__ +int _msys_crt0_common (MainFunc, struct per_process *); +#else int _cygwin_crt0_common (MainFunc, struct per_process *); +#endif PVOID dll_dllcrt0 (HMODULE, struct per_process *); #ifdef __cplusplus diff --git a/winsup/cygwin/lib/cygwin_attach_dll.c b/winsup/cygwin/lib/cygwin_attach_dll.c index 866bfd80fa..82679c4a97 100644 --- a/winsup/cygwin/lib/cygwin_attach_dll.c +++ b/winsup/cygwin/lib/cygwin_attach_dll.c @@ -15,10 +15,18 @@ details. */ /* for a loaded dll */ PVOID +#ifdef __MSYS__ +msys_attach_dll (HMODULE h, MainFunc f) +#else cygwin_attach_dll (HMODULE h, MainFunc f) +#endif { static struct per_process u; +#ifdef __MSYS__ + (void) _msys_crt0_common (f, &u); +#else (void) _cygwin_crt0_common (f, &u); +#endif /* jump into the dll. */ return dll_dllcrt0 (h, &u); diff --git a/winsup/cygwin/lib/cygwin_crt0.c b/winsup/cygwin/lib/cygwin_crt0.c index 7020a639dd..396447e52e 100644 --- a/winsup/cygwin/lib/cygwin_crt0.c +++ b/winsup/cygwin/lib/cygwin_crt0.c @@ -14,8 +14,16 @@ extern void _dll_crt0 () /* for main module */ void +#ifdef __MSYS__ +msys_crt0 (MainFunc f) +#else cygwin_crt0 (MainFunc f) +#endif { +#ifdef __MSYS__ + _msys_crt0_common (f, NULL); +#else _cygwin_crt0_common (f, NULL); +#endif _dll_crt0 (); /* Jump into the dll, never to return */ } diff --git a/winsup/cygwin/winver.rc b/winsup/cygwin/winver.rc index 980d51204c..58878d41bd 100644 --- a/winsup/cygwin/winver.rc +++ b/winsup/cygwin/winver.rc @@ -35,7 +35,7 @@ BEGIN VALUE "InternalName", CYGWIN_DLL_NAME VALUE "LegalCopyright", "Copyright \251 Cygwin Authors 1996-" STRINGIFY(CYGWIN_BUILD_YEAR) VALUE "OriginalFilename", CYGWIN_DLL_NAME - VALUE "ProductName", "Cygwin" + VALUE "ProductName", "MSYS2" VALUE "ProductVersion", STRINGIFY(CYGWIN_VERSION) VALUE "APIVersion", CYGWIN_API_VERSION VALUE "SharedMemoryVersion", STRINGIFY(CYGWIN_VERSION_SHARED_DATA) diff --git a/winsup/testsuite/winsup.api/cygload.cc b/winsup/testsuite/winsup.api/cygload.cc index afd3ee90fc..1b2f79dc05 100644 --- a/winsup/testsuite/winsup.api/cygload.cc +++ b/winsup/testsuite/winsup.api/cygload.cc @@ -25,7 +25,7 @@ save for errors. -testinterrupts Pauses the program for 30 seconds so you can demonstrate that it handles ^C properly. - -cygwin Name of DLL to load. Defaults to "cygwin1.dll". */ + -cygwin Name of DLL to load. Defaults to "msys-2.0.dll". */ #include "cygload.h" #include @@ -154,13 +154,13 @@ cygwin::connector::connector (const char *dll) *out << "Initializing cygwin..." << endl; - // This calls dcrt0.cc:cygwin_dll_init(), which calls dll_crt0_1(), + // This calls dcrt0.cc:msys_dll_init(), which calls dll_crt0_1(), // which will, among other things: // * spawn the cygwin signal handling thread from sigproc_init() // * initialize the thread-local storage for this thread and overwrite // the first 4K of the stack void (*cyginit) (); - get_symbol ("cygwin_dll_init", cyginit); + get_symbol ("msys_dll_init", cyginit); (*cyginit) (); *out << "Loading symbols..." << endl; @@ -224,7 +224,7 @@ cygwin::connector::~connector () // This should call init.cc:dll_entry() with DLL_PROCESS_DETACH. if (!FreeLibrary (_library)) - throw windows_error ("FreeLibrary", "cygwin1.dll"); + throw windows_error ("FreeLibrary", "msys-2.0.dll"); } catch (std::exception &x) { @@ -490,7 +490,7 @@ main (int argc, char *argv[]) std::ostringstream output; bool verbose = false, testinterrupts = false; - const char *dll = "cygwin1.dll"; + const char *dll = "msys-2.0.dll"; out = &output; diff --git a/winsup/testsuite/winsup.api/cygload.h b/winsup/testsuite/winsup.api/cygload.h index 30154048b0..0f2aacda9a 100644 --- a/winsup/testsuite/winsup.api/cygload.h +++ b/winsup/testsuite/winsup.api/cygload.h @@ -76,7 +76,7 @@ namespace cygwin // spawns a thread to let you receive signals from cygwin. class connector { public: - connector (const char *dll = "cygwin1.dll"); + connector (const char *dll = "msys-2.0.dll"); ~connector (); // A wrapper around GetProcAddress() for fetching symbols from the diff --git a/winsup/utils/ldd.cc b/winsup/utils/ldd.cc index 0d073c2989..a31c4c6e44 100644 --- a/winsup/utils/ldd.cc +++ b/winsup/utils/ldd.cc @@ -249,7 +249,7 @@ tocyg (wchar_t *win_fn) return fn; } -#define CYGWIN_DLL_LEN (wcslen (L"\\cygwin1.dll")) +#define CYGWIN_DLL_LEN (wcslen (L"\\msys-2.0.dll")) static int print_dlls (dlls *dll, const wchar_t *dllfn, const wchar_t *process_fn) { diff --git a/winsup/utils/loadlib.h b/winsup/utils/loadlib.h index c83b76478f..42ffbfdc03 100644 --- a/winsup/utils/loadlib.h +++ b/winsup/utils/loadlib.h @@ -13,7 +13,7 @@ #include /* Load all system libs from the windows system directory by prepending the - full path. This doesn't work for loadling cygwin1.dll. For this case, + full path. This doesn't work for loadling msys-2.0.dll. For this case, instead of prepending the path, make sure that the CWD is removed from the DLL search path, if possible (XP SP1++, Vista++). */ static HMODULE _load_sys_library (const wchar_t *dll) __attribute__ ((used)); @@ -45,8 +45,8 @@ _load_sys_library (const wchar_t *dll) set_dll_directory (L""); } - if (wcscmp (dll, L"cygwin1.dll") == 0) - return LoadLibraryExW (L"cygwin1.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (wcscmp (dll, L"msys-2.0.dll") == 0) + return LoadLibraryExW (L"msys-2.0.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH); wcscpy (dllpath, sysdir); wcscpy (dllpath + sysdir_len, dll); diff --git a/winsup/utils/mingw/cygcheck.cc b/winsup/utils/mingw/cygcheck.cc index 8a5329026f..47636df3b1 100644 --- a/winsup/utils/mingw/cygcheck.cc +++ b/winsup/utils/mingw/cygcheck.cc @@ -779,7 +779,7 @@ dll_info (const char *path, HANDLE fh, int lvl, int recurse) } } } - if (strstr (path, "\\cygwin1.dll")) + if (strstr (path, "\\msys-2.0.dll")) cygwin_info (fh); } @@ -1330,7 +1330,7 @@ handle_reg_installation (handle_reg_t what) if (what == PRINT_KEY) printf (" %s Key: %s Path: %s", i ? "User: " : "System:", name, path); - strcat (path, "\\bin\\cygwin1.dll"); + strcat (path, "\\bin\\msys-2.0.dll"); if (what == PRINT_KEY) printf ("%s\n", access (path, F_OK) ? " (ORPHANED)" : ""); else if (access (path, F_OK)) @@ -1979,10 +1979,10 @@ dump_sysinfo () wcstombs (f, ffinfo.cFileName, sizeof f); if (strcasecmp (f + strlen (f) - 4, ".dll") == 0) { - if (strncasecmp (f, "cyg", 3) == 0) + if (strncasecmp (f, "msys-", 5) == 0) { sprintf (tmp, "%s%s", pth->dir, f); - if (strcasecmp (f, "cygwin1.dll") == 0) + if (strcasecmp (f, "msys-2.0.dll") == 0) { if (!cygwin_dll_count) strcpy (cygdll_path, pth->dir); @@ -2006,9 +2006,9 @@ dump_sysinfo () FindClose (ff); } if (cygwin_dll_count > 1) - puts ("Warning: There are multiple cygwin1.dlls on your path"); + puts ("Warning: There are multiple msys-2.0.dlls on your path"); if (!cygwin_dll_count) - puts ("Warning: cygwin1.dll not found on your path"); + puts ("Warning: msys-2.0.dll not found on your path"); dump_dodgy_apps (verbose); @@ -3022,7 +3022,7 @@ load_cygwin (int& argc, char **&argv) { HMODULE h; - if (!(h = LoadLibrary ("cygwin1.dll"))) + if (!(h = LoadLibrary ("msys-2.0.dll"))) return; GetModuleFileNameW (h, cygwin_dll_path, 32768); if ((cygwin_internal = (uintptr_t (*) (cygwin_getinfo_types, ...)) diff --git a/winsup/utils/mingw/strace.cc b/winsup/utils/mingw/strace.cc index c239937be2..0eae6f02dd 100644 --- a/winsup/utils/mingw/strace.cc +++ b/winsup/utils/mingw/strace.cc @@ -284,7 +284,7 @@ load_cygwin () if (h) return 0; - if (!(h = LoadLibrary ("cygwin1.dll"))) + if (!(h = LoadLibrary ("msys-2.0.dll"))) { errno = ENOENT; return 0; diff --git a/winsup/utils/path.cc b/winsup/utils/path.cc index fe55a646d9..323e4c784b 100644 --- a/winsup/utils/path.cc +++ b/winsup/utils/path.cc @@ -585,14 +585,14 @@ read_mounts () } max_mount_entry = 0; - /* First fetch the cygwin1.dll path from the LoadLibrary call in load_cygwin. - This utilizes the DLL search order to find a matching cygwin1.dll and to + /* First fetch the msys-2.0.dll path from the LoadLibrary call in load_cygwin. + This utilizes the DLL search order to find a matching msys-2.0.dll and to compute the installation path from that DLL's path. */ if (cygwin_dll_path[0]) wcscpy (path, cygwin_dll_path); - /* If we can't load cygwin1.dll, check where cygcheck is living itself and - try to fetch installation path from here. Does cygwin1.dll exist in the - same path? This should only kick in if the cygwin1.dll in the same path + /* If we can't load msys-2.0.dll, check where cygcheck is living itself and + try to fetch installation path from here. Does msys-2.0.dll exist in the + same path? This should only kick in if the msys-2.0.dll in the same path has been made non-executable for the current user accidentally. */ else if (!GetModuleFileNameW (NULL, path, 32768)) return; @@ -601,7 +601,7 @@ read_mounts () { if (!cygwin_dll_path[0]) { - wcscpy (path_end, L"\\cygwin1.dll"); + wcscpy (path_end, L"\\msys-2.0.dll"); DWORD attr = GetFileAttributesW (path); if (attr == (DWORD) -1 || (attr & (FILE_ATTRIBUTE_DIRECTORY diff --git a/winsup/utils/ssp.c b/winsup/utils/ssp.c index 96a90a1d98..95045e1e8b 100644 --- a/winsup/utils/ssp.c +++ b/winsup/utils/ssp.c @@ -710,15 +710,15 @@ usage (FILE * stream) "You must specify the range of memory addresses to keep track of\n" "manually, but it's not hard to figure out what to specify. Use the\n" "\"objdump\" program to determine the bounds of the target's \".text\"\n" - "section. Let's say we're profiling cygwin1.dll. Make sure you've\n" + "section. Let's say we're profiling msys-2.0.dll. Make sure you've\n" "built it with debug symbols (else gprof won't run) and run objdump\n" "like this:\n" "\n" - " objdump -h cygwin1.dll\n" + " objdump -h msys-2.0.dll\n" "\n" "It will print a report like this:\n" "\n" - "cygwin1.dll: file format pei-i386\n" + "msys-2.0.dll: file format pei-i386\n" "\n" "Sections:\n" "Idx Name Size VMA LMA File off Algn\n" @@ -749,7 +749,7 @@ usage (FILE * stream) "\"gmon.out\". You can turn this data file into a readable report with\n" "gprof:\n" "\n" - " gprof -b cygwin1.dll\n" + " gprof -b msys-2.0.dll\n" "\n" "The \"-b\" means 'skip the help pages'. You can omit this until you're\n" "familiar with the report layout. The gprof documentation explains\n" From 88b485b551455b126858bad40a957fe81e8068e2 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 8 Apr 2026 19:28:06 +0800 Subject: [PATCH 10/13] Revert "Add support for MSYS environment variable instead of CYGWIN" This reverts commit 3e941b8ea19d21cf95d55f97770e530045e258f4. --- winsup/cygwin/environ.cc | 15 +-------------- winsup/cygwin/exceptions.cc | 4 ++-- winsup/utils/mingw/cygcheck.cc | 3 ++- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 4e049211e9..6233ab76a3 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -201,11 +201,7 @@ parse_options (const char *inbuf) if (export_settings) { debug_printf ("%s", newbuf + 1); -#ifdef __MSYS__ - setenv ("MSYS", newbuf + 1, 1); -#else setenv ("CYGWIN", newbuf + 1, 1); -#endif } return; } @@ -678,7 +674,7 @@ _addenv (const char *name, const char *value, int overwrite) win_env *spenv; if ((spenv = getwinenv (envhere))) spenv->add_cache (value); - if (strcmp (name, "MSYS") == 0) + if (strcmp (name, "CYGWIN") == 0) parse_options (value); return 0; @@ -877,11 +873,7 @@ environ_init (char **envp, int envc) dumper_init (); if (envp_passed_in) { -#ifdef __MSYS__ - p = getenv ("MSYS"); -#else p = getenv ("CYGWIN"); -#endif if (p) parse_options (p); } @@ -937,13 +929,8 @@ win32env_to_cygenv (PWCHAR rawenv, bool posify) } sawTERM = 1; } -#ifdef __MSYS__ - else if (*newp == 'M' && strncmp (newp, "MSYS=", 5) == 0) - parse_options (newp + 5); -#else else if (*newp == 'C' && strncmp (newp, "CYGWIN=", 7) == 0) parse_options (newp + 7); -#endif if (*eq && posify) posify_maybe (envp + i, *++eq ? eq : --eq, tmpbuf); debug_printf ("%p: %s", envp[i], envp[i]); diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index bdbf443c9b..5e05f6fbbb 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -529,14 +529,14 @@ int exec_prepared_command (PWCHAR command) PWCHAR rawenv = GetEnvironmentStringsW () ; for (PWCHAR p = rawenv; *p != L'\0'; p = wcschr (p, L'\0') + 1) { - if (wcsncmp (p, L"MSYS=", wcslen (L"MSYS=")) == 0) + if (wcsncmp (p, L"CYGWIN=", wcslen (L"CYGWIN=")) == 0) { PWCHAR q = wcsstr (p, L"error_start") ; /* replace 'error_start=...' with '_rror_start=...' */ if (q) { *q = L'_' ; - SetEnvironmentVariableW (L"MSYS", p + wcslen (L"MSYS=")) ; + SetEnvironmentVariableW (L"CYGWIN", p + wcslen (L"CYGWIN=")) ; } break; } diff --git a/winsup/utils/mingw/cygcheck.cc b/winsup/utils/mingw/cygcheck.cc index 47636df3b1..d12a379f83 100644 --- a/winsup/utils/mingw/cygcheck.cc +++ b/winsup/utils/mingw/cygcheck.cc @@ -95,6 +95,8 @@ static const char *known_env_vars[] = { "c_include_path", "compiler_path", "cxx_include_path", + "cygwin", + "cygwin32", "dejagnu", "expect", "gcc_default_options", @@ -106,7 +108,6 @@ static const char *known_env_vars[] = { "lpath", "make_mode", "makeflags", - "msys", "path", "pwd", "strace", From 86ad1e065cdb9d8afe6520ebe7aa170ee5a5c6ae Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Fri, 16 Jan 2026 11:36:27 +0800 Subject: [PATCH 11/13] Support for both MSYS and CYGWIN environment variable This is a prepare for merge msys2 into cygwin --- winsup/cygwin/environ.cc | 28 +++++++++++++++++++++------- winsup/cygwin/exceptions.cc | 11 +++++++++++ winsup/utils/mingw/cygcheck.cc | 1 + 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 6233ab76a3..87813e2207 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -180,7 +180,7 @@ strbrk(char *&buf) /* Parse a string of the form "something=stuff somethingelse=more-stuff", silently ignoring unknown "somethings". */ static void -parse_options (const char *inbuf) +parse_options (const char *inbuf, bool is_msys2) { int istrue; parse_thing *k; @@ -201,7 +201,10 @@ parse_options (const char *inbuf) if (export_settings) { debug_printf ("%s", newbuf + 1); - setenv ("CYGWIN", newbuf + 1, 1); + if (is_msys2) + setenv ("MSYS", newbuf + 1, 1); + else + setenv ("CYGWIN", newbuf + 1, 1); } return; } @@ -674,8 +677,10 @@ _addenv (const char *name, const char *value, int overwrite) win_env *spenv; if ((spenv = getwinenv (envhere))) spenv->add_cache (value); + if (strcmp (name, "MSYS") == 0) + parse_options (value, true); if (strcmp (name, "CYGWIN") == 0) - parse_options (value); + parse_options (value, false); return 0; } @@ -873,9 +878,12 @@ environ_init (char **envp, int envc) dumper_init (); if (envp_passed_in) { + p = getenv ("MSYS"); + if (p) + parse_options (p, true); p = getenv ("CYGWIN"); if (p) - parse_options (p); + parse_options (p, false); } } __except (NO_ERROR) @@ -929,8 +937,10 @@ win32env_to_cygenv (PWCHAR rawenv, bool posify) } sawTERM = 1; } + else if (*newp == 'M' && strncmp (newp, "MSYS=", 5) == 0) + parse_options (newp + 5, true); else if (*newp == 'C' && strncmp (newp, "CYGWIN=", 7) == 0) - parse_options (newp + 7); + parse_options (newp + 7, false); if (*eq && posify) posify_maybe (envp + i, *++eq ? eq : --eq, tmpbuf); debug_printf ("%p: %s", envp[i], envp[i]); @@ -1193,8 +1203,12 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, #ifdef __MSYS__ if (ascii_strncasematch(*srcp, "MSYS=", 5)) { - parse_options (*srcp + 5); - } + parse_options (*srcp + 5, true); + } + else if (ascii_strncasematch(*srcp, "CYGWIN=", 7)) + { + parse_options (*srcp + 7, false); + } else if (!keep_posix) { /* Don't pass timezone environment to non-msys applications */ diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 5e05f6fbbb..1debcb28fe 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -540,6 +540,17 @@ int exec_prepared_command (PWCHAR command) } break; } + if (wcsncmp (p, L"MSYS=", wcslen (L"MSYS=")) == 0) + { + PWCHAR q = wcsstr (p, L"error_start") ; + /* replace 'error_start=...' with '_rror_start=...' */ + if (q) + { + *q = L'_' ; + SetEnvironmentVariableW (L"MSYS", p + wcslen (L"MSYS=")) ; + } + break; + } } FreeEnvironmentStringsW (rawenv); diff --git a/winsup/utils/mingw/cygcheck.cc b/winsup/utils/mingw/cygcheck.cc index d12a379f83..9f0cb08ab3 100644 --- a/winsup/utils/mingw/cygcheck.cc +++ b/winsup/utils/mingw/cygcheck.cc @@ -108,6 +108,7 @@ static const char *known_env_vars[] = { "lpath", "make_mode", "makeflags", + "msys", "path", "pwd", "strace", From 2ea6dbc4b31a9af5043ee48d5e1492f4cd957229 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Fri, 10 Apr 2026 03:49:16 +0800 Subject: [PATCH 12/13] Revert hookapi.cc of "Rename dll from cygwin to msys" --- winsup/cygwin/hookapi.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc index 9f31a716c4..ee2edbafee 100644 --- a/winsup/cygwin/hookapi.cc +++ b/winsup/cygwin/hookapi.cc @@ -379,11 +379,7 @@ hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h) for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++) { if (!ascii_strcasematch (rva (PSTR, map ?: (char *) hm, pd->Name - delta), -#ifdef __MSYS__ - "msys-2.0.dll")) -#else "cygwin1.dll")) -#endif continue; if (!fn) { From fd5ce305d44723feb3e60c927295d5973ee7692b Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 7 Jan 2026 17:08:33 +0800 Subject: [PATCH 13/13] hookapi.c: Support for both cygwin and msys2 for bootstrap This is for bootstrap building msys2 as cygwin1.dll This can be rebased before "Rename dll from cygwin to msys" --- winsup/cygwin/hookapi.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc index ee2edbafee..49974f8c32 100644 --- a/winsup/cygwin/hookapi.cc +++ b/winsup/cygwin/hookapi.cc @@ -378,9 +378,10 @@ hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h) // Iterate through each import descriptor, and redirect if appropriate for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++) { - if (!ascii_strcasematch (rva (PSTR, map ?: (char *) hm, pd->Name - delta), - "cygwin1.dll")) - continue; + char *name_to_compare = rva (PSTR, map ?: (char *) hm, pd->Name - delta); + bool not_msys2 = !ascii_strcasematch (name_to_compare, "msys-2.0.dll"); + bool not_cygwin = !ascii_strcasematch (name_to_compare, "cygwin1.dll"); + if (not_msys2 && not_cygwin) continue; if (!fn) { /* Just checking if executable used cygwin1.dll. */