GNU bug report logs - #36184
Re-ordering of shared libraries causing a crash

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: libtool; Reported by: Mohammad Akhlaghi <mohammad@HIDDEN>; dated Wed, 12 Jun 2019 20:01:02 UTC; Maintainer for libtool is bug-libtool@HIDDEN.

Message received at submit <at>

Received: (at submit) by; 12 Jun 2019 20:00:51 +0000
From debbugs-submit-bounces <at> Wed Jun 12 16:00:50 2019
Received: from localhost ([]:34111
	by with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at>>)
	id 1hb9QH-000692-Aj
	for submit <at>; Wed, 12 Jun 2019 16:00:50 -0400
Received: from ([]:39427)
 by with esmtp (Exim 4.84_2)
 (envelope-from <mohammad@HIDDEN>) id 1hb9QE-00068u-TE
 for submit <at>; Wed, 12 Jun 2019 16:00:39 -0400
Received: from ([2001:470:142:3::10]:44649)
 by with esmtp (Exim 4.86_2)
 (envelope-from <mohammad@HIDDEN>) id 1hb9QD-0001F0-9M
 for bug-libtool@HIDDEN; Wed, 12 Jun 2019 16:00:38 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_40,RCVD_IN_DNSWL_LOW
 autolearn=disabled version=3.3.2
Received: from Debian-exim by with spam-scanned (Exim 4.71)
 (envelope-from <mohammad@HIDDEN>) id 1hb9ML-0005lY-Ls
 for bug-libtool@HIDDEN; Wed, 12 Jun 2019 15:56:39 -0400
Received: from ([]:52005)
 by with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <mohammad@HIDDEN>)
 id 1hb9MK-0005hY-6f
 for bug-libtool@HIDDEN; Wed, 12 Jun 2019 15:56:36 -0400
Received: from compute5.internal (compute5.nyi.internal [])
 by mailout.nyi.internal (Postfix) with ESMTP id 9DA1D21AF1
 for <bug-libtool@HIDDEN>; Wed, 12 Jun 2019 15:56:31 -0400 (EDT)
Received: from mailfrontend2 ([])
 by compute5.internal (MEProxy); Wed, 12 Jun 2019 15:56:31 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; h=
 :content-transfer-encoding; s=fm3; bh=tlJV8inz8zUkvGreLum+4QUgC7
 1dPSWT2/vvmyjzQuc=; b=D1CLGB0Jm8XZxTKXczOt+d+WYjLDtKBaOnyjvpTSCf
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=; h=content-transfer-encoding:content-type
 :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=tlJV8i
 nz8zUkvGreLum+4QUgC71dPSWT2/vvmyjzQuc=; b=gc7R0KZcRCqxzy6Qw2n0+9
X-ME-Sender: <xms:7lgBXY1kkdvQ4LGpwXruJ9uCXQdnWe5xfj8ou8Xr2GtXKY_FJAzD7w>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgudehtdcutefuodetggdotefrod
X-ME-Proxy: <xmx:7lgBXU9bj_1C7qhJjvG4j5_VjS0GmHRh-Yic_OrI5YJ7cWFcPIAgLg>
Received: from [] (unknown [])
 by (Postfix) with ESMTPA id 25EA7380085
 for <bug-libtool@HIDDEN>; Wed, 12 Jun 2019 15:56:30 -0400 (EDT)
From: Mohammad Akhlaghi <mohammad@HIDDEN>
Subject: Re-ordering of shared libraries causing a crash
To: bug-libtool@HIDDEN
Message-ID: <4f8169a1-5f2d-f690-9273-d4666d103399@HIDDEN>
Date: Wed, 12 Jun 2019 20:56:04 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at>
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <>
List-Unsubscribe: <>, 
 <mailto:debbugs-submit-request <at>>
List-Archive: <>
List-Post: <mailto:debbugs-submit <at>>
List-Help: <mailto:debbugs-submit-request <at>>
List-Subscribe: <>, 
 <mailto:debbugs-submit-request <at>>
Errors-To: debbugs-submit-bounces <at>
Sender: "Debbugs-submit" <debbugs-submit-bounces <at>>
X-Spam-Score: 0.2 (/)

Dear Libtool maintainers,

A new user of Gnuastro recently reported a problem in building Gnuastro 
and after digging into the problem, I think its source lies with 
Libtool, so I thought of consulting you here.

Gnuastro first builds its library (libgnuastro), then goes onto building 
its separate programs (astarithmetic is the first one). The library 
needs to link with several dependency libraries. So when building the 
programs, `-lgnuastro' has to be linked first, then all the dependency 

Recently we started using Gnulib's `AC_LIB_HAVE_LINKFLAGS' to check for 
the presence of libraries during the configure step. We append the 
results for all the dependency libraries into one variable 
(`CONFIG_LDADD') and use that when linking the individual programs. For 
example here you can see the for `astarithmetic':

However, when there are multiple versions of a library in the search 
path, apparently `AC_LIB_HAVE_LINKFLAGS' doesn't actually add a `-l' 
option, but it returns the full path of the shared library. As a result, 
on my system, `CONFIG_LDADD' looks like this (notice them several `.so' 

CONFIG_LDADD='-lgit2 -ltiff -llzma -ljpeg -lwcs -lcfitsio -lcurl -lz 
/usr/local/lib/ /usr/local/lib/ -lm -Wl,-rpath 
-Wl,/usr/local/lib -lm '

However, when we run `make' to build Gnuastro, Libtool apparently 
re-orders the libraries such that those without a `-l' come before those 
with it, you can see the relevant commands during `make' below (note how 
the order is preserved at first, but in the second command, the GSL 
`.so' files are all placed before those starting with `-l', in 
particular, before `'):

/bin/bash ../../libtool  --tag=CC   --mode=link gcc  -Wall -O3  -pthread 
-L\../../lib  -o astarithmetic main.o ui.o arithmetic.o operands.o 
../../bootstrapped/lib/ -lgnuastro -lgit2 -ltiff -llzma -ljpeg 
-lwcs -lcfitsio -lcurl -lz /usr/local/lib/ 
/usr/local/lib/ -lm -Wl,-rpath -Wl,/usr/local/lib -lm
libtool: link: gcc -Wall -O3 -pthread -o .libs/astarithmetic main.o ui.o 
arithmetic.o operands.o /usr/local/lib/ 
/usr/local/lib/ -Wl,-rpath -Wl,/usr/local/lib  -L../../lib 
/home/id/gnuastro-0.9.55-9d7d/lib/.libs/ -lgit2 -ltiff 
-llzma -ljpeg -lwcs -lcfitsio 
/usr/lib/x86_64-linux-gnu/ -lz -lm -pthread

On my system (Arch Linux, GCC 8.3.0) I also get a re-ordering, but it 
doesn't cause a problem. However, on the user's system (Ubuntu 18.04, 
GCC 7.4.0), it causes a linking error, complaining that there are 
undefined GSL symbols in `'.

To me it looks like the problem is in the re-ordering of the libraries. 
But I am a little confused why it complains on one system and doesn't 
complain on another.

Could you please guide me on the best way to solve this problem?

Thank you very much,

Acknowledgement sent to Mohammad Akhlaghi <mohammad@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-libtool@HIDDEN. Full text available.
Report forwarded to bug-libtool@HIDDEN:
bug#36184; Package libtool. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
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.