INN commit: trunk (7 files)

INN Commit rra at isc.org
Sat Nov 21 08:47:29 UTC 2020


    Date: Saturday, November 21, 2020 @ 00:47:28
  Author: iulius
Revision: 10406

Fix build with static libraries

Circular dependencies were not correctly resolved by the linker.
Seems to be a bug in the --preserve-dup-deps Libtool flag, that
does not do what it is supposed to do.  Fixed in a local modification
in ltmain.sh, reported to upstream.

Modified:
  trunk/Makefile.global.in
  trunk/backends/Makefile
  trunk/configure.ac
  trunk/frontends/Makefile
  trunk/storage/buffindexed/ovmethod.mk
  trunk/support/ltmain.sh
  trunk/tests/Makefile

---------------------------------+
 Makefile.global.in              |    2 
 backends/Makefile               |    9 ++--
 configure.ac                    |    2 
 frontends/Makefile              |   17 +++++---
 storage/buffindexed/ovmethod.mk |    2 
 support/ltmain.sh               |   79 ++++++++++++++++++++------------------
 tests/Makefile                  |    9 ++--
 7 files changed, 70 insertions(+), 50 deletions(-)

Modified: Makefile.global.in
===================================================================
--- Makefile.global.in	2020-11-21 07:02:43 UTC (rev 10405)
+++ Makefile.global.in	2020-11-21 08:47:28 UTC (rev 10406)
@@ -69,11 +69,13 @@
 LIBTOOLCC	= @LIBTOOLCC@
 LIBTOOLINST	= @LIBTOOLINST@
 LIBTOOLLD	= @LIBTOOLLD@
+LIBTOOLLDDEPS	= @LIBTOOLLDDEPS@
 EXTOBJ		= @EXTOBJ@
 EXTLIB		= @EXTLIB@
 
 LIBCC		= $(LIBTOOLCC) $(CC)
 LIBLD		= $(LIBTOOLLD) $(CC)
+LIBLDDEPS	= $(LIBTOOLLDDEPS) $(CC)
 
 ##  zlib support.  Additional flags and libraries used when compiling or
 ##  linking code that contains compression support.

Modified: backends/Makefile
===================================================================
--- backends/Makefile	2020-11-21 07:02:43 UTC (rev 10405)
+++ backends/Makefile	2020-11-21 08:47:28 UTC (rev 10406)
@@ -65,9 +65,12 @@
 
 ##  Compilation rules.
 
-BOTH		= $(LIBSTORAGE) $(LIBHIST) $(LIBINN)
+# $(LIBSTORAGE) must be listed twice to resolve circular dependencies
+# when doing static linking.
+BOTH		= $(LIBSTORAGE) $(LIBHIST) $(LIBSTORAGE) $(LIBINN)
 
 LINK 		= $(LIBLD) $(LDFLAGS) -o $@
+LINKDEPS	= $(LIBLDDEPS) $(LDFLAGS) -o $@
 INNLIBS		= $(LIBINN) $(LIBS)
 STORELIBS	= $(BOTH) $(STORAGE_LIBS) $(LIBS)
 
@@ -82,12 +85,12 @@
 batcher:	batcher.o    $(BOTH)	; $(LINK) batcher.o    $(STORELIBS)
 cvtbatch:	cvtbatch.o   $(BOTH)	; $(LINK) cvtbatch.o   $(STORELIBS)
 innbind:	innbind.o    $(LIBINN)	; $(LINK) innbind.o    $(INNLIBS)
-inndf:		inndf.o      $(BOTH)	; $(LINK) inndf.o      $(STORELIBS)
+inndf:		inndf.o      $(BOTH)	; $(LINKDEPS) inndf.o  $(STORELIBS)
 innxbatch:	innxbatch.o  $(LIBINN)	; $(LINK) innxbatch.o  $(INNLIBS)
 innxmit:	innxmit.o    $(BOTH)	; $(LINK) innxmit.o    $(STORELIBS)
 ninpaths:	ninpaths.o		; $(LINK) ninpaths.o
 nntpget:	nntpget.o    $(BOTH)	; $(LINK) nntpget.o    $(STORELIBS)
