From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#26048: Use absolute file names in NEED instead of adding many entries to RUNPATH Date: Tue, 21 Nov 2017 14:35:39 +0100 Message-ID: <871skrn49g.fsf@gnu.org> References: <87zigt89cf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eH8id-00071c-VD for bug-guix@gnu.org; Tue, 21 Nov 2017 08:36:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eH8iY-0002Dk-90 for bug-guix@gnu.org; Tue, 21 Nov 2017 08:36:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:41398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eH8iY-0002Dd-56 for bug-guix@gnu.org; Tue, 21 Nov 2017 08:36:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eH8iX-0004BP-UN for bug-guix@gnu.org; Tue, 21 Nov 2017 08:36:01 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87zigt89cf.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 10 Mar 2017 16:01:04 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: 26048@debbugs.gnu.org ludo@gnu.org (Ludovic Court=C3=A8s) skribis: > As Andy just noted on IRC, shared library lookup is inefficient in Guix, > because there=E2=80=99s one entry per library in RUNPATH. So we get: > > open("/gnu/store/y8ppqsxiki39n4mqpb4mab6bgwqsnnp7-libgc-7.4.2/lib/libm.so= .6", O_RDONLY|O_CLOEXEC) =3D -1 ENOENT (No such file or directory) > open("/gnu/store/w0bkj9qh7iqcklm5ld8ghg1ynnzqyv00-libffi-3.2.1/lib/libm.s= o.6", O_RDONLY|O_CLOEXEC) =3D -1 ENOENT (No such file or directory) > open("/gnu/store/d5gw4i6bnyznmbr55ba39bl3pgrhsyp0-libunistring-0.9.6/lib/= libm.so.6", O_RDONLY|O_CLOEXEC) =3D -1 ENOENT (No such file or directory) > open("/gnu/store/6k08nkddnrb15h5pwp1s0fa94mr1qas9-gmp-6.1.1/lib/libm.so.6= ", O_RDONLY|O_CLOEXEC) =3D -1 ENOENT (No such file or directory) > open("/gnu/store/9yn89bkl8vcg5rh9dmw3jijciwgrwjls-libltdl-2.4.6/lib/libm.= so.6", O_RDONLY|O_CLOEXEC) =3D -1 ENOENT (No such file or directory) > open("/gnu/store/iwgi9001dmmihrjg4rqhd6pa6788prjw-glibc-2.24/lib/libm.so.= 6", O_RDONLY|O_CLOEXEC) =3D 3 > > An alternate approach would be for ld-wrapper to replace =E2=80=9C-lfoo= =E2=80=9D with > =E2=80=9C/gnu/store/=E2=80=A6/libfoo.so=E2=80=9D, which would add the abs= olute file name as > NEEDed in the ELF file. This is actually impossible, as discussed at : Per the ELF v1.2 spec=C2=B9 (page 82), setting DT_NEEDED to an absolute file name would prevent overriding via LD_LIBRARY_PATH, which is not desirable. It turns out we cannot even set DT_NEEDED to an absolute file name in the first place, because ld records the DT_SONAME of the library, when it=E2=80=99s available (which is the case most of the time), rather than = its file name. =C2=B9 http://refspecs.linuxbase.org/elf/elf.pdf Ludo=E2=80=99.