* 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.
This commit is contained in:
Ian Lance Taylor 2011-11-03 04:32:01 +00:00
parent a8e2273bba
commit 3f3cddf146
8 changed files with 90 additions and 16 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

25
gold/configure vendored
View file

@ -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

View file

@ -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

View file

@ -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())

View file

@ -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.