Patch: Check if -lc is needed.

H . J . Lu hjl@valinux.com
Tue Jul 18 14:54:00 GMT 2000


On Tue, Jul 18, 2000 at 04:24:14PM -0300, Alexandre Oliva wrote:
> On Jul 18, 2000, "H . J . Lu" <hjl@valinux.com> wrote:
> 
> >> I'm not sure this wouldn't be rejected by some tool-chain.  I'd rather
> >> go with regular shared library names.
> 
> > We can use libconftest.so for both. But
> 
> Nope, libconftest.so is not a regular shared library names on all
> platforms supported by libtool.  And then, there are platforms that
> don't support shared libraries at all.

Any suggestions? Again, if it failes, it doesn't hurt.

> 
> > I just want to set something to archive_cmds so that it will run.
> 
> But you want verbose output, so `-v' must make it to the compiler
> invocation.
> 
> > I don't know enough about it. If it fails, it won't hurt. The worest
> > can happen is -lc is added even if it is not needed.
> 
> Indeed.  But are you volunteering to answer the questions about the
> weird errors that will show up in config.log? :-)

I can send it to /dev/null if I have to.

> 
> >> But you had mentioned that `-lc' was needed for older versions of GCC.
> >> Are you sure about that?
> 
> > Yes, I created those old versions gcc for Linux :-)
> 
> :-)
> 
> Ok, back to plan A.  How about only running this test when (i) the
> compiler in use is GCC; (ii) archive_cmds starts with `$CC ' and (iii)
> archive_cmds does not contain any `~'?  This would probably solve 90%
> of the problems.

Here is a new patch.

> 
> 
> You may also have to set variables that are referenced in archive_cmds
> of other systems to avoid having them prevent the success of the test.
> For example, $verstring and $output_objdir are referenced in irix' and
> osf's archive_cmds, $allow_undefined_flag is referenced on a couple of
> systems.
> 

Ok. But I don't know what values I should set them to. I just left
them blank.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
--
--- ../../import/libtool/ltconfig.in	Sun Feb 27 08:18:13 2000
+++ ./ltconfig.in	Tue Jul 18 14:51:58 2000
@@ -2175,6 +2175,37 @@ esac
 
 echo "$ac_t$enable_shared" 1>&6
 
+need_lc=yes
+if test "$enable_shared" = yes && test "$with_gcc" = yes; then
+  start_gcc=no
+  echo $archive_cmds | grep "^$CC" > /dev/null 2>&1 && start_gcc=yes
+  has_tilde=no
+  echo $archive_cmds | grep "~" > /dev/null 2>&1 && has_tilde=yes
+  if test $start_gcc = yes && test $has_tilde = no; then
+    echo "checking if we need -lc for building shared libraries..." 1>&6
+    $rm conftest*
+    echo "static int dummy;" > conftest.c
+    if { (eval echo $progname:@LINENO@: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then
+      # Append any warnings to the config.log.
+      cat conftest.err 1>&5
+
+      soname=conftest
+      lib=conftest
+      libobjs=conftest.o
+      deplibs=
+      linkopts=-v
+      verstring=
+      output_objdir=
+      allow_undefined_flag=
+      if { (eval echo $progname:@LINENO@: \"$archive_cmds\") 1>&5; (eval $archive_cmds) 2>&1 | grep " -lc " 1>&5 ; }; then
+        need_lc=no
+      fi
+    else
+      cat conftest.err 1>&5
+    fi
+  fi
+fi
+
 # Make sure either enable_shared or enable_static is yes.
 test "$enable_shared" = yes || enable_static=yes
 
@@ -2779,6 +2810,9 @@ SHELL=$LTSHELL
 
 # Whether or not to build shared libraries.
 build_libtool_libs=$enable_shared
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$need_lc
 
 # Whether or not to build static libraries.
 build_old_libs=$enable_static


More information about the Gcc-patches mailing list