This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Ignore --disable-static in libiberty
- From: "H. J. Lu" <hjl at lucon dot org>
- To: DJ Delorie <dj at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, binutils at sources dot redhat dot com
- Date: Sun, 19 Dec 2004 10:05:41 -0800
- Subject: Re: PATCH: Ignore --disable-static in libiberty
- References: <20041219034227.GA5169@lucon.org> <200412191727.iBJHRIsb019349@greed.delorie.com>
On Sun, Dec 19, 2004 at 12:27:18PM -0500, DJ Delorie wrote:
>
> Could you please revert your original patch for now? I still like the
> idea, it just needs more testing (sigh).
I have no problem with that. But either this patch
http://gcc.gnu.org/ml/gcc-patches/2004-12/msg01248.html
should be applied or this patch
http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00623.html
should be reverted. Otherwise, --enable-shared will fail in binutils.
>
> Also, I found this:
>
> LIBOBJS = asprintf$U.o
>
> It needs to be ./asprintf.o to avoid the VPATH problem. What's the $U
It should be fixed by the updated patch here.
> for anyway?
I have no idea. It has been there for a long time.
>
> Linux native with --enable-shared puts some but not all objs in .libs,
> which also causes problems. They just don't stop the build.
I didn't see it with this patch.
>
> So, we need to test default, --enable-shared, and --disable-static on
> linux and AIX.
I think this patch should address all problems on Linux and it should
work on AIX.
H.J.
-----
2004-12-19 H.J. Lu <hongjiu.lu@intel.com>
PR bootstrap/19072
* Makefile.in (enable_shared): New substitute.
(LTTARGETLIB): New.
(PREFIXTARGETLIB): New.
(LTTESTLIB): New.
(PREFIXTESTLIB): New.
(CCLD): New.
(LINK): New.
($(TARGETLIB)): Use $(LINK) to create libraries and create
targets by hand.
($(TESTLIB)): Likewise.
(mostlyclean): Don't remove .libs. Remove the libtool object
directory.
* config.table (enable_shared): Removed.
* configure.ac (enable_static): Set to yes.
(AC_PROG_LIBTOOL): Removed.
(AM_DISABLE_SHARED): Uncommented.
(AM_PROG_LIBTOOL): Likewise.
(LIBOBJS): Add `./' to avoid VPATH.
(LTLIBOBJS): Likewise.
(enable_shared): Substitute.
* configure: Regenerated.
--- libiberty/Makefile.in.static 2004-12-19 08:41:55.903353456 -0800
+++ libiberty/Makefile.in 2004-12-19 09:33:29.343810829 -0800
@@ -31,6 +31,8 @@ srcdir = @srcdir@
top_builddir = .
+enable_shared = @enable_shared@
+
prefix = @prefix@
exec_prefix = @exec_prefix@
@@ -71,7 +73,11 @@ PICFLAG =
MAKEOVERRIDES =
TARGETLIB = ./libiberty.a
+LTTARGETLIB = ./libiberty.la
+PREFIXTARGETLIB= ./libiberty
TESTLIB = ./testlib.a
+LTTESTLIB = ./testlib.la
+PREFIXTESTLIB = ./testlib
LIBOBJS = @LIBOBJS@
LTLIBOBJS = @LTLIBOBJS@
@@ -122,6 +128,8 @@ INCDIR=$(srcdir)/$(MULTISRCTOP)../includ
COMPILE.c = $(CC) -c @DEFS@ $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES) @ac_libiberty_warn_cflags@
LTCOMPILE = $(LIBTOOL) --mode=compile $(COMPILE.c)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(CFLAGS)
# Just to make sure we don't use a built-in rule with VPATH
.c.o:
@@ -260,13 +268,25 @@ INSTALLED_HEADERS =
$(INCDIR)/splay-tree.h \
$(INCDIR)/ternary.h
+# FIXME: Libtool has to be used to create static and shared libraries
+# if it is used to compile object files. Since libiberty doesn't really
+# build shared library, we have to create the libraries we need by hand
+# and remove those created by libtool.
$(TARGETLIB): $(REQUIRED_LTOFILES) $(EXTRA_LTOFILES) $(LTLIBOBJS)
- -rm -f $(TARGETLIB) .libs/$(TARGETLIB)
- $(AR) $(AR_FLAGS) $(TARGETLIB) \
- $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
- $(RANLIB) $(TARGETLIB)
- if [ -d .libs ]; then \
- cd .libs; \
+ libtooldir=`$(LIBTOOL) --config | sed -n -e 's/^objdir=//p'`; \
+ rm -f $(TARGETLIB) $$libtooldir/$(TARGETLIB) pic/$(TARGETLIB) \
+ || true; \
+ $(LINK) -o $(LTTARGETLIB) -rpath $(libdir) \
+ $(REQUIRED_LTOFILES) $(EXTRA_LTOFILES) $(LTLIBOBJS); \
+ if [ -f $$libtooldir/$(TARGETLIB) ]; then \
+ cp $$libtooldir/$(TARGETLIB) $(TARGETLIB).tmp; \
+ $(RANLIB) $(TARGETLIB).tmp; \
+ $(SHELL) $(srcdir)/../move-if-change \
+ $(TARGETLIB).tmp $(TARGETLIB); \
+ else true; fi; \
+ rm -f $(LTTARGETLIB) $$libtooldir/$(PREFIXTARGETLIB)*; \
+ if [ x$(enable_shared) = xyes ]; then \
+ cd $$libtooldir; \
$(AR) $(AR_FLAGS) $(TARGETLIB) \
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
$(RANLIB) $(TARGETLIB); \
@@ -277,10 +297,17 @@ $(TARGETLIB): $(REQUIRED_LTOFILES) $(EXT
else true; fi
$(TESTLIB): $(REQUIRED_LTOFILES) $(CONFIGURED_LTOFILES)
- -rm -f $(TESTLIB)
- $(AR) $(AR_FLAGS) $(TESTLIB) \
- $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
- $(RANLIB) $(TESTLIB)
+ libtooldir=`$(LIBTOOL) --config | sed -n -e 's/^objdir=//p'`; \
+ rm -f $(TESTLIB) $$libtooldir/$(TESTLIB) || true; \
+ $(LINK) -o $(LTTESTLIB) -rpath $(libdir) \
+ $(REQUIRED_LTOFILES) $(CONFIGURED_LTOFILES); \
+ if [ -f $$libtooldir/$(TESTLIB) ]; then \
+ cp $$libtooldir/$(TESTLIB) $(TESTLIB).tmp; \
+ $(RANLIB) $(TESTLIB).tmp; \
+ $(SHELL) $(srcdir)/../move-if-change \
+ $(TESTLIB).tmp $(TESTLIB); \
+ else true; fi; \
+ rm -f $(LTTESTLIB) $$libtooldir/$(PREFIXTESTLIB)*
info: libiberty.info info-subdir
install-info: install-info-subdir
@@ -403,7 +430,9 @@ maint-deps :
# Cleaning has to be done carefully to ensure that we don't clean our SUBDIRS
# multiple times, hence our explicit recursion with an empty SUBDIRS.
mostlyclean: mostlyclean-subdir
- -rm -rf *.o *.lo pic .libs core errs \#* *.E a.out
+ -libtooldir=`$(LIBTOOL) --config | sed -n -e 's/^objdir=//p'`; \
+ rm -f $$libtooldir
+ -rm -rf *.o *.lo pic core errs \#* *.E a.out
-rm -f needed.awk needed2.awk errors dummy needed-list config.h stamp-*
-rm -f $(CONFIG_H) $(NEEDED_LIST)
-rm -f libiberty.aux libiberty.cp libiberty.cps libiberty.fn libiberty.ky
--- libiberty/config.table.static 2004-12-18 08:58:09.000000000 -0800
+++ libiberty/config.table 2004-12-19 09:11:28.331927693 -0800
@@ -30,12 +30,5 @@ for frag in ${frags}; do
fi
done
-# record if we want to build shared libs.
-if [ "${shared}" = "yes" ]; then
- echo enable_shared = yes >> temp-frag
-else
- echo enable_shared = no >> temp-frag
-fi
-
frag=xhost-mkfrag
${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
--- libiberty/configure.ac.static 2004-12-18 08:58:19.000000000 -0800
+++ libiberty/configure.ac 2004-12-19 09:55:20.515472753 -0800
@@ -4,6 +4,9 @@ AC_PREREQ(2.59)
AC_INIT
AC_CONFIG_SRCDIR([xmalloc.c])
+# FIXME: libiberty doesn't support --disable-static
+enable_static=yes
+
# This works around the fact that libtool configuration may change LD
# for this particular configuration, but some shells, instead of
# keeping the changes in LD private, export them just because LD is
@@ -113,8 +116,6 @@ GCC_NO_EXECUTABLES
AC_PROG_CC
AC_PROG_CPP_WERROR
-AC_PROG_LIBTOOL
-
if test x$GCC = xyes; then
ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
fi
@@ -124,13 +125,11 @@ AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN_CROSS
-dnl When we start using libtool:
dnl Default to a non shared library. This may be overridden by the
dnl configure option --enable-shared.
-dnl AM_DISABLE_SHARED
+AM_DISABLE_SHARED
-dnl When we start using libtool:
-dnl AM_PROG_LIBTOOL
+AM_PROG_LIBTOOL
dnl When we start using automake:
dnl AM_CONFIG_HEADER(config.h:config.in)
@@ -540,6 +539,30 @@ else
fi
AC_SUBST(INSTALL_DEST)
+# Add `./' to avoid VPATH.
+m4_pattern_allow(LIBOBJS)
+L=""
+for l in x $LIBOBJS; do
+ case $l in
+ x) ;;
+ *) L="$L ./$l" ;;
+ esac
+done
+LIBOBJS="$L"
+
+m4_pattern_allow(LTLIBOBJS)
+L=""
+for l in x $LTLIBOBJS; do
+ case $l in
+ x) ;;
+ *) L="$L ./$l" ;;
+ esac
+done
+LTLIBOBJS="$L"
+
+dnl Delete it when we start creating shared library with libtool.
+AC_SUBST(enable_shared)
+
# We need multilib support, but only if configuring for the target.
AC_CONFIG_FILES([Makefile testsuite/Makefile])
AC_CONFIG_COMMANDS([default],