Thanks Andrew.  I will take a look at that.

-Doug

On Mon, Feb 13, 2012 at 6:45 PM, Andrew Pinski <pins...@gmail.com> wrote:
> On Mon, Feb 13, 2012 at 6:41 PM, Doug Kwan <dougk...@google.com> wrote:
>> Hi,
>>
>> This patch adds support for powerpc*-grtev2-linux-gnu.  The changes
>> include:
>>
>> 1. Relocating the dynamic linker using a run-time root prefix.
>> 2. Using different library setting in static linking.
>>
>> This is tested by building PowerPC64 and PowerPC toolchains and ran
>> some tests with the resulting toolchain.
>>
>> This is used by Google and is not meant to be sent to trunk.
>>
>> -Doug
>>
>> 2012-02-13   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 184150)
>> +++ gcc/config.gcc      (working copy)
>> @@ -2040,6 +2040,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
>>        ;;
>>  powerpc-wrs-vxworks|powerpc-wrs-vxworksae)
>>        tm_file="${tm_file} elfos.h freebsd-spec.h rs6000/sysv4.h"
>> Index: gcc/config/rs6000/linux64.h
>> ===================================================================
>> --- gcc/config/rs6000/linux64.h (revision 184150)
>> +++ gcc/config/rs6000/linux64.h (working copy)
>> @@ -367,8 +367,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" 
>> },
>
> Really can't you fix glibc so that libnss.a is not needed.
> See http://sourceware.org/bugzilla/show_bug.cgi?id=6528 for those fixes.
>
> Thanks,
> Andrew Pinski
>
>
>> Index: gcc/config/rs6000/sysv4.h
>> ===================================================================
>> --- gcc/config/rs6000/sysv4.h   (revision 184150)
>> +++ gcc/config/rs6000/sysv4.h   (working copy)
>> @@ -803,7 +803,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 "}"
>> @@ -881,6 +884,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
>> @@ -949,6 +957,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/5659050

Reply via email to