Hi Diego, This is a backport of r184370 from integration branch. I have tested this by building it for different configurations of powerpc.
-Doug 2012-03-01 Doug Kwan <dougk...@google.com> Backport r184370 from integration branch. 2012-02-17 Doug Kwan <dougk...@google.com> * gcc/config.gcc (powerpc*-*-linux): Pull in GRTEv2 spec changes if target matches *-grtev2-*. * gcc/config/rs6000/linux64.h (GLIB_DYNAMIC_LINKER{32,64}): Add runtime root prefix to glibc's dynamic linker. * gcc/config/rs6000/linux-grtev2.h: New file. * gcc/config/rs6000/sysv4.h (GLIB_DYNAMIC_LINKER): Add runtime root prefix to glibc's dynamic linker. (LINUX_GRTE_EXTRA_SPECS): Define to be empty if no definition found. (SUBTARGET_EXTRA_SPECS): Include LINUX_GRTE_EXTRA_SPECS. Index: gcc/config.gcc =================================================================== --- gcc/config.gcc (revision 184683) +++ gcc/config.gcc (working copy) @@ -2198,6 +2198,12 @@ powerpc-*-linux* | powerpc64-*-linux*) if test x${enable_secureplt} = xyes; then tm_file="rs6000/secureplt.h ${tm_file}" fi + # Pull in spec changes for GRTEv2 configurations. + case ${target} in + *-grtev2-*) + tm_file="${tm_file} rs6000/linux-grtev2.h" + ;; + esac ;; powerpc64-*-gnu*) tm_file="${tm_file} elfos.h freebsd-spec.h gnu.h rs6000/sysv4.h rs6000/default64.h rs6000/linux64.h rs6000/gnu.h glibc-stdint.h" Index: gcc/config/rs6000/linux64.h =================================================================== --- gcc/config/rs6000/linux64.h (revision 184683) +++ gcc/config/rs6000/linux64.h (working copy) @@ -372,8 +372,8 @@ extern int dot_symbols; #undef LINK_OS_DEFAULT_SPEC #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" -#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1" -#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1" +#define GLIBC_DYNAMIC_LINKER32 RUNTIME_ROOT_PREFIX "/lib/ld.so.1" +#define GLIBC_DYNAMIC_LINKER64 RUNTIME_ROOT_PREFIX "/lib64/ld64.so.1" #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" #if DEFAULT_LIBC == LIBC_UCLIBC Index: gcc/config/rs6000/linux-grtev2.h =================================================================== --- gcc/config/rs6000/linux-grtev2.h (revision 0) +++ gcc/config/rs6000/linux-grtev2.h (revision 0) @@ -0,0 +1,43 @@ +/* Definitions for Linux-based GRTE (Google RunTime Environment) version 2. + Copyright (C) 2009,2010,2011,2012 Free Software Foundation, Inc. + Contributed by Chris Demetriou and Ollie Wild. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + +/* Overrides LIB_LINUX_SPEC from sysv4.h. */ +#undef LIB_LINUX_SPEC +#define LIB_LINUX_SPEC \ + "%{pthread:-lpthread} \ + %{shared:-lc} \ + %{!shared:%{mieee-fp:-lieee} %{profile:%(libc_p)}%{!profile:%(libc)}}" + +/* When GRTE links statically, it needs its NSS and resolver libraries + linked in as well. Note that when linking statically, these are + enclosed in a group by LINK_GCC_C_SEQUENCE_SPEC. */ +#undef LINUX_GRTE_EXTRA_SPECS +#define LINUX_GRTE_EXTRA_SPECS \ + { "libc", "%{static:%(libc_static);:-lc}" }, \ + { "libc_p", "%{static:%(libc_p_static);:-lc_p}" }, \ + { "libc_static", \ + "-lc -lnss_borg -lnss_cache -lnss_dns -lnss_files -lresolv" }, \ + { "libc_p_static", \ + "-lc_p -lnss_borg_p -lnss_cache_p -lnss_dns_p -lnss_files_p -lresolv_p" }, Index: gcc/config/rs6000/sysv4.h =================================================================== --- gcc/config/rs6000/sysv4.h (revision 184683) +++ gcc/config/rs6000/sysv4.h (working copy) @@ -818,7 +818,10 @@ extern int fixuplabelno; #define LINK_START_LINUX_SPEC "" -#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" +#ifndef RUNTIME_ROOT_PREFIX +#define RUNTIME_ROOT_PREFIX "" +#endif +#define GLIBC_DYNAMIC_LINKER RUNTIME_ROOT_PREFIX "/lib/ld.so.1" #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" #if DEFAULT_LIBC == LIBC_UCLIBC #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" @@ -921,6 +924,11 @@ ncrtn.o%s" #define CPP_OS_OPENBSD_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}" #endif +/* These may be provided by rs6000/linux-grtev2.h. */ +#ifndef LINUX_GRTE_EXTRA_SPECS +#define LINUX_GRTE_EXTRA_SPECS +#endif + /* Define any extra SPECS that the compiler needs to generate. */ /* Override rs6000.h definition. */ #undef SUBTARGET_EXTRA_SPECS @@ -995,6 +1003,7 @@ ncrtn.o%s" { "cpp_os_openbsd", CPP_OS_OPENBSD_SPEC }, \ { "cpp_os_default", CPP_OS_DEFAULT_SPEC }, \ { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }, \ + LINUX_GRTE_EXTRA_SPECS \ SUBSUBTARGET_EXTRA_SPECS #define SUBSUBTARGET_EXTRA_SPECS -- This patch is available for review at http://codereview.appspot.com/5716054