-overchan:	overchan.o   $(BOTH)	; $(LINK) overchan.o   $(STORELIBS)
+overchan:	overchan.o   $(BOTH)	; $(LINKDEPS) overchan.o $(STORELIBS)
 shlock:		shlock.o     $(LIBINN)	; $(LINK) shlock.o     $(INNLIBS)
 shrinkfile:	shrinkfile.o $(LIBINN)	; $(LINK) shrinkfile.o $(INNLIBS)
 

Modified: configure.ac
===================================================================
--- configure.ac	2020-11-21 07:02:43 UTC (rev 10405)
+++ configure.ac	2020-11-21 08:47:28 UTC (rev 10406)
@@ -97,6 +97,7 @@
 LIBTOOLCC='$(top)/libtool --mode=compile'
 LIBTOOLINST='$(top)/libtool --mode=install'
 LIBTOOLLD='$(top)/libtool --mode=link'
+LIBTOOLLDDEPS='$(top)/libtool --mode=link --preserve-dup-deps'
 CCOUTPUT='-c -o $@ $<'
 AC_SUBST(EXTLIB)
 AC_SUBST(EXTOBJ)
@@ -103,6 +104,7 @@
 AC_SUBST(LIBTOOLCC)
 AC_SUBST(LIBTOOLINST)
 AC_SUBST(LIBTOOLLD)
+AC_SUBST(LIBTOOLLDDEPS)
 AC_SUBST(CCOUTPUT)
 
 dnl Command-line options.  Many of these macros just do the command-line

Modified: frontends/Makefile
===================================================================
--- frontends/Makefile	2020-11-21 07:02:43 UTC (rev 10405)
+++ frontends/Makefile	2020-11-21 08:47:28 UTC (rev 10406)
@@ -63,9 +63,12 @@
 
 ##  Compilation rules.
 
-BOTH		= $(LIBSTORAGE) $(LIBHIST) $(LIBINN)
+# $(LIBSTORAGE) must be listed twice to resolve circular dependencies
+# when doing static linking.
+BOTH		= $(LIBSTORAGE) $(LIBHIST) $(LIBSTORAGE) $(LIBINN)
 
 LINK 		= $(LIBLD) $(LDFLAGS) -o $@
+LINKDEPS	= $(LIBLDDEPS) $(LDFLAGS) -o $@
 INNLIBS		= $(LIBINN) $(LIBS)
 STORELIBS	= $(BOTH) $(STORAGE_LIBS) $(LIBS)
 
@@ -77,10 +80,14 @@
 getlist:	getlist.o      $(LIBINN) ; $(LINK) getlist.o      $(INNLIBS)
 inews:		inews.o        $(LIBINN) ; $(LINK) inews.o        $(INNLIBS)
 innconfval:	innconfval.o   $(LIBINN) ; $(LINK) innconfval.o   $(INNLIBS)
-ovdb_init:	ovdb_init.o    $(BOTH)   ; $(LINK) ovdb_init.o    $(STORELIBS)
-ovdb_monitor:	ovdb_monitor.o $(BOTH)   ; $(LINK) ovdb_monitor.o $(STORELIBS)
-ovdb_server:	ovdb_server.o  $(BOTH)   ; $(LINK) ovdb_server.o  $(STORELIBS)
-ovdb_stat:	ovdb_stat.o    $(BOTH)   ; $(LINK) ovdb_stat.o    $(STORELIBS)
+ovdb_init:	ovdb_init.o    $(BOTH)
+	$(LINKDEPS) ovdb_init.o    $(STORELIBS)
+ovdb_monitor:	ovdb_monitor.o $(BOTH)
+	$(LINKDEPS) ovdb_monitor.o $(STORELIBS)
+ovdb_server:	ovdb_server.o  $(BOTH)
+	$(LINKDEPS) ovdb_server.o  $(STORELIBS)
+ovdb_stat:	ovdb_stat.o    $(BOTH)
+	$(LINKDEPS) ovdb_stat.o    $(STORELIBS)
 rnews:		rnews.o        $(BOTH)   ; $(LINK) rnews.o        $(STORELIBS)
 sm:		sm.o           $(BOTH)   ; $(LINK) sm.o           $(STORELIBS)
 

