This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Import include/filenames.h from BFD (Windows/DJGPP testers needed)
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, dj at redhat dot com
- Date: Thu, 3 Jul 2003 09:06:54 +1000 (EST)
- Subject: Re: Import include/filenames.h from BFD (Windows/DJGPP testers needed)
Zack Weinberg wrote:
> FYI, I have checked in include/filenames.h, which cannot break
> anything by its mere presence. I am still looking for testers
> for the gcc part of the patch.
>
> zw
>
I've tested your patch with mingw32 bootstrap (c,c++ only) and no problems
on NT operating systems. However, I expect there will be problems on Win9x
and WinMe because of differences in handling of '/' vs '\\' and the
reversal of DIR_SEPARATOR and DIR_SEPARATOR_2 for mingw32.
I tried that reversal in mingw distros of gcc before and got heaps of bug
reports. This is why:
On NT '/' and '\\' can be used interchangeably in CreateProcess, the
win32 API function that handles spawn* and exec* families of functions.
>From what I've found out through trial-and-error: On Win9x and WinME,
they can be used interchangeably _iff_ the first element of the
argument vector (the pathname of the executable) is _not_ quoted. If it
is quoted, the use of '/' causes problems. (I don't know why: maybe is
has something to do the use of /c etc as switches in the command /c syntax).
Now, libiberty's pexecute takes great care to ensure that the argument
is quoted. Why? Because windows encourages users to put spaces in their
filenames and without quotes
C:/Program Files/mingw/bin/gcc.exe
is treated as two strings. You can't win.
When we compile gcc -v foo.c, the behaviour with your patch is:
gcc version 3.4 20030701 (experimental)
D:/MINGW/BIN/../lib/gcc-lib/mingw32/3.4/cc1.exe -quiet -v -iprefix
D:\MINGW\BIN/../lib/gcc-lib/mingw32/3.4/ foo.c -quiet -dumpbase foo.c -auxbase foo -version -o
D:\TEMP/cc9daaaa.s
#include "..." search starts here:
#include <...> search starts here:
D:/MINGW/include
D:/MINGW/lib/gcc-lib/mingw32/3.4/include
D:/MINGW/mingw32/include
/mingw/include
/mingw/include
/mingw/lib/gcc-lib/mingw32/3.4/include
/mingw/mingw32/include
/mingw/include
End of search list.
GNU C version 3.4 20030701 (experimental) (mingw32)
compiled by GNU C version 3.4 20030701 (experimental).
GGC heuristics: --param ggc-min-expand=34 --param ggc-min-heapsize=8118
D:/MINGW/BIN/../lib/gcc-lib/mingw32/3.4/../../../../mingw32/bin/as.exe
...
etc
This works fine on NT. On Win9X, it won't because of the passing of the
the first element of the argument vector like
"D:/MINGW/BIN/../lib/gcc-lib/mingw32/3.4/cc1.exe"
through spawnv
I'd like to have the primary DIR_SEPARATOR as '/' rather '\\' because
having '/' simplifies generating dependencies (some versions of make
have problems with '\\'). Also when using gcc -v in configure scripts,
having everyting in standard form simplifies the detection of ld and as
paths. Finally, using '\\' as DIR_SEPARATOR used to tweak a preprocessor
bug in C++ code where a '\\' in __FILE__ was sometimes treated like a
line-continuation. That bug is gone now, but.
FWIW, the only place that I've seen '/' as DIR_SEPARATOR causing problems
on Win9x is in gcc.c's execute().
The following patch to libiberty/pex-win32.c, combined with your patch,
causes no regression on NT and should allow #define DIR_SEPARATOR '/' to
work on Win9x. Unfortunately, I no longer have access to Win9x to test
properly. Can someone help?
Danny
Changelog
2003-07-03 Danny Smith <dannysmith@users.sourceforge.net>
* pex-win32.c (fix_argv): Ensure that the executable pathname
uses Win32 backslashes.
(pexecute): Cast away constness when assigning *errmsg_arg.
Index: pex-win32.c
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/pex-win32.c,v
retrieving revision 1.1
diff -c -3 -p -r1.1 pex-win32.c
*** pex-win32.c 24 Jan 2003 20:02:11 -0000 1.1
--- pex-win32.c 2 Jul 2003 21:38:41 -0000
*************** fix_argv (argvec)
*** 57,63 ****
--- 57,69 ----
char **argvec;
{
int i;
+ char * command0 = argvec[0];
+ /* Ensure that the executable pathname uses Win32 backslashes. */
+ for (; *command0 != '\0'; command0++)
+ if (*command0 == '/')
+ *command0 = '\\';
+
for (i = 1; argvec[i] != 0; i++)
{
int len, j;
*************** pexecute (program, argv, this_pname, tem
*** 203,209 ****
if (pid == -1)
{
*errmsg_fmt = install_error_msg;
! *errmsg_arg = program;
return -1;
}
--- 209,215 ----
if (pid == -1)
{
*errmsg_fmt = install_error_msg;
! *errmsg_arg = (char*) program;
return -1;
}
http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.