[Sorry not to add to this thread sooner. Exams have been keeping me
unavoidably busy.]
AFAIK, using multiple independent Cygwin environments simultaneously is
impossible without recompiling a modified cygwin1.dll under a different
name, and then either recompiling or hex-editing every dll and exe you wish
to use in the modified environment to load the alternative dll name.

Obviously, this is a non-trivial operation (and I haven't started discussing
the modifications to the cygwin dll yet.) Anyone attempting this should be
aware that the cygwin list does not support modified versions of cygwin.

----------------------------------------------------------------------------
------------
Sidenote to Michael Hale:
Why not just compile a "last known good" list of package versions, maintain
an internal mirror, and tell your developers "use a recent version of
cygwin, fall back to the known good versions if you have problems"? That
would seem achieve most of your goals with a *lot* less pain.
----------------------------------------------------------------------------
------------

OK, so if you still think that modifying the Cygwin dll is a good idea, and
are prepared to receive limited, if any, support from this list:

*** Be warned that this info is incomplete! It used to work, some time in
the past, but when I tested it, I got a broken modified bash, that couldn't
start any subprocesses. So if you are prepared to take my work and enhance
it, please go ahead! (Naturally I'd quite like to know if any successes are
made). But do not think that the below text is a cookbook solution. ***

For the most part, the changes are a careful manually-directed search and
replace through the winsup/cygwin (and possibly winsup/utils) directories.

The remaining issue is one Igor indirectly referred to. If you run a
modified cygwin process from an unmodified one, or vice versa, you still get
version mismatches. The problem is the child_info struct, aka the
lpReserved2 data in CreateProcess. Here's a nice webpage I found:
http://www.catch22.org.uk/tuts/undoc01.asp

Extremely fortunately for our purposes, only 4 bytes of leading zeros are
required to avoid the nasty Microsoft C-runtime interactions mentioned in
that webpage, whilst Cygwin uses 16 bytes. We can therefore use the
intermediate 12 bytes to fill with our own magic number, isolating us both
from official Cygwin and from Microsoft C-runtime apps.

At least, it did, a long time ago.
Attached is my patch, updated to apply cleanly (though not to work!) with
current CVS.

Have fun!
Don't bother the list with "this is broken, help me fix it" emails.
Let me know of any progress.

Max.
Index: winsup/cygwin/Makefile.in
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/cygwin/Makefile.in,v
retrieving revision 1.163
diff -u -p -r1.163 Makefile.in
--- winsup/cygwin/Makefile.in   4 May 2004 15:09:58 -0000       1.163
+++ winsup/cygwin/Makefile.in   29 May 2004 08:58:46 -0000
@@ -89,7 +89,7 @@ RUNTESTFLAGS =
 # native rebuilding issues (we don't want the build tools to see a partially
 # built cygwin.dll and attempt to use it instead of the old one).
 
-DLL_NAME:=cygwin1.dll
+DLL_NAME:=mygwin1.dll
 TEST_DLL_NAME:=cygwin0.dll
 TEST_LIB_NAME:=libcygwin0.a
 DEF_FILE:=cygwin.def
