* [PATCH] gold --with-lib-path
[not found] <CAO2+NUB+gwOcWcS1-4yLfwgdG1x-AjkO5-kOSOyHQVaeN2FErw@mail.gmail.com>
@ 2011-07-17 8:30 ` Леонид Юрьев
2011-11-03 4:32 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Леонид Юрьев @ 2011-07-17 8:30 UTC (permalink / raw)
To: binutils
Hi,
There a lot of troubles while using gold in real life without the
built-in libs search path...
This is a simplest-way patch for ones.
diff --git a/gold/Makefile.am b/gold/Makefile.am
index df5e66c..4d3a4d5 100644
--- a/gold/Makefile.am
+++ b/gold/Makefile.am
@@ -15,6 +15,7 @@ AM_CPPFLAGS = \
-I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \
-DLOCALEDIR="\"$(datadir)/locale\"" \
-DBINDIR="\"$(bindir)\"" -DTOOLBINDIR="\"$(tooldir)/bin\"" \
+ -DLIB_PATH="\"$(lib_path)\"" \
@INCINTL@
LIBIBERTY = ../libiberty/libiberty.a
diff --git a/gold/Makefile.in b/gold/Makefile.in
index bf729cf..f1babed 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -331,6 +331,7 @@ infodir = @infodir@
install_as_default = @install_as_default@
install_sh = @install_sh@
installed_linker = @installed_linker@
+lib_path = @lib_path@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
@@ -364,6 +365,7 @@ AM_CPPFLAGS = \
-I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \
-DLOCALEDIR="\"$(datadir)/locale\"" \
-DBINDIR="\"$(bindir)\"" -DTOOLBINDIR="\"$(tooldir)/bin\"" \
+ -DLIB_PATH="\"$(lib_path)\"" \
@INCINTL@
LIBIBERTY = ../libiberty/libiberty.a
diff --git a/gold/configure b/gold/configure
index b882223..bb8fb86 100755
--- a/gold/configure
+++ b/gold/configure
@@ -627,6 +627,7 @@ GCC_FALSE
GCC_TRUE
NATIVE_LINKER_FALSE
NATIVE_LINKER_TRUE
+lib_path
MSGMERGE
MSGFMT
MKINSTALLDIRS
@@ -764,6 +765,7 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
+with_lib_path
with_sysroot
enable_ld
enable_gold
@@ -1427,6 +1429,7 @@ Optional Features:
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-lib-path=dir1:dir2... set default path for libs search
--with-sysroot=DIR search for usr/lib et al within DIR
Some influential environment variables:
@@ -3212,6 +3215,15 @@ ac_config_headers="$ac_config_headers config.h:config.in"
+# Check whether --with-lib-path was given.
+if test "${with_lib_path+set}" = set; then :
+ withval=$with_lib_path; lib_path=$withval
+else
+ lib_path=/lib:/usr/lib
+fi
+
+
+
# Check whether --with-sysroot was given.
if test "${with_sysroot+set}" = set; then :
withval=$with_sysroot; sysroot=$withval
@@ -6080,6 +6092,8 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
+
+
if test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias"; then
NATIVE_LINKER_TRUE=
NATIVE_LINKER_FALSE='#'
diff --git a/gold/configure.ac b/gold/configure.ac
index 949c8c3..bd9aa86 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -11,6 +11,10 @@ AM_INIT_AUTOMAKE([no-dist parallel-tests])
AM_CONFIG_HEADER(config.h:config.in)
+AC_ARG_WITH(lib-path,
+[ --with-lib-path=dir1:dir2... set default path for libs search],
+[lib_path=$withval], [lib_path=/lib:/usr/lib])
+
AC_ARG_WITH(sysroot,
[ --with-sysroot[=DIR] search for usr/lib et al within DIR],
[sysroot=$withval], [sysroot=no])
@@ -254,6 +258,8 @@ AC_C_BIGENDIAN
AC_EXEEXT
+AC_SUBST(lib_path)
+
AM_CONDITIONAL(NATIVE_LINKER,
test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias")
AM_CONDITIONAL(GCC, test "$GCC" = yes)
diff --git a/gold/options.cc b/gold/options.cc
index be32645..2e75870 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -1145,8 +1145,18 @@ General_options::finalize()
{
// Even if they don't specify it, we add -L /lib and -L /usr/lib.
// FIXME: We should only do this when configured in native mode.
+#ifdef LIB_PATH
+ const char* p = LIB_PATH;
+ while (*p != '\0')
+ {
+ size_t length = strcspn(p, ",:");
+ this->add_to_library_path_with_sysroot(std::string(p,
length).c_str());
+ p += (p[length] ? length + 1 : length);
+ }
+#else
this->add_to_library_path_with_sysroot("/lib");
this->add_to_library_path_with_sysroot("/usr/lib");
+#endif
}
// Parse the contents of -retain-symbols-file into a set.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gold --with-lib-path
2011-07-17 8:30 ` [PATCH] gold --with-lib-path Леонид Юрьев
@ 2011-11-03 4:32 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2011-11-03 4:32 UTC (permalink / raw)
To: Леонид
Юрьев
Cc: binutils
[-- Attachment #1: Type: text/plain, Size: 983 bytes --]
Леонид Юрьев <leo@yuriev.ru> writes:
> There a lot of troubles while using gold in real life without the
> built-in libs search path...
> This is a simplest-way patch for ones.
Thanks. I just committed a different patch which implements
--with-lib-path. This patch also fixes up the search path used by a
cross-linker when there is no sysroot. Committed to mainline.
Ian
2011-11-02 Ian Lance Taylor <iant@google.com>
* configure.ac: Add --with-lib-path option. Define LIB_PATH and
NATIVE_LINKER.
* Makefile.am (AM_CPPFLAGS): Define TOOLLIBDIR.
* options.cc (General_options::finalize): Use library search path
from configure script if specified. If not native and no sysroot,
only search TOOLLIBDIR.
* options.h (Search_directory::Search_directory): Change name to
const std::string&.
(General_options::add_to_library_path_with_sysroot): Change arg to
const std::string&.
* configure, Makefile.in, config.in: Rebuild.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4460 bytes --]
Index: Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/Makefile.am,v
retrieving revision 1.63
diff -u -p -r1.63 Makefile.am
--- Makefile.am 23 Sep 2011 15:02:32 -0000 1.63
+++ Makefile.am 3 Nov 2011 04:29:29 -0000
@@ -15,7 +15,7 @@ AM_CPPFLAGS = \
-I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \
-DLOCALEDIR="\"$(datadir)/locale\"" \
-DBINDIR="\"$(bindir)\"" -DTOOLBINDIR="\"$(tooldir)/bin\"" \
- @INCINTL@
+ -DTOOLLIBDIR="\"$(tooldir)/lib\"" @INCINTL@
LIBIBERTY = ../libiberty/libiberty.a
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gold/configure.ac,v
retrieving revision 1.67
diff -u -p -r1.67 configure.ac
--- configure.ac 23 Sep 2011 15:02:32 -0000 1.67
+++ configure.ac 3 Nov 2011 04:29:30 -0000
@@ -238,6 +238,20 @@ AC_DEFINE_UNQUOTED(GOLD_DEFAULT_BIG_ENDI
AC_DEFINE_UNQUOTED(GOLD_DEFAULT_OSABI, $default_osabi,
[Default OSABI code])
+AC_ARG_WITH(lib-path,
+[ --with-lib-path=dir1:dir2... set default LIB_PATH],
+[case "$withval" in
+ yes) LIB_PATH='"/lib:/usr/lib"' ;;
+ no) LIB_PATH='""' ;;
+ *) LIB_PATH='"'"$withval"'"' ;;
+ esac],
+[LIB_PATH='"::DEFAULT::"'])
+AC_DEFINE_UNQUOTED(LIB_PATH, $LIB_PATH,
+ [Default library search path])
+if test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias"; then
+ AC_DEFINE(NATIVE_LINKER, 1, [Whether configured as a native linker])
+fi
+
AC_CHECK_TOOL(NM, nm)
AC_PROG_CC
Index: options.cc
===================================================================
RCS file: /cvs/src/src/gold/options.cc,v
retrieving revision 1.116
diff -u -p -r1.116 options.cc
--- options.cc 3 Oct 2011 17:01:43 -0000 1.116
+++ options.cc 3 Nov 2011 04:29:31 -0000
@@ -1121,33 +1121,48 @@ General_options::finalize()
program_name);
#endif
+ std::string libpath;
if (this->user_set_Y())
{
- std::string s = this->Y();
- if (s.compare(0, 2, "P,") == 0)
- s.erase(0, 2);
+ libpath = this->Y();
+ if (libpath.compare(0, 2, "P,") == 0)
+ libpath.erase(0, 2);
+ }
+ else if (!this->nostdlib())
+ {
+#ifndef NATIVE_LINKER
+#define NATIVE_LINKER 0
+#endif
+ const char* p = LIB_PATH;
+ if (strcmp(p, "::DEFAULT::") != 0)
+ libpath = p;
+ else if (NATIVE_LINKER
+ || this->user_set_sysroot()
+ || *TARGET_SYSTEM_ROOT != '\0')
+ {
+ this->add_to_library_path_with_sysroot("/lib");
+ this->add_to_library_path_with_sysroot("/usr/lib");
+ }
+ else
+ this->add_to_library_path_with_sysroot(TOOLLIBDIR);
+ }
+ if (!libpath.empty())
+ {
size_t pos = 0;
size_t next_pos;
do
{
- next_pos = s.find(':', pos);
+ next_pos = libpath.find(':', pos);
size_t len = (next_pos == std::string::npos
? next_pos
: next_pos - pos);
if (len != 0)
- this->add_to_library_path_with_sysroot(s.substr(pos, len).c_str());
+ this->add_to_library_path_with_sysroot(libpath.substr(pos, len));
pos = next_pos + 1;
}
while (next_pos != std::string::npos);
}
- else if (!this->nostdlib())
- {
- // Even if they don't specify it, we add -L /lib and -L /usr/lib.
- // FIXME: We should only do this when configured in native mode.
- this->add_to_library_path_with_sysroot("/lib");
- this->add_to_library_path_with_sysroot("/usr/lib");
- }
// Parse the contents of -retain-symbols-file into a set.
if (this->retain_symbols_file())
Index: options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.172
diff -u -p -r1.172 options.h
--- options.h 3 Nov 2011 03:38:34 -0000 1.172
+++ options.h 3 Nov 2011 04:29:31 -0000
@@ -543,7 +543,7 @@ class Search_directory
{ }
// This is the usual constructor.
- Search_directory(const char* name, bool put_in_sysroot)
+ Search_directory(const std::string& name, bool put_in_sysroot)
: name_(name), put_in_sysroot_(put_in_sysroot), is_in_sysroot_(false)
{
if (this->name_.empty())
@@ -1463,7 +1463,7 @@ class General_options
// These are called by finalize() to set up the search-path correctly.
void
- add_to_library_path_with_sysroot(const char* arg)
+ add_to_library_path_with_sysroot(const std::string& arg)
{ this->add_search_directory_to_library_path(Search_directory(arg, true)); }
// Apply any sysroot to the directory lists.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-03 4:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAO2+NUB+gwOcWcS1-4yLfwgdG1x-AjkO5-kOSOyHQVaeN2FErw@mail.gmail.com>
2011-07-17 8:30 ` [PATCH] gold --with-lib-path Леонид Юрьев
2011-11-03 4:32 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).