GNU logs - #27722, boring messages


Message sent to bug-libtool@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#27722: libtool makes it impossible to build a package statically
Resent-From: Bruno Haible <bruno@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-libtool@HIDDEN
Resent-Date: Sat, 15 Jul 2017 22:50:01 +0000
Resent-Message-ID: <handler.27722.B.150015898116192 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 27722
X-GNU-PR-Package: libtool
X-GNU-PR-Keywords: 
To: 27722 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-libtool@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.150015898116192
          (code B ref -1); Sat, 15 Jul 2017 22:50:01 +0000
Received: (at submit) by debbugs.gnu.org; 15 Jul 2017 22:49:41 +0000
Received: from localhost ([127.0.0.1]:40784 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dWVsV-0004D0-UV
	for submit <at> debbugs.gnu.org; Sat, 15 Jul 2017 18:49:40 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45153)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <bruno@HIDDEN>) id 1dWVsT-0004Co-K1
 for submit <at> debbugs.gnu.org; Sat, 15 Jul 2017 18:49:34 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1dWVsN-0007yH-1u
 for submit <at> debbugs.gnu.org; Sat, 15 Jul 2017 18:49:28 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:43966)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1dWVsM-0007xv-Ta
 for submit <at> debbugs.gnu.org; Sat, 15 Jul 2017 18:49:26 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36114)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1dWVsJ-0001x9-OG
 for bug-libtool@HIDDEN; Sat, 15 Jul 2017 18:49:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <bruno@HIDDEN>) id 1dWVsG-0007lz-EB
 for bug-libtool@HIDDEN; Sat, 15 Jul 2017 18:49:23 -0400
Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::12]:32494)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <bruno@HIDDEN>) id 1dWVsG-0007in-0m
 for bug-libtool@HIDDEN; Sat, 15 Jul 2017 18:49:20 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1500158958;
 l=7974; s=domk; d=clisp.org;
 h=Content-Transfer-Encoding:Content-Type:MIME-Version:Date:Subject:To:
 From; bh=5ejdzU+GSmORKFeMDJoaB8NE877yiG+Tya+dmGA57+8=;
 b=AAPwWnQwb0LO4uuAvyu7H4+K967g80AGl5d5X2jXGD/XfMlCUjahbElVNGSubiGpiw
 b4pjT2qgXoSK9SnNZXCJHsdKZo9BJDry1eAxieI/vavBEka9MbZ3heHQCCQ2ClbzKI0U
 4AmQx5i8X3vhCSs8Db/xa6E16s2SMckhbPA/o=
X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRavM45bp2
X-RZG-CLASS-ID: mo00
Received: from bruno.haible.de
 (dslb-088-068-035-076.088.068.pools.vodafone-ip.de [88.68.35.76])
 by smtp.strato.de (RZmta 41.1 DYNA|AUTH)
 with ESMTPSA id x01200t6FMgxplN
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH
 bits, eq. 15360 bits RSA)) (Client did not present a certificate);
 Sun, 16 Jul 2017 00:42:59 +0200 (CEST)
From: Bruno Haible <bruno@HIDDEN>
Date: Sun, 16 Jul 2017 00:42:58 +0200
Message-ID: <3009480.1b2adHvoDB@omega>
User-Agent: KMail/5.1.3 (Linux/4.4.0-83-generic; KDE/5.18.0; x86_64; ; )
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="nextPart4252892.gXJH3gUTyE"
Content-Transfer-Encoding: 7Bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

This is a multi-part message in MIME format.

--nextPart4252892.gXJH3gUTyE
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

Hi,

Summary
-------

The processing of the '-static' option by "libtool --mode=link" makes it
impossible to build a package in such a way that
  1) all libraries are static,
  2) all binaries are statically linked (ldd reports "not a dynamic executable").

Motivation
----------

There are many use-cases of statically linked binaries. In my case it's
because I want to run programs under qemu in "user mode", and for big-endian
CPUs currently only statically linked binaries work. [1]

Details
-------

