[PATCH] Fine control sysroot runtime behavior.
Benda Xu
heroxbd@gentoo.org
Mon Dec 1 10:22:00 GMT 2014
More information about the Binutils mailing list
Mon Dec 1 10:22:00 GMT 2014
- Previous message (by thread): [PATCH] fine control sysroot runtime behavior
- Next message (by thread): [PATCH] Fine control sysroot runtime behavior.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This is a rebase of patch submitted in http://article.gmane.org/gmane.comp.gnu.binutils/63137 to the HEAD of git repository. Patch updated for the Changelog entries and for regeneration with autoconf and autoheader. The feature sysroot originally for cross compiling has two parts. The first is to prepend lib path, done in configure phase, which we call "configure-time sysroot". The second is to prepend rpath in libraries and path inside ld scripts when ld is called, which we call "runtime sysroot". In case of cross compilation, both are needed. While in case of native sysroot, which runs userland in a directory prefix natively, only configure-time sysroot is needed. Here we add an additional option of --enable-runtime-sysroot to fine control such features. 2014-12-01 Benda Xu <heroxbd@gentoo.org> * configure.ac: add enable-runtime-sysroot to control the macro ENABLE_RUNTIME_SYSROOT * emultempl/elf32.em: only prepend rpath with sysroot when ENABLE_RUNTIME_SYSROOT is defined * ldfile.c: only prepend lib path with sysroot when ENABLE_RUNTIME_SYSROOT is defined * ld.texinfo: document this new behavior for ld script * configure, config.in: regenerate --- ld/ChangeLog | 11 +++++++++++ ld/config.in | 3 +++ ld/configure | 24 ++++++++++++++++++++++-- ld/configure.ac | 12 ++++++++++++ ld/emultempl/elf32.em | 10 +++++++++- ld/ld.texinfo | 19 ++++++++++--------- ld/ldfile.c | 4 ++++ 7 files changed, 71 insertions(+), 12 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 9ec721f..d38b0d4 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,14 @@ +2014-12-01 Benda Xu <heroxbd@gentoo.org> + + * configure.ac: add enable-runtime-sysroot to control the + macro ENABLE_RUNTIME_SYSROOT + * emultempl/elf32.em: only prepend rpath with sysroot when + ENABLE_RUNTIME_SYSROOT is defined + * ldfile.c: only prepend lib path with sysroot when + ENABLE_RUNTIME_SYSROOT is defined + * ld.texinfo: document this new behavior for ld script + * configure, config.in: regenerate + 2014-11-25 H.J. Lu <hongjiu.lu@intel.com> * emulparams/elf_i386.sh (TINY_READONLY_SECTION): New. diff --git a/ld/config.in b/ld/config.in index 2ab4844..46e25db 100644 --- a/ld/config.in +++ b/ld/config.in @@ -11,6 +11,9 @@ language is requested. */ #undef ENABLE_NLS +/* prepend sysroot to libpath in ld script and rpath */ +#undef ENABLE_RUNTIME_SYSROOT + /* Additional extension a shared object might have. */ #undef EXTRA_SHLIB_EXTENSION diff --git a/ld/configure b/ld/configure index 8a7bd20..80a2d6e 100755 --- a/ld/configure +++ b/ld/configure @@ -783,6 +783,7 @@ with_lib_path enable_targets enable_64_bit_bfd with_sysroot +enable_runtime_sysroot enable_gold enable_got enable_werror @@ -1439,6 +1440,10 @@ Optional Features: --disable-largefile omit support for large files --enable-targets alternative target configurations --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes) + --enable-runtime-sysroot + prepend sysroot to libpath in ld script and rpath, + only used in addition to --with-sysroot (default is + yes) --enable-gold[=ARG] build gold [ARG={default,yes,no}] --enable-got=<type> GOT handling scheme (target, single, negative, multigot) @@ -11712,7 +11717,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11715 "configure" +#line 11720 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11818,7 +11823,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11821 "configure" +#line 11826 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15466,6 +15471,21 @@ fi +# Check whether --enable-runtime-sysroot was given. +if test "${enable_runtime_sysroot+set}" = set; then : + enableval=$enable_runtime_sysroot; case "${enableval}" in + no) ;; + *) +$as_echo "#define ENABLE_RUNTIME_SYSROOT /**/" >>confdefs.h + ;; +esac +else + +$as_echo "#define ENABLE_RUNTIME_SYSROOT /**/" >>confdefs.h + +fi + + # Check whether --enable-gold was given. if test "${enable_gold+set}" = set; then : enableval=$enable_gold; case "${enableval}" in diff --git a/ld/configure.ac b/ld/configure.ac index 1bddfc9..9ff7f2f 100644 --- a/ld/configure.ac +++ b/ld/configure.ac @@ -94,6 +94,18 @@ AC_SUBST(use_sysroot) AC_SUBST(TARGET_SYSTEM_ROOT) AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE) +AC_ARG_ENABLE(runtime-sysroot, +[AS_HELP_STRING([--enable-runtime-sysroot], + [prepend sysroot to libpath in ld script and rpath, + only used in addition to --with-sysroot (default is yes)])], +[case "${enableval}" in + no) ;; + *) AC_DEFINE(ENABLE_RUNTIME_SYSROOT, [], \ + [prepend sysroot to libpath in ld script and rpath]) ;; +esac], +AC_DEFINE(ENABLE_RUNTIME_SYSROOT, [], \ + [prepend sysroot to libpath in ld script and rpath])) + dnl Use --enable-gold to decide if this linker should be the default. dnl "install_as_default" is set to false if gold is the default linker. dnl "installed_linker" is the installed BFD linker name. diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 137446f..fe5e58b 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -526,7 +526,10 @@ static char * gld${EMULATION_NAME}_add_sysroot (const char *path) { int len, colons, i; - char *ret, *p; + char *ret; + +#ifdef ENABLE_RUNTIME_SYSROOT + char *p; len = strlen (path); colons = 0; @@ -554,6 +557,11 @@ gld${EMULATION_NAME}_add_sysroot (const char *path) *p++ = path[i++]; *p = 0; +#else + ret = xmalloc (strlen (path) + 1); + strcpy (ret, path); +#endif + return ret; } diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 502582c..4ff99c9 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -3141,15 +3141,16 @@ then you can put @samp{INPUT (subr.o)} in your linker script. In fact, if you like, you can list all of your input files in the linker script, and then invoke the linker with nothing but a @samp{-T} option. -In case a @dfn{sysroot prefix} is configured, and the filename starts -with the @samp{/} character, and the script being processed was -located inside the @dfn{sysroot prefix}, the filename will be looked -for in the @dfn{sysroot prefix}. Otherwise, the linker will try to -open the file in the current directory. If it is not found, the -linker will search through the archive library search path. -The @dfn{sysroot prefix} can also be forced by specifying @code{=} -as the first character in the filename path. See also the -description of @samp{-L} in @ref{Options,,Command Line Options}. +In case a @dfn{sysroot prefix} is configured without explict +--disable-runtime-sysroot, and the filename starts with the @samp{/} +character, and the script being processed was located inside the +@dfn{sysroot prefix}, the filename will be looked for in the +@dfn{sysroot prefix}. Otherwise, the linker will try to open the file +in the current directory. If it is not found, the linker will search +through the archive library search path. The @dfn{sysroot prefix} can +also be forced by specifying @code{=} as the first character in the +filename path. See also the description of @samp{-L} in +@ref{Options,,Command Line Options}. If you use @samp{INPUT (-l@var{file})}, @command{ld} will transform the name to @code{lib@var{file}.a}, as with the command line argument diff --git a/ld/ldfile.c b/ld/ldfile.c index 782ed7f..f6bc3aa 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -461,7 +461,11 @@ try_open (const char *name, bfd_boolean *sysrooted) result = fopen (name, "r"); if (result != NULL) +#ifdef ENABLE_RUNTIME_SYSROOT *sysrooted = is_sysrooted_pathname (name); +#else + *sysrooted = 0; +#endif if (verbose) { -- 2.1.3
- Previous message (by thread): [PATCH] fine control sysroot runtime behavior
- Next message (by thread): [PATCH] Fine control sysroot runtime behavior.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list