diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2dd4536d97a..304eda7b0c3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2006-11-13 Carlos O'Donell + Mark Mitchell + + * gcc.c: Organize search path variables into $prefix relative, + and well-known native. Add comments. + (add_sysrooted_prefix): Add comment. + (process_command): If !gcc_exec_prefix add $prefix based paths. + If *cross_compile == '0', add native well-known paths. + Assert tooldir_base_prefix is always relative. + (main): If print_search_dirs, and if gcc_exec_prefix is set, + use this value for 'install:' path. + * Makefile.in: Add GCC_EXEC_PREFIX to generated site.exp. + 2006-11-13 H.J. Lu * config/i386/i386.c: Fix a typo in comment. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 7e4c16a5e6a..8a499d15598 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -3986,6 +3986,7 @@ site.exp: ./config.status Makefile @echo "set HOSTCFLAGS \"$(CFLAGS)\"" >> ./tmp0 @echo "set TESTING_IN_BUILD_TREE 1" >> ./tmp0 @echo "set HAVE_LIBSTDCXX_V3 1" >> ./tmp0 + @echo "set GCC_EXEC_PREFIX \"$(libdir)/gcc/\"" >> ./tmp0 # If newlib has been configured, we need to pass -B to gcc so it can find # newlib's crt0.o if it exists. This will cause a "path prefix not used" # message if it doesn't, but the testsuite is supposed to ignore the message - diff --git a/gcc/gcc.c b/gcc/gcc.c index 6c017ec4251..76b6de66978 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1472,25 +1472,33 @@ static const char *gcc_libexec_prefix; #define MD_STARTFILE_PREFIX_1 "" #endif +/* These directories are locations set at configure-time based on the + --prefix option provided to configure. Their initializers are + defined in Makefile.in. These paths are not *directly* used when + gcc_exec_prefix is set because, in that case, we know where the + compiler has been installed, and use paths relative to that + location instead. */ static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX; +static const char *const standard_libexec_prefix = STANDARD_LIBEXEC_PREFIX; +static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX; +static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; + +/* For native compilers, these are well-known paths containing + components that may be provided by the system. For cross + compilers, these paths are not used. */ static const char *const standard_exec_prefix_1 = "/usr/libexec/gcc/"; static const char *const standard_exec_prefix_2 = "/usr/lib/gcc/"; static const char *md_exec_prefix = MD_EXEC_PREFIX; - static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; -static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; -static const char *const standard_startfile_prefix_1 +static const char *const standard_startfile_prefix_1 = STANDARD_STARTFILE_PREFIX_1; static const char *const standard_startfile_prefix_2 = STANDARD_STARTFILE_PREFIX_2; +/* A relative path to be used in finding the location of tools + relative to the driver. */ static const char *const tooldir_base_prefix = TOOLDIR_BASE_PREFIX; -static const char *tooldir_prefix; - -static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX; - -static const char *standard_libexec_prefix = STANDARD_LIBEXEC_PREFIX; /* Subdirectory to use for locating libraries. Set by set_multilib_dir based on the compilation options. */ @@ -2749,6 +2757,7 @@ add_prefix (struct path_prefix *pprefix, const char *prefix, } /* Same as add_prefix, but prepending target_system_root to prefix. */ +/* The target_system_root prefix has been relocated by gcc_exec_prefix. */ static void add_sysrooted_prefix (struct path_prefix *pprefix, const char *prefix, const char *component, @@ -3278,6 +3287,7 @@ process_command (int argc, const char **argv) int is_modify_target_name; unsigned int j; #endif + const char *tooldir_prefix; GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX"); @@ -3383,10 +3393,18 @@ process_command (int argc, const char **argv) gcc_libexec_prefix = make_relative_prefix (tmp_prefix, standard_exec_prefix, standard_libexec_prefix); + + /* The path is unrelocated, so fallback to the original setting. */ + if (!gcc_libexec_prefix) + gcc_libexec_prefix = standard_libexec_prefix; + free (tmp_prefix); } #else #endif + /* From this point onward, gcc_exec_prefix is non-null if the toolchain + is relocated. The toolchain was either relocated using GCC_EXEC_PREFIX + or an automatically created GCC_EXEC_PREFIX from argv[0]. */ if (gcc_exec_prefix) { @@ -3936,62 +3954,50 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" use_pipes = 0; } - /* Set up the search paths before we go looking for config files. */ + /* Set up the search paths. We add directories that we expect to + contain GNU Toolchain components before directories specified by + the machine description so that we will find GNU components (like + the GNU assembler) before those of the host system. */ - /* These come before the md prefixes so that we will find gcc's subcommands - (such as cpp) rather than those of the host system. */ - /* Use 2 as fourth arg meaning try just the machine as a suffix, - as well as trying the machine and the version. */ + /* If we don't know where the toolchain has been installed, use the + configured-in locations. */ + if (!gcc_exec_prefix) + { #ifndef OS2 - add_prefix (&exec_prefixes, standard_libexec_prefix, "GCC", - PREFIX_PRIORITY_LAST, 1, 0); - add_prefix (&exec_prefixes, standard_libexec_prefix, "BINUTILS", - PREFIX_PRIORITY_LAST, 2, 0); - add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS", - PREFIX_PRIORITY_LAST, 2, 0); - add_prefix (&exec_prefixes, standard_exec_prefix_1, "BINUTILS", - PREFIX_PRIORITY_LAST, 2, 0); - add_prefix (&exec_prefixes, standard_exec_prefix_2, "BINUTILS", - PREFIX_PRIORITY_LAST, 2, 0); + add_prefix (&exec_prefixes, standard_libexec_prefix, "GCC", + PREFIX_PRIORITY_LAST, 1, 0); + add_prefix (&exec_prefixes, standard_libexec_prefix, "BINUTILS", + PREFIX_PRIORITY_LAST, 2, 0); + add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS", + PREFIX_PRIORITY_LAST, 2, 0); #endif + add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS", + PREFIX_PRIORITY_LAST, 1, 0); + } - add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS", - PREFIX_PRIORITY_LAST, 1, 0); - add_prefix (&startfile_prefixes, standard_exec_prefix_2, "BINUTILS", - PREFIX_PRIORITY_LAST, 1, 0); + /* If not cross-compiling, search well-known system locations. */ + if (*cross_compile == '0') + { +#ifndef OS2 + add_prefix (&exec_prefixes, standard_exec_prefix_1, "BINUTILS", + PREFIX_PRIORITY_LAST, 2, 0); + add_prefix (&exec_prefixes, standard_exec_prefix_2, "BINUTILS", + PREFIX_PRIORITY_LAST, 2, 0); +#endif + add_prefix (&startfile_prefixes, standard_exec_prefix_2, "BINUTILS", + PREFIX_PRIORITY_LAST, 1, 0); + } + gcc_assert (!IS_ABSOLUTE_PATH (tooldir_base_prefix)); tooldir_prefix = concat (tooldir_base_prefix, spec_machine, dir_separator_str, NULL); - /* If tooldir is relative, base it on exec_prefixes. A relative - tooldir lets us move the installed tree as a unit. - - If GCC_EXEC_PREFIX is defined, then we want to add two relative - directories, so that we can search both the user specified directory - and the standard place. */ - - if (!IS_ABSOLUTE_PATH (tooldir_prefix)) - { - if (gcc_exec_prefix) - { - char *gcc_exec_tooldir_prefix - = concat (gcc_exec_prefix, spec_machine, dir_separator_str, - spec_version, dir_separator_str, tooldir_prefix, NULL); - - add_prefix (&exec_prefixes, - concat (gcc_exec_tooldir_prefix, "bin", - dir_separator_str, NULL), - NULL, PREFIX_PRIORITY_LAST, 0, 0); - add_prefix (&startfile_prefixes, - concat (gcc_exec_tooldir_prefix, "lib", - dir_separator_str, NULL), - NULL, PREFIX_PRIORITY_LAST, 0, 1); - } - - tooldir_prefix = concat (standard_exec_prefix, spec_machine, - dir_separator_str, spec_version, - dir_separator_str, tooldir_prefix, NULL); - } + /* Look for tools relative to the location from which the driver is + running, or, if that is not available, the configured prefix. */ + tooldir_prefix + = concat (gcc_exec_prefix ? gcc_exec_prefix : standard_exec_prefix, + spec_machine, dir_separator_str, + spec_version, dir_separator_str, tooldir_prefix, NULL); add_prefix (&exec_prefixes, concat (tooldir_prefix, "bin", dir_separator_str, NULL), @@ -6314,18 +6320,16 @@ main (int argc, char **argv) PREFIX_PRIORITY_LAST, 0, 1); else if (*cross_compile == '0') { - if (gcc_exec_prefix) - add_prefix (&startfile_prefixes, - concat (gcc_exec_prefix, machine_suffix, - standard_startfile_prefix, NULL), - NULL, PREFIX_PRIORITY_LAST, 0, 1); add_prefix (&startfile_prefixes, - concat (standard_exec_prefix, - machine_suffix, + concat (gcc_exec_prefix + ? gcc_exec_prefix : standard_exec_prefix, + machine_suffix, standard_startfile_prefix, NULL), NULL, PREFIX_PRIORITY_LAST, 0, 1); } + /* Sysrooted prefixes are relocated because target_system_root is + also relocated by gcc_exec_prefix. */ if (*standard_startfile_prefix_1) add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_1, "BINUTILS", @@ -6369,7 +6373,9 @@ main (int argc, char **argv) if (print_search_dirs) { - printf (_("install: %s%s\n"), standard_exec_prefix, machine_suffix); + printf (_("install: %s%s\n"), + gcc_exec_prefix ? gcc_exec_prefix : standard_exec_prefix, + gcc_exec_prefix ? "" : machine_suffix); printf (_("programs: %s\n"), build_search_list (&exec_prefixes, "", false, false)); printf (_("libraries: %s\n"), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9eba88e4825..b0dc1fe4d08 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-11-13 Carlos O'Donell + + * lib/c-torture.exp: Use target-libpath.exp. + * lib/target-libpath.exp (set_ld_library_path_env_vars): If present, + set GCC_EXEC_PREFIX env var from global variable of same name. + 2006-11-12 Andrew Pinski PR fortran/26994 diff --git a/gcc/testsuite/lib/c-torture.exp b/gcc/testsuite/lib/c-torture.exp index c9138d66068..185775d2249 100644 --- a/gcc/testsuite/lib/c-torture.exp +++ b/gcc/testsuite/lib/c-torture.exp @@ -17,6 +17,7 @@ # This file was written by Rob Savoye. (rob@cygnus.com) load_lib file-format.exp +load_lib target-libpath.exp # The default option list can be overridden by # TORTURE_OPTIONS="{ { list1 } ... { listN } }" @@ -40,6 +41,19 @@ if ![info exists TORTURE_OPTIONS] { { -Os } ] } +global GCC_UNDER_TEST +if ![info exists GCC_UNDER_TEST] { + set GCC_UNDER_TEST "[find_gcc]" +} + +global orig_environment_saved + +# This file may be sourced, so don't override environment settings +# that have been previously setup. +if { $orig_environment_saved == 0 } { + append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] + set_ld_library_path_env_vars +} # Split TORTURE_OPTIONS into two choices: one for testcases with loops and # one for testcases without loops. diff --git a/gcc/testsuite/lib/target-libpath.exp b/gcc/testsuite/lib/target-libpath.exp index 8aca0edf43e..8135b3f4c96 100644 --- a/gcc/testsuite/lib/target-libpath.exp +++ b/gcc/testsuite/lib/target-libpath.exp @@ -50,6 +50,12 @@ proc set_ld_library_path_env_vars { } { global orig_ld_library_path_32 global orig_ld_library_path_64 global orig_dyld_library_path + global GCC_EXEC_PREFIX + + # Set the relocated compiler prefix, but only if the user hasn't specified one. + if { [info exists GCC_EXEC_PREFIX] && ![info exists env(GCC_EXEC_PREFIX)] } { + setenv GCC_EXEC_PREFIX "$GCC_EXEC_PREFIX" + } # Setting the ld library path causes trouble when testing cross-compilers. if { [is_remote target] } {