This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] [Bug bootstrap/38580] [4.4 Regression] Bootstrap broken on mingw32


The following fixes PR 38580 by replacing the call to execvp with calls
to pex_one (from libiberty)  and exit.

On x86_64-linux host, this patch changes error return for an invalid -b option

to:
./xgcc -b nonexistent
./xgcc: error trying to exec './nonexistent-gcc-4.4.0': execvp: No such
file or directory

from:
./xgcc -b nonexistent-target -B ./ -v
xgcc: couldn't run './nonexistent-gcc-4.4.0': No such file or directory

Note that on linux hosts, the error message is now emitted by
libiberty pex-unix code, rather than by proces_command.

On mingw32 host, the patch changes error return for an invalid -b option
to:
xgcc -b nonexistent
xgcc: couldn't run 'nonexistent-gcc-4.4.0': CreateProcess: No such
file or directory

from:
xgcc: unrecognized option '-b'
xgcc: no input files



On both hosts it does the right thing if the target exists.


Tested by building on x86_64-linux and mingw32 hosts, and running
testsuite for mingw32 bootstrap


2009-01-11  Danny Smith  <dannysmith@users.sourceforge.net>

	PR bootstrap/38580
	* gcc.c (process_command): Replace call to execvp
	with calls to pex_one and exit.


Index: gcc.c
===================================================================
--- gcc.c	(revision 142958)
+++ gcc.c	(working copy)
@@ -3382,6 +3382,9 @@
       char **new_argv;
       char *new_argv0;
       int baselen;
+      int status;
+      int err;
+      const char *errmsg;

       while (argc > 1 && argv[1][0] == '-'
 	     && (argv[1][1] == 'V'
@@ -3424,8 +3427,18 @@
       new_argv = XDUPVEC (char *, argv, argc + 1);
       new_argv[0] = new_argv0;

-      execvp (new_argv0, new_argv);
-      fatal ("couldn't run '%s': %s", new_argv0, xstrerror (errno));
+      errmsg = pex_one (PEX_SEARCH, new_argv0, new_argv, progname, NULL,
+			NULL, &status, &err);
+
+      if (errmsg)
+	{
+	  if (err == 0)
+	    fatal ("couldn't run '%s': %s", new_argv0, errmsg);
+	  else
+	    fatal ("couldn't run '%s': %s: %s", new_argv0, errmsg,
+		    xstrerror (err));
+        }
+      exit (status);
     }

   /* Set up the default search paths.  If there is no GCC_EXEC_PREFIX,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]