This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Fix process id handling in collect2.c
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: zack at codesourcery dot com (Zack Weinberg)
- Cc: gcc-patches at gcc dot gnu dot org, dj at redhat dot com
- Date: Sun, 26 Jan 2003 14:57:15 -0500 (EST)
- Subject: [PATCH]: Fix process id handling in collect2.c
> "John David Anglin" <dave@hiauly1.hia.nrc.ca> writes:
>
> > This patch causes a bootstrap failure on hppa2.0w-hp-hpux11.11. When
> > linking libgcc_s.1, the following error occurs:
> >
> > collect2: /opt/gnu/hppa2.0w-hp-hpux11.11/bin/nm returned 28 exit status
> >
> > I verified manually that the actual exit status for nm is 0. I changed
> > pex-unix.c to use wait and things work again.
>
> That smells like a bug in collect2. Can you instrument pex-unix.c and
> find out whether collect2 is calling pwait with the right process ID?
Right, it wasn't using the correct process ID for waits on forked processes.
Ok? Tested on hppa2.0w-hp-hpux11.11.
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
2003-01-26 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* collect2.c (pexecute_pid): Rename to pid.
(collect_wait, collect_execute, scan_prog_file, scan_libraries): Use
pid.
Index: collect2.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/collect2.c,v
retrieving revision 1.145
diff -u -3 -p -r1.145 collect2.c
--- collect2.c 20 Jan 2003 20:41:55 -0000 1.145
+++ collect2.c 26 Jan 2003 19:39:35 -0000
@@ -235,8 +235,8 @@ static struct head frame_tables; /* list
struct obstack temporary_obstack;
char * temporary_firstobj;
-/* Holds the return value of pexecute. */
-int pexecute_pid;
+/* Holds the return value of pexecute and fork. */
+int pid;
/* Structure to hold all the directories in which to search for files to
execute. */
@@ -1500,7 +1500,7 @@ collect_wait (prog)
{
int status;
- pwait (pexecute_pid, &status, 0);
+ pwait (pid, &status, 0);
if (status)
{
if (WIFSIGNALED (status))
@@ -1589,9 +1589,8 @@ collect_execute (prog, argv, redir)
dup2 (redir_handle, STDERR_FILENO);
}
- pexecute_pid = pexecute (argv[0], argv, argv[0], NULL,
- &errmsg_fmt, &errmsg_arg,
- (PEXECUTE_FIRST | PEXECUTE_LAST | PEXECUTE_SEARCH));
+ pid = pexecute (argv[0], argv, argv[0], NULL, &errmsg_fmt, &errmsg_arg,
+ (PEXECUTE_FIRST | PEXECUTE_LAST | PEXECUTE_SEARCH));
if (redir)
{
@@ -1603,7 +1602,7 @@ collect_execute (prog, argv, redir)
close (redir_handle);
}
- if (pexecute_pid == -1)
+ if (pid == -1)
fatal_perror (errmsg_fmt, errmsg_arg);
}
@@ -2070,7 +2069,6 @@ scan_prog_file (prog_name, which_pass)
void (*quit_handler) PARAMS ((int));
char *real_nm_argv[4];
const char **nm_argv = (const char **) real_nm_argv;
- int pid;
int argc = 0;
int pipe_fd[2];
char *p, buf[1024];
@@ -2515,7 +2513,6 @@ scan_libraries (prog_name)
void (*quit_handler) PARAMS ((int));
char *real_ldd_argv[4];
const char **ldd_argv = (const char **) real_ldd_argv;
- int pid;
int argc = 0;
int pipe_fd[2];
char buf[1024];