@@ -379,7 +379,7 @@ $(LIB_NAME): rmsym newsym $(TEST_DLL_NAM
 # dependency set to $(LIB_NAME) to accommodate make -j2.
 # Otherwise dlltool gets confused. cgf (11-16-2000)
 $(TEST_LIB_NAME): $(LIB_NAME)
-       perl -p -e 'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $? 
> $@
+       perl -p -e 'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/mygwin1/cygwin0/g' < $? 
> $@
 
 $(LIBSERVER): $(bupdir)/cygserver/Makefile
        $(MAKE) -C $(bupdir)/cygserver libcygserver.a
Index: winsup/cygwin/cygwin.din
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/cygwin/cygwin.din,v
retrieving revision 1.119
diff -u -p -r1.119 cygwin.din
--- winsup/cygwin/cygwin.din    25 May 2004 03:21:34 -0000      1.119
+++ winsup/cygwin/cygwin.din    29 May 2004 08:58:46 -0000
@@ -1,4 +1,4 @@
-LIBRARY "cygwin1.dll" BASE=0x61000000
+LIBRARY "mygwin1.dll" BASE=0x61000000
 
 EXPORTS
 __argc DATA
Index: winsup/cygwin/dcrt0.cc
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/cygwin/dcrt0.cc,v
retrieving revision 1.219
diff -u -p -r1.219 dcrt0.cc
--- winsup/cygwin/dcrt0.cc      28 May 2004 19:50:05 -0000      1.219
+++ winsup/cygwin/dcrt0.cc      29 May 2004 08:58:46 -0000
@@ -587,7 +587,11 @@ dll_crt0_0 ()
   wincap.init ();
   initial_env ();
 
-  char zeros[sizeof (child_proc_info->zero)] = {0};
+  char zeros[sizeof (child_proc_info->zero)] = { (DWORD) 0,
+    (DWORD) 0x783bc8a7,
+    (DWORD) 0x82bdc845,
+    (DWORD) 0x1823ef8f,
+  };
 
   init_console_handler ();
   init_global_security ();
@@ -1171,8 +1175,8 @@ multiple_cygwin_problem (const char *wha
     system_printf ("%s magic number mismatch detected - %p/%p", what, magic_version, 
version);
   else
     api_fatal ("%s version mismatch detected - %p/%p.\n\
-You have multiple copies of cygwin1.dll on your system.\n\
-Search for cygwin1.dll using the Windows Start->Find/Search facility\n\
+You have multiple copies of mygwin1.dll on your system.\n\
+Search for mygwin1.dll using the Windows Start->Find/Search facility\n\
 and delete all but the most recent version.  The most recent version *should*\n\
 reside in x:\\cygwin\\bin, where 'x' is the drive on which you have\n\
 installed the cygwin distribution.", what, magic_version, version);
Index: winsup/cygwin/exceptions.cc
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/cygwin/exceptions.cc,v
retrieving revision 1.216
diff -u -p -r1.216 exceptions.cc
--- winsup/cygwin/exceptions.cc 28 May 2004 19:50:05 -0000      1.216
+++ winsup/cygwin/exceptions.cc 29 May 2004 08:58:46 -0000
@@ -133,7 +133,7 @@ error_start_init (const char *buf)
 
   char pgm[CYG_MAX_PATH + 1];
   if (!GetModuleFileName (NULL, pgm, CYG_MAX_PATH))
-    strcpy (pgm, "cygwin1.dll");
+    strcpy (pgm, "mygwin1.dll");
   for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\'))
     *p = '/';
 
Index: winsup/cygwin/newsym
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/cygwin/newsym,v
retrieving revision 1.5
diff -u -p -r1.5 newsym
--- winsup/cygwin/newsym        7 Jul 2003 05:30:33 -0000       1.5
+++ winsup/cygwin/newsym        29 May 2004 08:58:46 -0000
@@ -16,7 +16,7 @@ _$newsym:
        jmp     *__imp__$oldsym
 
        .section .idata\$7
-       .long   __head_cygwin1_dll
+       .long   __head_mygwin1_dll
 
         .section        .idata\$5
 __imp__$newsym:        .rva    1f
Index: winsup/cygwin/sigproc.cc
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/cygwin/sigproc.cc,v
retrieving revision 1.198
diff -u -p -r1.198 sigproc.cc
--- winsup/cygwin/sigproc.cc    28 May 2004 19:50:06 -0000      1.198
+++ winsup/cygwin/sigproc.cc    29 May 2004 08:58:46 -0000
@@ -857,6 +857,9 @@ void __stdcall
 init_child_info (DWORD chtype, child_info *ch, pid_t pid, HANDLE subproc_ready)
 {
   memset (ch, 0, sizeof *ch);
+  ch->zero[1] = 0x783bc8a7;
+  ch->zero[2] = 0x82bdc845;
+  ch->zero[3] = 0x1823ef8f;
   ch->cb = chtype == PROC_FORK ? sizeof (child_info_fork) : sizeof (child_info);
   ch->intro = PROC_MAGIC_GENERIC;
   ch->magic = CHILD_INFO_MAGIC;
Index: winsup/cygwin/speclib
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/cygwin/speclib,v
retrieving revision 1.13
diff -u -p -r1.13 speclib
--- winsup/cygwin/speclib       28 Nov 2003 20:51:11 -0000      1.13
+++ winsup/cygwin/speclib       29 May 2004 08:58:46 -0000
@@ -44,9 +44,9 @@ BEGIN {
     binmode STDOUT;
     $lib = ($ENV{lib} =~ m!/([^/]+)$!o)[0] || $ENV{lib};
     $lib =~ s/\.a//o;
-    my $pad = length('cygwin1_dll') - length($lib);
+    my $pad = length('mygwin1_dll') - length($lib);
     die "speclib: library name too long (" . length($lib) . ")\n" if $pad < 0;
     $lib = "__head_$lib" . "\0" x $pad;
 }
-    s/__head_cygwin1_dll/$lib/g;
+    s/__head_mygwin1_dll/$lib/g;
 EOF
Index: winsup/cygwin/include/cygwin/version.h
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/cygwin/include/cygwin/version.h,v
retrieving revision 1.168
diff -u -p -r1.168 version.h
--- winsup/cygwin/include/cygwin/version.h      25 May 2004 20:00:19 -0000      1.168
+++ winsup/cygwin/include/cygwin/version.h      29 May 2004 08:58:46 -0000
@@ -265,7 +265,7 @@ details. */
        The full names include the CYGWIN_VERSION_SHARED_DATA version
        as well as this identifier. */
 
-#define CYGWIN_VERSION_DLL_IDENTIFIER  "cygwin1"
+#define CYGWIN_VERSION_DLL_IDENTIFIER  "mygwin1"
 
      /* The Cygwin mount table interface in the Win32 registry also
        has a version number associated with it in case that is
@@ -282,7 +282,7 @@ details. */
      /* Identifiers used in the Win32 registry. */
 
 #define CYGWIN_INFO_CYGNUS_REGISTRY_NAME "Cygnus Solutions"
-#define CYGWIN_INFO_CYGWIN_REGISTRY_NAME "Cygwin"
+#define CYGWIN_INFO_CYGWIN_REGISTRY_NAME "Mygwin"
 #define CYGWIN_INFO_PROGRAM_OPTIONS_NAME "Program Options"
 #define CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME "mounts v2"
 #define CYGWIN_INFO_CYGDRIVE_FLAGS "cygdrive flags"
Index: winsup/utils/cygcheck.cc
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/utils/cygcheck.cc,v
retrieving revision 1.43
diff -u -p -r1.43 cygcheck.cc
--- winsup/utils/cygcheck.cc    21 Mar 2004 17:58:14 -0000      1.43
+++ winsup/utils/cygcheck.cc    29 May 2004 08:58:46 -0000
@@ -523,7 +523,7 @@ dll_info (const char *path, HANDLE fh, i
            }
        }
     }
-  if (strstr (path, "\\cygwin1.dll"))
+  if (strstr (path, "\\mygwin1.dll"))
     cygwin_info (fh);
 }
 
@@ -1223,7 +1223,7 @@ dump_sysinfo ()
              if (strncasecmp (f, "cyg", 3) == 0)
                {
                  sprintf (tmp, "%s\\%s", paths[i], f);
-                 if (strcasecmp (f, "cygwin1.dll") == 0)
+                 if (strcasecmp (f, "mygwin1.dll") == 0)
                    found_cygwin_dll = strdup (tmp);
                  else
                    ls (tmp);
Index: winsup/utils/strace.cc
===================================================================
RCS file: /home/mirror/cvsmirror/src-cvs/src/winsup/utils/strace.cc,v
retrieving revision 1.33
diff -u -p -r1.33 strace.cc
--- winsup/utils/strace.cc      21 Feb 2004 04:51:15 -0000      1.33
+++ winsup/utils/strace.cc      29 May 2004 08:58:46 -0000
@@ -268,7 +268,7 @@ load_cygwin ()
   if (h)
     return 0;
 
-  if (!(h = LoadLibrary ("cygwin1.dll")))
+  if (!(h = LoadLibrary ("mygwin1.dll")))
     {
       errno = ENOENT;
       return 0;

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply via email to