In packages that don't create shared libraries and therefore don't use libtool,
the way to achieve statically linked binaries (assuming GCC) is simple:

  $ ./configure LDFLAGS="-static"

For packages that create *only* shared libraries, the GNU libtool manual
provides a solution [2][3]:

  $ ./configure --enable-static --disable-shared LDFLAGS="-all-static"

But this is not a general solution: Some packages, like GNU libffcall,
create shared libraries AND static libraries. But there is only 1 LDFLAGS
parameter that can be passed to 'configure'.

'configure' (thankfully!) does not take 2 different variables LDFLAGS
(for non-libtool linking) and LTLDFLAGS (for libtool linking), because
the use of libtool is an internal detail of a package, and the user who
wants to install it should not see added complexity because of libtool.

So,
1) $ ./configure --enable-static --disable-shared LDFLAGS="-static"
   does not work for producing statically linked binaries because libtool
   intercepts the 'static' option. The result (according to 'ldd') is
   a binary that is linked against the *shared* libc.
2) $ ./configure --enable-static --disable-shared LDFLAGS="-all-static"
   does not work because GCC does not understand a '-all-static' option.
3) The hint given in [4]
   $ ./configure --enable-static --disable-shared LDFLAGS="-Xcompiler -static"
   does not work because GCC does not understand a '-Xcompiler' option.

How to reproduce
----------------

$ wget https://haible.de/bruno/gnu/libiconv-20170715.tar.gz

1) $ tar xvfz libiconv-20170715.tar.gz
   $ cd libiconv-20170715
   $ ./configure --enable-static --disable-shared LDFLAGS="-static"
   $ make
   $ make install DESTDIR=/tmp/inst
   $ LC_ALL=C ldd /tmp/inst/usr/local/bin/iconv
           linux-vdso.so.1 =>  (0x00007fff1a74d000)
           libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fddde90b000)
           /lib64/ld-linux-x86-64.so.2 (0x00005580e2f6c000)

2) $ tar xvfz libiconv-20170715.tar.gz
   $ cd libiconv-20170715
   $ ./configure --enable-static --disable-shared LDFLAGS="-all-static"
   ...
   checking whether the C compiler works... no
   configure: error: in `/tmp/libiconv-20170715':
   configure: error: C compiler cannot create executables
   See `config.log' for more details

3) $ tar xvfz libiconv-20170715.tar.gz
   $ cd libiconv-20170715
   $ ./configure --enable-static --disable-shared LDFLAGS="-Xcompiler -static"
   ...
   checking whether the C compiler works... no
   configure: error: in `/tmp/libiconv-20170715':
   configure: error: C compiler cannot create executables
   See `config.log' for more details

Past reports
------------

In 2004, this was discussed here: [5] already gave the solution, namely to
rename libtool's options. [6] gives the rationale.

For the specific case of GNU binutils, it was reported in 2011: [7][8]

Reported again in 2012: [9][10]

My workaround
-------------

I work around it with the solution from [5]. Instead of '-lt-static'
I chose '-static-uninstalled-libs', in order to reduce the confusion
with the existing option '-static-libtool-libs'.

Patch attached. It touches only the *link* mode of libtool. I don't
see a reason for touching the *compile* mode of libtool, since the
right place for the '-static' option is LDFLAGS, not CFLAGS. [11]

With this patch, it works as expected:

   $ tar xvfz libiconv-20170715.tar.gz
   $ cd libiconv-20170715
   $ patch -p1 < /tmp/libtool-allow-static.diff
   $ ./configure --enable-static --disable-shared LDFLAGS="-static"
   $ make
   $ make install DESTDIR=/tmp/inst
   $ LC_ALL=C ldd /tmp/inst/usr/local/bin/iconv
           not a dynamic executable


Best regards,

         Bruno


