aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog16
-rw-r--r--gcc/Makefile.in13
-rw-r--r--gcc/collect2.c147
-rwxr-xr-xgcc/configure2
-rw-r--r--gcc/configure.in2
-rw-r--r--gcc/gcc.c18
6 files changed, 53 insertions, 145 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0027278..5054a65 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+Mon Apr 6 21:49:57 1998 Bob Manson <manson@charmed.cygnus.com>
+
+ * gcc.c: Add linker spec.
+ (link_command_spec): Use %(linker) instead of ld.
+ (main): If collect2 is requested as the linker, see if it exists;
+ if not, use ld instead.
+
+ * Makefile.in (USE_COLLECT2): It's named collect2 now, not ld.
+ (ld:) Deleted.
+ (install-collect2): Install as collect2, not ld.
+
+ * configure.in(will_use_collect2): It's named collect2 now.
+
+ * collect2: Remove checks to see if we were invoked recursively.
+ (collect_execute): Use _spawnvp under cygwin32.
+
Mon Apr 6 17:23:41 1998 Jim Wilson <wilson@cygnus.com>
* haifa-sched.c (build_control_flow): Set unreachable for block whose
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 53749d6..66db829 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -334,12 +334,12 @@ EXTRA_GCC_OBJS =@host_extra_gcc_objs@
# Often this is edited directly by `configure'.
EXTRA_HEADERS =@extra_headers_list@
-# Set this to `ld' to enable use of collect2.
+# Set this to `collect2' to enable use of collect2.
USE_COLLECT2 = @will_use_collect2@
MAYBE_USE_COLLECT2 = @maybe_use_collect2@
# It is convenient for configure to add the assignment at the beginning,
# so don't override it here.
-USE_COLLECT2 = ld$(exeext)
+USE_COLLECT2 = collect2$(exeext)
# List of extra C and assembler files to add to libgcc1.a.
# Assembler files should have names ending in `.asm'.
@@ -1254,11 +1254,6 @@ c-pragma.o: c-pragma.c $(CONFIG_H) system.h $(TREE_H) except.h function.h \
c-iterate.o: c-iterate.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) c-tree.h \
flags.h
-# To make a configuration always use collect2, set USE_COLLECT2 to ld.
-ld$(exeext): collect2$(exeext)
- rm -f ld$(exeext)
- $(LN) collect2$(exeext) ld$(exeext)
-
collect2$(exeext): collect2.o tlink.o hash.o cplus-dem.o underscore.o \
version.o choose-temp.o $(LIBDEPS)
# Don't try modifying collect2 (aka ld) in place--it might be linking this.
@@ -2390,9 +2385,9 @@ install-assert-h: assert.h installdirs
chmod a-x $(assertdir)/assert.h; \
fi
-# Use this target to install the program `collect2' under the name `ld'.
+# Use this target to install the program `collect2' under the name `collect2'.
install-collect2: collect2 installdirs
- $(INSTALL_PROGRAM) collect2$(exeext) $(libsubdir)/ld$(exeext)
+ $(INSTALL_PROGRAM) collect2$(exeext) $(libsubdir)/collect2$(exeext)
# Install the driver program as $(libsubdir)/gcc for collect2.
$(INSTALL_PROGRAM) xgcc$(exeext) $(libsubdir)/gcc$(exeext)
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 4e462d9..a1b7ddc 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -35,6 +35,9 @@ Boston, MA 02111-1307, USA. */
#include "demangle.h"
#include "obstack.h"
#include "gansidecl.h"
+#ifdef __CYGWIN32__
+#include <process.h>
+#endif
#ifndef HAVE_STRERROR
extern char *sys_errlist[];
@@ -281,7 +284,6 @@ void collect_execute PROTO((char *, char **, char *));
void dump_file PROTO((char *));
static void handler PROTO((int));
static int is_ctor_dtor PROTO((char *));
-static int is_in_prefix_list PROTO((struct path_prefix *, char *, int));
static char *find_a_file PROTO((struct path_prefix *, char *));
static void add_prefix PROTO((struct path_prefix *, char *));
static void prefix_from_env PROTO((char *, struct path_prefix *));
@@ -733,48 +735,6 @@ static struct path_prefix cpath, path;
static char *target_machine = TARGET_MACHINE;
#endif
-/* Names under which we were executed. Never return one of those files in our
- searches. */
-
-static struct path_prefix our_file_names;
-
-/* Determine if STRING is in PPREFIX.
-
- This utility is currently only used to look up file names. Prefix lists
- record directory names. This matters to us because the latter has a
- trailing slash, so I've added a flag to handle both. */
-
-static int
-is_in_prefix_list (pprefix, string, filep)
- struct path_prefix *pprefix;
- char *string;
- int filep;
-{
- struct prefix_list *pl;
-
- if (filep)
- {
- int len = strlen (string);
-
- for (pl = pprefix->plist; pl; pl = pl->next)
- {
- if (strncmp (pl->prefix, string, len) == 0
- && strcmp (pl->prefix + len, "/") == 0)
- return 1;
- }
- }
- else
- {
- for (pl = pprefix->plist; pl; pl = pl->next)
- {
- if (strcmp (pl->prefix, string) == 0)
- return 1;
- }
- }
-
- return 0;
-}
-
/* Search for NAME using prefix list PPREFIX. We only look for executable
files.
@@ -825,40 +785,18 @@ find_a_file (pprefix, name)
{
strcpy (temp, pl->prefix);
strcat (temp, name);
-
- if (debug)
- fprintf (stderr, " - try: %s\n", temp);
- if (! is_in_prefix_list (&our_file_names, temp, 1)
- /* This is a kludge, but there seems no way around it. */
- && strcmp (temp, "./ld") != 0
- && access (temp, X_OK) == 0)
- {
- if (debug)
- fprintf (stderr, " - found!\n");
-
- return temp;
- }
+ if (access (temp, X_OK) == 0)
+ return temp;
#ifdef EXECUTABLE_SUFFIX
/* Some systems have a suffix for executable files.
So try appending that. */
strcat (temp, EXECUTABLE_SUFFIX);
- if (debug)
- fprintf (stderr, " - try: %s\n", temp);
-
- if (! is_in_prefix_list (&our_file_names, temp, 1)
- && access (temp, X_OK) == 0)
- {
- if (debug)
- fprintf (stderr, " - found! (Uses executable suffix)\n");
-
- return temp;
- }
-#endif
- if (debug && pl->next == NULL)
- fprintf (stderr, " - failed to locate using relative paths\n");
+ if (access (temp, X_OK) == 0)
+ return temp;
+#endif
}
if (debug && pprefix->plist == NULL)
@@ -990,8 +928,6 @@ main (argc, argv)
FILE *importf;
#endif
char *ld_file_name;
- char *collect_name;
- char *collect_names;
char *p;
char **c_argv;
char **c_ptr;
@@ -1029,51 +965,8 @@ main (argc, argv)
obstack_begin (&temporary_obstack, 0);
obstack_begin (&permanent_obstack, 0);
temporary_firstobj = (char *) obstack_alloc (&temporary_obstack, 0);
- current_demangling_style = gnu_demangling;
-
- /* We must check that we do not call ourselves in an infinite
- recursion loop. We append the name used for us to the COLLECT_NAMES
- environment variable.
-
- In practice, collect will rarely invoke itself. This can happen now
- that we are no longer called gld. A perfect example is when running
- gcc in a build directory that has been installed. When looking for
- ld's, we will find our installed version and believe that's the real ld. */
-
- /* We must also append COLLECT_NAME to COLLECT_NAMES to watch for the
- previous version of collect (the one that used COLLECT_NAME and only
- handled two levels of recursion). If we do not we may mutually recurse
- forever. This can happen (I think) when bootstrapping the old version
- and a new one is installed (rare, but we should handle it).
- ??? Hopefully references to COLLECT_NAME can be removed at some point. */
-
- GET_ENVIRONMENT (collect_name, "COLLECT_NAME");
- GET_ENVIRONMENT (collect_names, "COLLECT_NAMES");
-
- p = (char *) xmalloc (strlen ("COLLECT_NAMES=")
- + (collect_name ? strlen (collect_name) + 1 : 0)
- + (collect_names ? strlen (collect_names) + 1 : 0)
- + strlen (argv[0]) + 1);
- strcpy (p, "COLLECT_NAMES=");
- if (collect_name != 0)
- sprintf (p + strlen (p), "%s%c", collect_name, PATH_SEPARATOR);
- if (collect_names != 0)
- sprintf (p + strlen (p), "%s%c", collect_names, PATH_SEPARATOR);
- strcat (p, argv[0]);
- putenv (p);
-
- prefix_from_env ("COLLECT_NAMES", &our_file_names);
-
- /* Set environment variable COLLECT_NAME to our name so the previous version
- of collect will not find us. If it does we will mutually recurse forever.
- This can happen when bootstrapping the new version and an old version is
- installed.
- ??? Hopefully this bit of code can be removed at some point. */
-
- p = xmalloc (strlen ("COLLECT_NAME=") + strlen (argv[0]) + 1);
- sprintf (p, "COLLECT_NAME=%s", argv[0]);
- putenv (p);
+ current_demangling_style = gnu_demangling;
p = getenv ("COLLECT_GCC_OPTIONS");
while (p && *p)
{
@@ -1188,18 +1081,6 @@ main (argc, argv)
if (ld_file_name == 0)
ld_file_name = find_a_file (&path, full_ld_suffix);
- /* If we've invoked ourselves, try again with LD_FILE_NAME. */
-
- if (collect_names != 0)
- {
- if (ld_file_name != 0)
- {
- argv[0] = ld_file_name;
- execvp (argv[0], argv);
- }
- fatal ("cannot find `ld' (%s)", ld_file_name);
- }
-
#ifdef REAL_NM_FILE_NAME
nm_file_name = find_a_file (&path, REAL_NM_FILE_NAME);
if (nm_file_name == 0)
@@ -1518,10 +1399,6 @@ main (argc, argv)
fprintf (stderr, "o_file = %s\n",
(o_file ? o_file : "not found"));
- ptr = getenv ("COLLECT_NAMES");
- if (ptr)
- fprintf (stderr, "COLLECT_NAMES = %s\n", ptr);
-
ptr = getenv ("COLLECT_GCC_OPTIONS");
if (ptr)
fprintf (stderr, "COLLECT_GCC_OPTIONS = %s\n", ptr);
@@ -1773,6 +1650,7 @@ collect_execute (prog, argv, redir)
if (argv[0] == 0)
fatal ("cannot find `%s'", prog);
+#ifndef __CYGWIN32__
pid = vfork ();
if (pid == -1)
{
@@ -1797,6 +1675,11 @@ collect_execute (prog, argv, redir)
execvp (argv[0], argv);
fatal_perror ("executing %s", prog);
}
+#else
+ pid = _spawnvp (_P_NOWAIT, argv[0], argv);
+ if (pid == -1)
+ fatal ("spawnvp failed");
+#endif
}
static void
diff --git a/gcc/configure b/gcc/configure
index 6a26959..cc419d4 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -4792,7 +4792,7 @@ then
will_use_collect2=
maybe_use_collect2=
else
- will_use_collect2="ld"
+ will_use_collect2="collect2"
maybe_use_collect2="-DUSE_COLLECT2"
fi
diff --git a/gcc/configure.in b/gcc/configure.in
index a87ce52..2bb5892 100644
--- a/gcc/configure.in
+++ b/gcc/configure.in
@@ -3109,7 +3109,7 @@ then
will_use_collect2=
maybe_use_collect2=
else
- will_use_collect2="ld"
+ will_use_collect2="collect2"
maybe_use_collect2="-DUSE_COLLECT2"
fi
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 37d5ebc..ff4cf95 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -477,6 +477,10 @@ proper position among the other output files. */
#endif
#endif
+#ifndef LINKER_NAME
+#define LINKER_NAME "collect2"
+#endif
+
static char *cpp_spec = CPP_SPEC;
static char *cpp_predefines = CPP_PREDEFINES;
static char *cc1_spec = CC1_SPEC;
@@ -490,6 +494,7 @@ static char *libgcc_spec = LIBGCC_SPEC;
static char *endfile_spec = ENDFILE_SPEC;
static char *startfile_spec = STARTFILE_SPEC;
static char *switches_need_spaces = SWITCHES_NEED_SPACES;
+static char *linker_name_spec = LINKER_NAME;
/* Some compilers have limits on line lengths, and the multilib_select
and/or multilib_matches strings can be very long, so we build them at
@@ -708,7 +713,7 @@ static int n_default_compilers
/* Don't generate -L options. */
static char *link_command_spec = "\
%{!fsyntax-only: \
- %{!c:%{!M:%{!MM:%{!E:%{!S:ld %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
+ %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
%{r} %{s} %{t} %{u*} %{x} %{z} %{Z}\
%{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
%{static:} %{L*} %o\
@@ -720,7 +725,7 @@ static char *link_command_spec = "\
/* Use -L. */
static char *link_command_spec = "\
%{!fsyntax-only: \
- %{!c:%{!M:%{!MM:%{!E:%{!S:ld %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
+ %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
%{r} %{s} %{t} %{u*} %{x} %{z} %{Z}\
%{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
%{static:} %{L*} %D %o\
@@ -1093,6 +1098,7 @@ static struct spec_list static_specs[] = {
INIT_STATIC_SPEC ("multilib_defaults", &multilib_defaults),
INIT_STATIC_SPEC ("multilib_extra", &multilib_extra),
INIT_STATIC_SPEC ("multilib_matches", &multilib_matches),
+ INIT_STATIC_SPEC ("linker", &linker_name_spec),
};
#ifdef EXTRA_SPECS /* additional specs needed */
@@ -2130,6 +2136,7 @@ execute ()
commands[0].prog = argbuf[0]; /* first command. */
commands[0].argv = &argbuf[0];
string = find_a_file (&exec_prefixes, commands[0].prog, X_OK);
+
if (string)
commands[0].argv[0] = string;
@@ -4797,6 +4804,13 @@ main (argc, argv)
{
int tmp = execution_count;
+ /* We'll use ld if we can't find collect2. */
+ if (! strcmp (linker_name_spec, "collect2"))
+ {
+ char *s = find_a_file (&exec_prefixes, "collect2", X_OK);
+ if (s == NULL)
+ linker_name_spec = "ld";
+ }
/* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables
for collect. */
putenv_from_prefixes (&exec_prefixes, "COMPILER_PATH=");