Re: [GHC] #1560: Windows CreateProcess quotes bug; make re-executing itself fails

2007-07-30 Thread GHC
#1560: Windows CreateProcess quotes bug; make re-executing itself fails
--+-
Reporter:  igloo  |Owner: 
Type:  bug|   Status:  closed 
Priority:  high   |Milestone:  6.8
   Component:  libraries (other)  |  Version:  6.6.1  
Severity:  normal |   Resolution:  fixed  
Keywords: |   Difficulty:  Unknown
  Os:  Windows| Testcase: 
Architecture:  Unknown|  
--+-
Changes (by simonmar):

  * resolution:  => fixed
  * status:  new => closed

Comment:

 Fixed (or at least worked around), by:

 {{{
 Mon Jul 30 06:43:46 PDT 2007  Simon Marlow <[EMAIL PROTECTED]>
   * FIX #1559, #1560.  Rearrange the way we do ifBuildable...
   ifBuildable now returns an exit code, with 1 indicating an unbuildable
   non-core package, and 0 otherwise.  Hence we can now invoke the
   recursive make from the shell, sidestepping the problems in #1559 and
   #1560.
 }}}

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #1560: Windows CreateProcess quotes bug; make re-executing itself fails

2007-07-25 Thread GHC
#1560: Windows CreateProcess quotes bug; make re-executing itself fails
+---
  Reporter:  igloo  |  Owner: 
  Type:  bug| Status:  new
  Priority:  high   |  Milestone:  6.8
 Component:  libraries (other)  |Version:  6.6.1  
  Severity:  normal |   Keywords: 
Difficulty:  Unknown| Os:  Windows
  Testcase: |   Architecture:  Unknown
+---
Something very odd is going on with the way we run other programs on
 Windows (msys/mingw).
 The following session shows that, regardless of whether or not we put
 quotes around the program we want to run when calling `CreateProcess`,
 there are no quotes in `argv[0]`. However, when make comes to reinvoke
 itself (after building any 'include'ed Makefiles) it has managed to find
 the quotes and fails to execute '"make"'.

 This should be fairly easy to debug, except I cannot build the make that
 it is using.
 The failure is shown even further down.

 The re-execution happens around line 1934 in the source I have:
 {{{
   char **p;
   fputs (_("Re-executing:"), stdout);
   for (p = nargv; *p != 0; ++p)
 printf (" %s", *p);
   putchar ('\n');
 }}}

 If anyone can work out where the quotes come from, can make a small
 program that exhibits the same problem or has any idea what the problem
 with building make is, then please let me know!


 Thanks

 Ian

 {{{
 $ gcc --version
 gcc.exe (GCC) 3.4.2 (mingw-special)
 Copyright (C) 2004 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.

 $ make --version
 GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
 Built for i686-pc-msys
 Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.
 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
 PARTICULAR PURPOSE.

 Report bugs to <[EMAIL PROTECTED]>.

 $ cat Makefile

 .PHONY: foo
 foo:
 echo hello $(VAR) world
 rm -f include.Makefile

 include include.Makefile
 include.Makefile:
 echo "VAR=val" > $@

 $ cat show_args.c
 #include 

 int main(int argc, char *argv[]) {
 int i;
 printf("argc = %d\n", argc);
 for (i = 0; i < argc; i++) {
 printf("argv[%d] = %s\n", i, argv[i]);
 }
 return 0;
 }

 $ cat test.c
 #include 
 #include 

 int foo(char *cmdline) {
 int r;
 int flags = 0;
 void *environment = NULL;
 void *workingDirectory = NULL;

 STARTUPINFO si;
 PROCESS_INFORMATION pi;

 ZeroMemory(&si, sizeof(si));
 si.cb = sizeof(si);
 ZeroMemory(&pi, sizeof(pi));

 printf("\n");
 printf("*** cmdline = %s\n", cmdline);
 fflush(stdout);
 r = CreateProcess(NULL, cmdline, NULL, NULL, TRUE, flags, environment,
 workingDirectory, &si, &pi);
 printf("*** r = %d\n", r);
 fflush(stdout);
 WaitForSingleObject(pi.hProcess, INFINITE);
 CloseHandle(pi.hProcess);
 CloseHandle(pi.hThread);
 }

 int main(int argc, char *argv[]) {
 foo("./show_args a b c");
 foo("\"./show_args\" a b c");
 foo("make -dr");
 foo("\"make\" -dr");
 return 0;
 }

 $ gcc show_args.c -o show_args
 $ gcc test.c -o test
 $ ./test.exe
 
 *** cmdline = ./show_args a b c
 *** r = 1
 argc = 4
 argv[0] = ./show_args
 argv[1] = a
 argv[2] = b
 argv[3] = c
 
 *** cmdline = "./show_args" a b c
 *** r = 1
 argc = 4
 argv[0] = ./show_args
 argv[1] = a
 argv[2] = b
 argv[3] = c
 
 *** cmdline = make -dr
 *** r = 1
 GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
 Built for i686-pc-msys
 Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.
 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
 PARTICULAR PURPOSE.

 Report bugs to <[EMAIL PROTECTED]>.

 Reading makefiles...
 Reading makefile `Makefile'...
 Reading makefile `include.Makefile' (search path) (no ~ expansion)...
 Makefile:7: include.Makefile: No such file or directory
 Updating makefiles
  Considering target file `include.Makefile'.
   File `include.Makefile' does not exist.
   Finished prerequisites of target file `include.Makefile'.
  Must remake target `include.Makefile'.
 echo "VAR=val" > include.Makefile
 Putting child 0x0a0158b0 (include.Makefile) PID 2476 on the chain.
 Live child 0x