[1] https://bugs.launchpad.net/qemu/+bug/1701798
[2] https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html
[3] https://www.sourceware.org/autobook/autobook/autobook_59.html#Linking-against-Libtool-Libraries-with-Automake
[4] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=11064
[5] https://lists.gnu.org/archive/html/libtool/2004-11/msg00017.html
[6] https://lists.gnu.org/archive/html/libtool/2004-11/msg00024.html
[7] https://sourceware.org/ml/binutils/2011-08/msg00159.html
[8] https://sourceware.org/bugzilla/show_bug.cgi?id=13891
[9] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=11064
[10] https://lists.gnu.org/archive/html/bug-libtool/2012-03/msg00011.html
[11] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Preset-Output-Variables.html

--nextPart4252892.gXJH3gUTyE
Content-Disposition: attachment; filename="libtool-allow-static.diff"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="libtool-allow-static.diff"

diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
index 0f0a2da..1d0185a 100644
--- a/build-aux/ltmain.sh
+++ b/build-aux/ltmain.sh
@@ -3720,6 +3720,7 @@ a program from several object files.
 The following components of LINK-COMMAND are treated specially:
 
   -all-static       do not do any dynamic linking at all
+  -static           do not do any dynamic linking at all
   -avoid-version    do not add a version suffix if possible
   -bindir BINDIR    specify path to binaries directory (for systems where
                     libraries must be found in the PATH setting at runtime)
@@ -3746,7 +3747,8 @@ The following components of LINK-COMMAND are treated specially:
   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
   -shared           only do dynamic linking of libtool libraries
   -shrext SUFFIX    override the standard shared library file extension
-  -static           do not do any dynamic linking of uninstalled libtool libraries
+  -static-uninstalled-libs
+                    do not do any dynamic linking of uninstalled libtool libraries
   -static-libtool-libs
                     do not do any dynamic linking of libtool libraries
   -version-info CURRENT[:REVISION[:AGE]]
@@ -6573,9 +6575,9 @@ func_mode_link ()
 	build_old_libs=no
 	break
 	;;
-      -all-static | -static | -static-libtool-libs)
+      -all-static | -static | -static-uninstalled-libs | -static-libtool-libs)
 	case $arg in
-	-all-static)
+	-all-static | -static)
 	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
 	    func_warning "complete static linking is impossible in this configuration"
 	  fi
@@ -6584,7 +6586,7 @@ func_mode_link ()
 	  fi
 	  prefer_static_libs=yes
 	  ;;
-	-static)
+	-static-uninstalled-libs)
 	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
 	    dlopen_self=$dlopen_self_static
 	  fi
@@ -6883,7 +6885,7 @@ func_mode_link ()
       prevarg=$arg
 
       case $arg in
-      -all-static)
+      -all-static | -static)
 	if test -n "$link_static_flag"; then
 	  # See comment for -static flag below, for more details.
 	  func_append compile_command " $link_static_flag"
@@ -7174,9 +7176,9 @@ func_mode_link ()
 	continue
 	;;
 
-      -static | -static-libtool-libs)
-	# The effects of -static are defined in a previous loop.
-	# We used to do the same as -all-static on platforms that
+      -static-uninstalled-libs | -static-libtool-libs)
+	# The effects of -static-uninstalled-libs are defined in a previous
+	# loop.  We used to do the same as -all-static on platforms that
 	# didn't have a PIC flag, but the assumption that the effects
 	# would be equivalent was wrong.  It would break on at least
 	# Digital Unix and AIX.

--nextPart4252892.gXJH3gUTyE--





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Bruno Haible <bruno@HIDDEN>
Subject: bug#27722: Acknowledgement (libtool makes it impossible to build
 a package statically)
Message-ID: <handler.27722.B.150015898116192.ack <at> debbugs.gnu.org>
References: <3009480.1b2adHvoDB@omega>
X-Gnu-PR-Message: ack 27722
X-Gnu-PR-Package: libtool
Reply-To: 27722 <at> debbugs.gnu.org
Date: Sat, 15 Jul 2017 22:50:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-libtool@HIDDEN

If you wish to submit further information on this problem, please
send it to 27722 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
27722: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D27722
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems



Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.