This is the mail archive of the gcc@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]

Re: compiling a shared-library not linked against libgcc_s.so


On Sun, Oct 21, 2001 at 07:42:14PM +0200, Rene Rebe wrote:
> Hi.
> 
> I'm try to get a shared library, which collects the files during the build
> process of our distribution (www.rocklinux.org), to work with the gcc-3.0.x.
> 
> The library wraps the open, read, write, close, ... calls to log the
> activities.
> 
> It get's compiled with:
> 
> gcc -Wall -O2 -ldl --shared -o fl_wrapper.so fl_wrapper.c
> 
> And is linked against:
> 
> jackson:~ # ldd fl_wrapper.so 
> 	libdl.so.2 => /lib/libdl.so.2 (0x4000d000)
> 	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x40011000)
> 	libc.so.6 => /lib/libc.so.6 (0x40019000)
> 	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
> 
> The library works fine until the gcc-3 removes the /usr/lib/libgcc_s.so during
> it's make install - and so the next command fails because the libgcc_s for the
> preloaded lib is gone.
> 

If you ask me, I consider it a gcc bug. Try this patch.


H.J.
2001-07-02  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.libgcc	Wed Jun 13 13:36:24 2001
+++ gcc/configure.in	Mon Jul  2 08:25:31 2001
@@ -1945,14 +1945,26 @@ 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
+  # We are building a nativa compiler here since "$host" = "$target".
   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 -f /lib/libgcc_s.so.1 || test -f /usr/lib/libgcc_s.so.1; then
+      slibdir='$(libsubdir)'
+    fi
+  fi
+fi])
 AC_SUBST(slibdir)
 
 # Nothing to do for FLOAT_H, float_format already handled.
--- gcc/gcc.c.libgcc	Tue Jun 12 14:38:51 2001
+++ gcc/gcc.c	Mon Jul  2 08:18:19 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);
@@ -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]