Some corrections below, keeping in mind that the binutils build is a
native build, not a cross build.

On Fri, Feb 21, 2020 at 6:05 PM Tadeus Prastowo <[email protected]> wrote:
>
> Hi Pierre,
>
> On Fri, Feb 21, 2020 at 11:01 AM Pierre Labastie via lfs-dev
> <[email protected]> wrote:
> >
> > Le 21/02/2020 à 05:33, Bruce Dubbs via lfs-dev a écrit :
> > > On 2/20/20 10:09 PM, Xi Ruoyao via lfs-dev wrote:
> > >> No.  The linker (/usr/bin/ld) looks at ld.so.conf, but the dynamic linker
> > >> (/lib/ld-linux-x86-64.so.2) looks at ld.so.cache.
> > >
> > > You're right.  I got the tools mixed up.  Thanks.
> > >
> > >   -- Bruce
> > >
> > >>> I'll use the above to try to reword the explanation of the
> > >>> --with-sysroot option.
> >
> > Actually, the main use of the --with-sysroot switch is that it changes the
> > behavior of ld with respect to the -rpath switch. From man ld:
> >
> >            The linker uses the following search paths to locate required
> >            shared libraries:
> >
> >            1.  Any directories specified by -rpath-link options.
> >
> >            2.  Any directories specified by -rpath options.  The difference
> >                between -rpath and -rpath-link is that directories specified 
> > by
> >                -rpath options are included in the executable and used at
> >                runtime, whereas the -rpath-link option is only effective at
> >                link time. Searching -rpath in this way is only supported by
> >                native linkers and cross linkers which have been configured
> >                with the --with-sysroot option.
> >
> > So I think "-rpath" should appear somewhere in this explanation.
>
> But, pay attention to the following passage: "Searching -rpath in this
> way [(i.e., any directories specified by -rpath options)] is only
> supported by [...] cross linkers which have been configured with the
> --with-sysroot option."  It means that, if the `--with-sysroot' option
> is not given to configure binutils, the resulting ld will ignore any
> -rpath given in the command line.  This means that not specifying the
> `--with-sysroot' option is indeed a good idea because any path
> specified using the `-rpath' option will simply be ignored, keeping
> the /tools isolated from the build system.

No, the `-rpath' option is not ignored because the problem at hand is
building a native binutils.

> > The --with-sysroot switch has not effect if ld is called without -rpath 
> > option...
>
> That's not true for the problem at hand because the `--with-sysroot'
> switch indeed has an effect as already reported in the other thread
> despite the absent of the `-rpath' option in the linking command.

This stands correct.  The `--with-sysroot' option has an effect even
if ld is called without any `-rpath' option.

> And, the problem at hand uses an ld for a static linking to obtain the
> perl executable because both the option `-shared' and *.so files are
> not specified in the linking command, no?

There exists a linking to dynamic libraries due to the use of -lm and,
due to Time/HiRes, -lrt.

> > Let me try with my non-native English:
> > This option will change the linker behavior when it is run with a command
> > containing the -rpath switch: any linked library will be searched into the
> > path specified by -rpath before searching other locations such as
> > /etc/ld.so.conf. Note that since the default sysroot location does not 
> > exist,
> > it does not intervene in the searching process. Without the --with-sysroot
> > option, the -rpath path is not used for searching dependent libraries, with
> > the risk of finding host libraries, which defeats the effort of having a 
> > clean
> > build.
>
> Keeping in mind that the `-rpath' option has an effect if the option
> `--with-sysroot' is given when configuring binutils, the main reason
> for using the option `--with-sysroot' in the first place cannot be the
> `-rpath' option as you described.

That is wrong.  Sorry.  So, I think the explanation can be cut short as follows:

This option will prevent the linker from looking in places in the
build system (e.g., those specified by the `-rpath' options and
default files, such as /etc/ld.so.conf).  This option forces the
linker to look only in places within the non-existent default sysroot
directory /tools/$LFS_TGT/sys-root, effectively enforcing a clean
build of /tools.

> > Pierre
>
> --
> Best regards,
> Tadeus
-- 
http://lists.linuxfromscratch.org/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to