Le 07/03/2013 19:51, Matt Burgess a écrit : > On Thu, 2013-03-07 at 14:57 +0100, Pierre Labastie wrote: > >> Please add --with-sysroot to the configure switches in binutils-pass2. >> It is harmless (just adds a feature to ld), and corrects that bug. > I think you meant --with-build-sysroot, right? The configure help > output for that says > > --with-build-sysroot=SYSROOT > use sysroot as the system root during the build > > So, I assume just '--with-build-sysroot' is enough, i.e. setting it to a > null value? I still don't understand what that flag does and why/how it > fixes this issue. More importantly, I don't understand if it will > affect our builds in any other way. > > I'll see if I can dig out some docs, but if anyone knows in the mean > time, I'm all ears. > I really meant --with-sysroot. That switch is defined in ld's configure, not the top one. (it might be better to use --with-sysroot=/, but --with-sysroot works for me). It changes the behavior of ld: from "man ld": -rpath=dir Add a directory to the runtime library search path. This is used when linking an ELF executable with shared objects. All -rpath arguments are concatenated and passed to the runtime linker, which uses them to locate shared objects at runtime. The -rpath option is also used when locating shared objects which are needed by shared objects explicitly included in the link; see the description of the -rpath-link option. If -rpath is not used when linking an ELF executable, the contents of the environment variable "LD_RUN_PATH" will be used if it is defined. [...] -rpath-link=dir When using ELF or SunOS, one shared library may require another. This happens when an "ld -shared" link includes a shared library as one of the input files.
When the linker encounters such a dependency when doing a non- shared, non-relocatable link, it will automatically try to locate the required shared library and include it in the link, if it is not included explicitly. In such a case, the -rpath-link option specifies the first set of directories to search. The -rpath-link option may specify a sequence of directory names either by specifying a list of names separated by colons, or by appearing multiple times. This option should be used with caution as it overrides the search path that may have been hard compiled into a shared library. In such a case it is possible to use unintentionally a different search path than the runtime linker would do. 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. 3. On an ELF system, for native linkers, if the -rpath and -rpath-link options were not used, search the contents of the environment variable "LD_RUN_PATH". 4. On SunOS, if the -rpath option was not used, search any directories specified using -L options. 5. For a native linker, the search the contents of the environment variable "LD_LIBRARY_PATH". 6. For a native ELF linker, the directories in "DT_RUNPATH" or "DT_RPATH" of a shared library are searched for shared libraries needed by it. The "DT_RPATH" entries are ignored if "DT_RUNPATH" entries exist. 7. The default directories, normally /lib and /usr/lib. 8. For a native linker on an ELF system, if the file /etc/ld.so.conf exists, the list of directories found in that file. ----------------------------- Conclusion: gcc uses rpath, but rpath is used to search a shared object required by another one only if the linker has been configured with --with-sysroot. If nothing else is specified, it uses /etc/ld.so.conf, which points to the host libraries, and that is the source of the bug. -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page