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]

PATCH: Handle the shared libgcc is a system library


This patch detects if there is a system shared libgcc in /lib or
/usr/lib. If it detects one, the shared libgcc will be installed
$(libsubdir) so that it won't override the system one by accident.

I also added --release/-dumprelease since I found --version couldn't
tell the different releases of the same version. It can be used to
install libgcc_s.so into /lib

# cp `gcc --print-file-name=libgcc_s.so.1` /lib/libgcc_s-`gcc --release`.so
# ln -sf libgcc_s-`gcc --release`.so /lib/libgcc_s.so.1

so that there is always a libgcc_s.so.1 available at any time.


H.J.
---
2001-07-01  H.J. Lu  (hjl@gnu.org)

	* configure.in (slibdir): Set according to if the shared libgcc
	library is a system shared library.
	* configure: Rebuild.

	* gcc.c (compiler_release): New string for the compiler
	release.
	(option_map): Add --release/-dumprelease.
	(display_help): Add -dumprelease.
	(process_command): Initialize compiler_release and handle
	-dumprelease.

--- gcc/configure.in.glibc	Wed Jun 13 13:36:24 2001
+++ gcc/configure.in	Sun Jul  1 10:01:13 2001
@@ -1945,14 +1945,33 @@ AC_ARG_ENABLE(version-specific-runtime-l
 
 AC_ARG_WITH(slibdir,
 [  --with-slibdir=DIR      shared libraries in DIR [LIBDIR]],
-slibdir="$with_slibdir",
+slibdir="$with_slibdir",[
 if test "${enable_version_specific_runtime_libs+set}" = set; then
   slibdir='$(libsubdir)'
 elif test "$host" != "$target"; then
   slibdir='$(build_tooldir)/lib'
 else
   slibdir='$(libdir)'
-fi)
+  if test "$build" = "$target"; then
+    # For systems where there is the shared libgcc in /lib or /usr/lib,
+    # we assume it is a system library come from the system vendor, we
+    # install our shared libgcc into $(libsubdir). We only check the
+    # system shared libgcc for the native build.
+    # FIXME: Need to check if the system shared libgcc library is
+    #	     really ok.
+    if test -e /lib/libgcc_s.so || test -e /usr/lib/libgcc_s.so; then
+      slibdir='$(libsubdir)'
+    fi
+  else
+    # For the native compiler built by canadian cross build, we install
+    # our shared libgcc into /lib if it is used as the system compiler.
+    case $target in
+    *-linux*)
+      slibdir="/lib"
+    ;;
+    esac
+  fi
+fi])
 AC_SUBST(slibdir)
 
 # Nothing to do for FLOAT_H, float_format already handled.
--- gcc/gcc.c.glibc	Tue Jun 12 14:38:51 2001
+++ gcc/gcc.c	Sun Jul  1 09:34:02 2001
@@ -157,6 +157,10 @@ static int save_temps_flag;
 
 static const char *compiler_version;
 
+/* The compiler release. */
+
+static const char *compiler_release;
+
 /* The target version specified with -V */
 
 static const char *spec_version = DEFAULT_TARGET_VERSION;
@@ -898,6 +902,7 @@ struct option_map option_map[] =
    {"--user-dependencies", "-MM", 0},
    {"--verbose", "-v", 0},
    {"--version", "-dumpversion", 0},
+   {"--release", "-dumprelease", 0},
    {"--warn-", "-W", "*j"},
    {"--write-dependencies", "-MD", 0},
    {"--write-user-dependencies", "-MMD", 0},
@@ -2897,6 +2902,7 @@ display_help ()
     fputs (_("  (Use '-v --help' to display command line options of sub-processes)\n"), stdout);
   fputs (_("  -dumpspecs               Display all of the built in spec strings\n"), stdout);
   fputs (_("  -dumpversion             Display the version of the compiler\n"), stdout);
+  fputs (_("  -dumprelease             Display the release of the compiler\n"), stdout);
   fputs (_("  -dumpmachine             Display the compiler's target processor\n"), stdout);
   fputs (_("  -print-search-dirs       Display the directories in the compiler's search path\n"), stdout);
   fputs (_("  -print-libgcc-file-name  Display the name of the compiler's companion library\n"), stdout);
@@ -3022,7 +3028,7 @@ process_command (argc, argv)
   n_infiles = 0;
   added_libraries = 0;
 
-  /* Figure compiler version from version string.  */
+  /* Figure out compiler version from version string.  */
 
   compiler_version = temp1 = xstrdup (version_string);
 
@@ -3035,6 +3041,27 @@ process_command (argc, argv)
 	}
     }
 
+  /* Figure compiler release from version string.  */
+  compiler_release = temp1 = xstrdup (version_string);
+
+  for (; *temp1; ++temp1)
+    {
+      if (ISSPACE ((unsigned char) *temp1))
+	*temp1 = '-';
+      else if (*temp1 == '(')
+	{
+	  *temp1 = '\0';
+	  break;
+	}
+    }
+  for (--temp1; *temp1; --temp1)
+    {
+      if (*temp1 == '-')
+	*temp1 = '\0';
+      else
+	break;
+    }
+
   /* Set up the default search paths.  If there is no GCC_EXEC_PREFIX,
      see if we can create it from the pathname specified in argv[0].  */
 
@@ -3200,6 +3227,11 @@ process_command (argc, argv)
       else if (! strcmp (argv[i], "-dumpversion"))
 	{
 	  printf ("%s\n", spec_version);
+	  exit (0);
+	}
+      else if (! strcmp (argv[i], "-dumprelease"))
+	{
+	  printf ("%s\n", compiler_release);
 	  exit (0);
 	}
       else if (! strcmp (argv[i], "-dumpmachine"))


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