[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] build: Fix shared build with gcc-7.
From: |
Jan Nieuwenhuizen |
Subject: |
Re: [PATCH] build: Fix shared build with gcc-7. |
Date: |
Thu, 19 Mar 2020 15:47:38 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Samuel Thibault writes:
Hi Samuel,
> Jan Nieuwenhuizen, le jeu. 19 mars 2020 12:13:13 +0100, a ecrit:
>> Samuel Thibault writes:
>> > Jan Nieuwenhuizen, le sam. 14 mars 2020 11:35:18 +0100, a ecrit:
>> --8<---------------cut here---------------start------------->8---
>> $ i586-pc-gnu-gcc -L. -L../libihash/ -L../libports/ -L../libiohelp/
>> -L../libhurdbugaddr/ -L../libshouldbeinlibc/ -L../libfshelp/ -std=gnu99
>> -fgnu89-inline -Wall -g -O3 -fno-strict-aliasing -g -O2
>> -uargp_program_bug_address -o test-fcntl \
>> test-fcntl.o \
>> '-Wl,-(' ../libhurdbugaddr/libhurdbugaddr.so ../libfshelp/libfshelp.so
>> \
>> -lpthread \
>> '-Wl,-)'
>
>> i586-pc-gnu-ld: warning: libshouldbeinlibc.so.0.3, needed by
>> ../libfshelp/libfshelp.so, not found (try using -rpath or -rpath-link)
>
> Ok, so we do have -L../libshouldbeinlibc/, and I guess
> -L../libshouldbeinlibc/libshouldbeinlibc.so.0.3 does exist?
Yes, certainly.
>> Note how it says: (try using -rpath ...?).
>
> Yes, but like many warnings, they can be misleading. In general we do
> not want rpath.
... (sure)
>> i586-pc-gnu-gcc -L. -Wl,-rpath=../libihash/ -Wl,-rpath=../libports/
>> -Wl,-rpath=../libiohelp/ -Wl,-rpath=../libhurdbugaddr/
>> -Wl,-rpath=../libshouldbeinlibc/ -L../libfshelp/ -std=gnu99 -fgnu89-inline
>> -Wall -g -O3 -fno-strict-aliasing -g -O2 -uargp_program_bug_address -o
>> test-fcntl \
>> test-fcntl.o \
>> '-Wl,-(' ../libhurdbugaddr/libhurdbugaddr.so ../libfshelp/libfshelp.so
>> \
>> -lpthread \
>> '-Wl,-)'
>>
>> it succeeds.
>
> But then if you run objdump -x test-fcntl you will see
>
> RUNPATH ../libports/
>
> which we definitely do not want to keep for the installed binary :)
Right!
> Using -rpath-link would apparently avoid recording it, and only use it
> for the link, which does make sense. I'd say try to use that instead in
> your patch, and we can commit that.
Ah, it suggested -rpath-link; I somehow managed to overlook that; I
didn't notice that concept earlier.
Yes, with -rpath-link works for me and it indeed does not show up in
RUNPATH
/gnu/store/d0wpwkb6ws0hv1kbh47kba11wa6b3lr6-hurd-0.9-1.91a5167/lib:/gnu/store/zv4gnc0xlzbbvbsvlch2mpky8q8bskqm-glibc-cross-i586-pc-gnu-2.31/lib:/gnu/store/aghiyhwwy32x352njaq2fj9pmzg289iy-gcc-cross-i586-pc-gnu-7.5.0/i586-pc-gnu/lib:/gnu/store/aghiyhwwy32x352njaq2fj9pmzg289iy-gcc-cross-i586-pc-gnu-7.5.0/lib/gcc/i586-pc-gnu/7.5.0/../../../../i586-pc-gnu/lib
unlike it indeed does with -rpath:
RUNPATH
../libbpf/:../libcons/:../libfshelp/:../libftpconn/:../libhurdbugaddr/:../libhurd-slab/:../libihash/:../libiohelp/:../libpager/:../libpipe/:../libports/:../libps/:../libshouldbeinlibc/:../libstore/:../libthreads/:/gnu/store/vzgqkigpifcdbls1g10cnr98132l14y4-hurd-0.9-1.91a5167/lib:/gnu/store/zv4gnc0xlzbbvbsvlch2mpky8q8bskqm-glibc-cross-i586-pc-gnu-2.31/lib:/gnu/store/aghiyhwwy32x352njaq2fj9pmzg289iy-gcc-cross-i586-pc-gnu-7.5.0/i586-pc-gnu/lib:/gnu/store/aghiyhwwy32x352njaq2fj9pmzg289iy-gcc-cross-i586-pc-gnu-7.5.0/lib/gcc/i586-pc-gnu/7.5.0/../../../../i586-pc-gnu/lib
>> the succeeding native collect2, apparentlty finding some libraries in
>> /usr
>
> Actually we do not want to succeed just because it finds libs from /lib
> or /usr/lib
Ok. So, updated patch attached (the commit message was really off now
that we understand better what's going on; changed that too).
Thanks! Greetings,
janneke
>From 5fc69170ad38ba431004a9b50fcea585d576c36e Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Sat, 14 Mar 2020 11:28:31 +0100
Subject: [PATCH] build: Fix cross build on Guix.
As discussed in
https://lists.gnu.org/archive/html/bug-hurd/2020-03/msg00018.html.
* Makeconf (lpath): Add -Wl,-rpath-link <dir> next to -L <dir>.
---
Makeconf | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makeconf b/Makeconf
index 67f7ab1c..829f60c7 100644
--- a/Makeconf
+++ b/Makeconf
@@ -325,7 +325,8 @@ _libsubst=${libsubst$(patsubst
%,-override,${libsubst-override})}
# Direct the linker where to find shared objects specified in the
# dependencies of other shared objects it encounters.
-lpath := -L. $(patsubst %,-L%,$(dir $(wildcard ../lib*/lib*.so)))
+lib_dirs := $(dir $(wildcard ../lib*/lib*.so))
+lpath := -L. $(lib_dirs:%=-L%) $(lib_dirs:%=-Wl,-rpath=%)
# Main rule to link executables
#
--
2.24.0
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.com