Modified: storage/buffindexed/ovmethod.mk
===================================================================
--- storage/buffindexed/ovmethod.mk	2020-11-21 07:02:43 UTC (rev 10405)
+++ storage/buffindexed/ovmethod.mk	2020-11-21 08:47:28 UTC (rev 10406)
@@ -4,5 +4,5 @@
 	$(LIBCC) $(CFLAGS) -DBUFF_DEBUG -c -o $@ buffindexed/buffindexed.c
 
 buffindexed/buffindexed_d: buffindexed/buffindexed_d.$(EXTOBJ) libstorage.$(EXTLIB) $(LIBHIST)
-	$(LIBLD) $(LDFLAGS) -o $@ buffindexed/buffindexed_d.$(EXTOBJ) \
+	$(LIBLDDEPS) $(LDFLAGS) -o $@ buffindexed/buffindexed_d.$(EXTOBJ) \
 	    $(LIBSTORAGE) $(LIBHIST) $(LIBINN) $(STORAGE_LIBS) $(LIBS)

Modified: support/ltmain.sh
===================================================================
--- support/ltmain.sh	2020-11-21 07:02:43 UTC (rev 10405)
+++ support/ltmain.sh	2020-11-21 08:47:28 UTC (rev 10406)
@@ -5,9 +5,9 @@
 #############################
 # This file has been modified from the standard libtool version to
 # recognize the additional -S flag that INN's install-sh program
-# recognizes; apart from that, it is identical to the stock libtool
-# distribution.
-# Only one part of the code is modified; search for the comment below
+# supports, and fix a bug when using --preserve-dup-deps Libtool flag;
+# apart from that, it is identical to the stock libtool distribution.
+# Only two parts of the code are modified; search for the comments below
 # containing "INN".
 
 # libtool (GNU libtool) 2.4.6
@@ -8686,41 +8686,46 @@
 	  eval tmp_libs=\"\$$var\"
 	  new_libs=
 	  for deplib in $tmp_libs; do
-	    # FIXME: Pedantically, this is the right thing to do, so
-	    #        that some nasty dependency loop isn't accidentally
-	    #        broken:
-	    #new_libs="$deplib $new_libs"
-	    # Pragmatically, this seems to cause very few problems in
-	    # practice:
-	    case $deplib in
-	    -L*) new_libs="$deplib $new_libs" ;;
-	    -R*) ;;
-	    *)
-	      # And here is the reason: when a library appears more
-	      # than once as an explicit dependence of a library, or
-	      # is implicitly linked in more than once by the
-	      # compiler, it is considered special, and multiple
-	      # occurrences thereof are not removed.  Compare this
-	      # with having the same library being listed as a
-	      # dependency of multiple other libraries: in this case,
-	      # we know (pedantically, we assume) the library does not
-	      # need to be listed more than once, so we keep only the
-	      # last copy.  This is not always right, but it is rare
-	      # enough that we require users that really mean to play
-	      # such unportable linking tricks to link the library
-	      # using -Wl,-lname, so that libtool does not consider it
-	      # for duplicate removal.
-	      case " $specialdeplibs " in
-	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
+            # Modification for INN in the loop (fix --preserve-dup-deps).
+            if $opt_preserve_dup_deps; then
+	      # Pedantically, this is the right thing to do, so
+	      # that some nasty dependency loop isn't accidentally
+	      # broken.
+	      new_libs="$deplib $new_libs"
+            else
+	      # Pragmatically, this seems to cause very few problems in
+	      # practice:
+	      case $deplib in
+	      -L*) new_libs="$deplib $new_libs" ;;
+	      -R*) ;;
 	      *)
