summaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-02 17:42:00 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-02 17:42:00 +0000
commit5cb4c868e7e51a83bf56a592ddc866f427b7c993 (patch)
tree3e8cc7d5d1480250560533db491107be11d42779 /gcc/gcc.c
parentec7a9913eda0c8a6a7c4abf7e9c2a7d58c6d6616 (diff)
downloadgcc-5cb4c868e7e51a83bf56a592ddc866f427b7c993.tar.gz
* gcc.c (init_gcc_specs): New function. Make -shared-libgcc
the default when building a shared object. (init_spec): Use it. * testsuite/lib/g++.exp: Include the directory where libgcc is located to the LD_LIBRARY_PATH list. * inovke.texi (-shared-libgcc): Document the cases in which * Make-lang.in (g++spec.o): Add DRIVER_DEFINES to the list of macros used when compiling g++spec.c. * g++spec.c (lang_specific_driver): Link with the shared libgcc by default. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39408 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c49
1 files changed, 42 insertions, 7 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index f66fc828475..9a7a9419d69 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -268,6 +268,9 @@ static int execute PARAMS ((void));
static void clear_args PARAMS ((void));
static void fatal_error PARAMS ((int));
static void set_input PARAMS ((const char *));
+static void init_gcc_specs PARAMS ((struct obstack *,
+ const char *,
+ const char *));
/* Specs are strings containing lines, each of which (if not blank)
is made up of a program name, and arguments separated by spaces.
@@ -1252,6 +1255,35 @@ static struct spec_list *extra_specs = (struct spec_list *) 0;
static struct spec_list *specs = (struct spec_list *) 0;
+/* Add appropriate libgcc specs to OBSTACK, taking into account
+ various permutations of -shared-libgcc, -shared, and such. */
+
+static void
+init_gcc_specs (obstack, shared_name, static_name)
+ struct obstack *obstack;
+ const char *shared_name;
+ const char *static_name;
+{
+ char buffer[128];
+
+ /* If we see -shared-libgcc, then use the shared version. */
+ sprintf (buffer, "%%{shared-libgcc:%s}", shared_name);
+ obstack_grow (obstack, buffer, strlen (buffer));
+ /* If we see -static-libgcc, then use the shared version. */
+ sprintf (buffer, "%%{static-libgcc:%s}", static_name);
+ obstack_grow (obstack, buffer, strlen (buffer));
+ /* Otherwise, if we see -shared, then use the shared version. */
+ sprintf (buffer,
+ "%%{!shared-libgcc:%%{!static-libgcc:%%{shared:%s}}}",
+ shared_name);
+ obstack_grow (obstack, buffer, strlen (buffer));
+ /* Otherwise, use the static version. */
+ sprintf (buffer,
+ "%%{!shared-libgcc:%%{!static-libgcc:%%{!shared:%s}}}",
+ static_name);
+ obstack_grow (obstack, buffer, strlen (buffer));
+}
+
/* Initialize the specs lookup routines. */
static void
@@ -1326,15 +1358,16 @@ init_spec ()
when given the proper command line arguments. */
while (*p)
{
- const char *r;
if (in_sep && *p == '-' && strncmp (p, "-lgcc", 5) == 0)
{
+ init_gcc_specs (&obstack,
#ifdef NO_SHARED_LIBGCC_MULTILIB
- r = "%{shared-libgcc:-lgcc_s}%{!shared-libgcc:-lgcc}";
+ "-lgcc_s"
#else
- r = "%{shared-libgcc:-lgcc_s%M}%{!shared-libgcc:-lgcc}";
+ "-lgcc_s%M"
#endif
- obstack_grow (&obstack, r, strlen(r));
+ ,
+ "-lgcc");
p += 5;
in_sep = 0;
}
@@ -1342,12 +1375,14 @@ init_spec ()
{
/* Ug. We don't know shared library extensions. Hope that
systems that use this form don't do shared libraries. */
+ init_gcc_specs (&obstack,
#ifdef NO_SHARED_LIBGCC_MULTILIB
- r = "%{shared-libgcc:-lgcc_s}%{!shared-libgcc:libgcc.a%s}";
+ "-lgcc_s"
#else
- r = "%{shared-libgcc:-lgcc_s%M}%{!shared-libgcc:libgcc.a%s}";
+ "-lgcc_s%M"
#endif
- obstack_grow (&obstack, r, strlen(r));
+ ,
+ "libgcc.a%s");
p += 10;
in_sep = 0;
}