aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2011-11-03 04:32:01 +0000
committerIan Lance Taylor <ian@airs.com>2011-11-03 04:32:01 +0000
commit3f3cddf146bb20f8222ce6ed8c8ffc6ee9c59124 (patch)
treeca8130f91064ed5ffc266840f2633256acae10e9 /gold
parenta8e2273bba9b658132165d70edb8b47023193e82 (diff)
downloadgdb-3f3cddf146bb20f8222ce6ed8c8ffc6ee9c59124.zip
gdb-3f3cddf146bb20f8222ce6ed8c8ffc6ee9c59124.tar.gz
gdb-3f3cddf146bb20f8222ce6ed8c8ffc6ee9c59124.tar.bz2
* 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.
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog14
-rw-r--r--gold/Makefile.am2
-rw-r--r--gold/Makefile.in2
-rw-r--r--gold/config.in6
-rwxr-xr-xgold/configure25
-rw-r--r--gold/configure.ac14
-rw-r--r--gold/options.cc39
-rw-r--r--gold/options.h4
8 files changed, 90 insertions, 16 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index eb87996..aac3aa0 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,17 @@
+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.
+
2011-11-02 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
* arm.cc (Target_arm::may_use_v5t_interworking): Check whether
diff --git a/gold/Makefile.am b/gold/Makefile.am
index c1c3588..d121ac4 100644
--- a/gold/Makefile.am
+++ b/gold/Makefile.am
@@ -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
diff --git a/gold/Makefile.in b/gold/Makefile.in
index ff6d7c2..0fa739a 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -369,7 +369,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
@PLUGINS_TRUE@LIBDL = -ldl
diff --git a/gold/config.in b/gold/config.in
index 8611376..2854620 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -165,6 +165,12 @@
/* Define to 1 if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
+/* Default library search path */
+#undef LIB_PATH
+
+/* Whether configured as a native linker */
+#undef NATIVE_LINKER
+
/* Name of package */
#undef PACKAGE
diff --git a/gold/configure b/gold/configure
index 708f540..3dddec6 100755
--- a/gold/configure
+++ b/gold/configure
@@ -775,6 +775,7 @@ enable_gold
enable_threads
enable_plugins
enable_targets
+with_lib_path
enable_dependency_tracking
enable_nls
enable_werror
@@ -1435,6 +1436,7 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-sysroot=DIR search for usr/lib et al within DIR
+ --with-lib-path=dir1:dir2... set default LIB_PATH
--with-gold-ldflags=FLAGS additional link flags for gold
--with-gold-ldadd=LIBS additional libraries for gold
@@ -3535,6 +3537,29 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
+
+# Check whether --with-lib-path was given.
+if test "${with_lib_path+set}" = set; then :
+ withval=$with_lib_path; case "$withval" in
+ yes) LIB_PATH='"/lib:/usr/lib"' ;;
+ no) LIB_PATH='""' ;;
+ *) LIB_PATH='"'"$withval"'"' ;;
+ esac
+else
+ LIB_PATH='"::DEFAULT::"'
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define LIB_PATH $LIB_PATH
+_ACEOF
+
+if test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias"; then
+
+$as_echo "#define NATIVE_LINKER 1" >>confdefs.h
+
+fi
+
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args.
set dummy ${ac_tool_prefix}nm; ac_word=$2
diff --git a/gold/configure.ac b/gold/configure.ac
index 905dbaf..1b46f4a 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -238,6 +238,20 @@ AC_DEFINE_UNQUOTED(GOLD_DEFAULT_BIG_ENDIAN, $default_big_endian,
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
diff --git a/gold/options.cc b/gold/options.cc
index dcf6ba7..64a8539 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -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())
diff --git a/gold/options.h b/gold/options.h
index 8876a1e..534df26 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -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.