-		case " $new_libs " in
-		*" $deplib "*) ;;
-		*) new_libs="$deplib $new_libs" ;;
-		esac
-		;;
-	      esac
-	      ;;
-	    esac
+	        # And here is the reason: when a library appears more
+	        # than once as an explicit dependence of a library, or
+	        # is implicitly linked in more than once by the
+	        # compiler, it is considered special, and multiple
+	        # occurrences thereof are not removed.  Compare this
+	        # with having the same library being listed as a
+	        # dependency of multiple other libraries: in this case,
+	        # we know (pedantically, we assume) the library does not
+	        # need to be listed more than once, so we keep only the
+	        # last copy.  This is not always right, but it is rare
+	        # enough that we require users that really mean to play
+	        # such unportable linking tricks to link the library
+	        # using -Wl,-lname, so that libtool does not consider it
+	        # for duplicate removal.  And if not possible for portability
+                # reasons, then --preserve-dup-deps should be used.
+	        case " $specialdeplibs " in
+	        *" $deplib "*) new_libs="$deplib $new_libs" ;;
+	        *)
+		  case " $new_libs " in
+		  *" $deplib "*) ;;
+		  *) new_libs="$deplib $new_libs" ;;
+		  esac
+		  ;;
+	        esac
+	        ;;
+             esac
+            fi
 	  done
 	  tmp_libs=
 	  for deplib in $new_libs; do

Modified: tests/Makefile
===================================================================
--- tests/Makefile	2020-11-21 07:02:43 UTC (rev 10405)
+++ tests/Makefile	2020-11-21 08:47:28 UTC (rev 10406)
@@ -55,6 +55,7 @@
 	$(CC) $(CFLAGS) -c -o $@ $*.c
 
 LINK		= $(LIBTOOLLD) $(CC) $(LDFLAGS) $(BDB_LDFLAGS) $(SSL_LDFLAGS) $(SASL_LDFLAGS) $(KRB5_LDFLAGS) -o $@
+LINKDEPS	= $(LIBTOOLLDDEPS) $(CC) $(LDFLAGS) $(BDB_LDFLAGS) $(SSL_LDFLAGS) $(SASL_LDFLAGS) $(KRB5_LDFLAGS) -o $@
 STORAGEDEPS	= $(LIBSTORAGE) $(LIBHIST) $(LIBINN)
 STORAGELIBS	= $(STORAGEDEPS) $(STORAGE_LIBS)
 
@@ -269,22 +270,22 @@
 	    tap/messages.o tap/string.o $(LIBINN)
 
 overview/api.t: overview/api-t.o tap/basic.o $(STORAGEDEPS)
-	$(LINK) overview/api-t.o tap/basic.o $(STORAGELIBS) $(LIBS)
+	$(LINKDEPS) overview/api-t.o tap/basic.o $(STORAGELIBS) $(LIBS)
 
 overview/buffindexed-t.o: overview/overview-t.c
 	$(CC) $(CFLAGS) -DOVTYPE=buffindexed -c -o $@ overview/overview-t.c
 
 overview/buffindexed.t: overview/buffindexed-t.o tap/basic.o $(STORAGEDEPS)
-	$(LINK) overview/buffindexed-t.o tap/basic.o $(STORAGELIBS) $(LIBS)
+	$(LINKDEPS) overview/buffindexed-t.o tap/basic.o $(STORAGELIBS) $(LIBS)
 
 overview/tradindexed-t.o: overview/overview-t.c
 	$(CC) $(CFLAGS) -DOVTYPE=tradindexed -c -o $@ overview/overview-t.c
 
 overview/tradindexed.t: overview/tradindexed-t.o tap/basic.o $(STORAGEDEPS)
-	$(LINK) overview/tradindexed-t.o tap/basic.o $(STORAGELIBS) $(LIBS)
+	$(LINKDEPS) overview/tradindexed-t.o tap/basic.o $(STORAGELIBS) $(LIBS)
 
 overview/xref.t: overview/xref-t.o tap/basic.o $(STORAGEDEPS)
-	$(LINK) overview/xref-t.o tap/basic.o $(STORAGELIBS) $(LIBS)
+	$(LINKDEPS) overview/xref-t.o tap/basic.o $(STORAGELIBS) $(LIBS)
 
 util/innbind.t: util/innbind-t.o tap/basic.o $(LIBINN)
 	$(LINK) util/innbind-t.o tap/basic.o $(LIBINN) $(LIBS)



More information about the inn-committers mailing list