public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [google] GRTE static link spec (issue4426065)
@ 2011-04-27 20:03 Ollie Wild
  2011-04-27 20:24 ` Diego Novillo
  0 siblings, 1 reply; 2+ messages in thread
From: Ollie Wild @ 2011-04-27 20:03 UTC (permalink / raw)
  To: reply, gcc-patches

commit 44417f1103b0823f950f539a38a5539b8ff74330
Author: Ollie Wild <aaw@google.com>
Date:   Mon Apr 25 21:55:44 2011 -0400

    When using GRTE (libc) and linking statically, instead of just -lc add:
    
          -lc -lnss_borg -lnss_cache -lnss_dns -lnss_files -lresolv
    
    to the link by modifying LIB_SPEC to redirect to several new specs
    which are GRTE-specific.
    
    To be applied to google/integration branch.
    

M	gcc/config.gcc
M	gcc/config/i386/linux.h
M	gcc/config/i386/linux64.h
A	gcc/config/linux-grtev2.h

Tested:
  Tested via buildit bootstrap and tests and by executing gcc with -v to
  validate supplied link options.

ChangeLog:
2011-04-27  Ollie Wild  <aaw@google.com>

	* config.gcc: Add GRTE detection.
	* config/i386/linux.h (LINUX_GRTE_EXTRA_SPECS): New macro.
	(SUBTARGET_EXTRA_SPECS): Add LINUX_GRTE_EXTRA_SPECS.
	* config/i386/linux64.h (LINUX_GRTE_EXTRA_SPECS): New macro.
	(SUBTARGET_EXTRA_SPECS): New macro with LINUX_GRTE_EXTRA_SPECS.
	* config/linux-grtev2.h: New file.

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 58f6787..dc7524f 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1286,6 +1286,9 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i
 	i[34567]86-*-gnu*) tm_file="$tm_file i386/linux.h gnu.h i386/gnu.h";;
 	esac
 	tmake_file="${tmake_file} i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules"
+	if [ "$with_sysroot" = "/usr/grte/v2" ]; then
+	  tm_file="${tm_file} linux-grtev2.h"
+	fi
 	;;
 x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu)
 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h \
@@ -1297,6 +1300,9 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu)
 	x86_64-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h" ;;
 	esac
 	tmake_file="${tmake_file} i386/t-linux64 i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules"
+	if [ "$with_sysroot" = "/usr/grte/v2" ]; then
+	  tm_file="${tm_file} linux-grtev2.h"
+	fi
 	;;
 i[34567]86-pc-msdosdjgpp*)
 	xm_file=i386/xm-djgpp.h
diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index 1d2a548..019cea9 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -101,8 +101,14 @@ along with GCC; see the file COPYING3.  If not see
 #define ASM_SPEC \
   "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
 
+/* These may be provided by config/linux-grtev2.h.  */
+#ifndef LINUX_GRTE_EXTRA_SPECS
+#define LINUX_GRTE_EXTRA_SPECS
+#endif
+
 #undef  SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
+  LINUX_GRTE_EXTRA_SPECS \
   { "link_emulation", LINK_EMULATION },\
   { "dynamic_linker", LINUX_DYNAMIC_LINKER }
 
diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index 118e795..429c273 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -90,6 +90,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
       %{" SPEC_64 ":-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}} \
     %{static:-static}}"
 
+/* These may be provided by config/linux-grtev2.h.  */
+#ifndef LINUX_GRTE_EXTRA_SPECS
+#define LINUX_GRTE_EXTRA_SPECS
+#endif
+
+#undef  SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS \
+  LINUX_GRTE_EXTRA_SPECS
+
 /* Similar to standard Linux, but adding -ffast-math support.  */
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
diff --git a/gcc/config/linux-grtev2.h b/gcc/config/linux-grtev2.h
new file mode 100644
index 0000000..29268fc
--- /dev/null
+++ b/gcc/config/linux-grtev2.h
@@ -0,0 +1,43 @@
+/* Definitions for Linux-based GRTE (Google RunTime Environment) version 2.
+   Copyright (C) 2009,2010,2011 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_SPEC from linux.h.  */
+#undef	LIB_SPEC
+#define LIB_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" },

--
This patch is available for review at http://codereview.appspot.com/4426065

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [google] GRTE static link spec (issue4426065)
  2011-04-27 20:03 [google] GRTE static link spec (issue4426065) Ollie Wild
@ 2011-04-27 20:24 ` Diego Novillo
  0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2011-04-27 20:24 UTC (permalink / raw)
  To: Ollie Wild; +Cc: reply, gcc-patches

On Wed, Apr 27, 2011 at 15:13, Ollie Wild <aaw@google.com> wrote:

> ChangeLog:
> 2011-04-27  Ollie Wild  <aaw@google.com>
>
>        * config.gcc: Add GRTE detection.
>        * config/i386/linux.h (LINUX_GRTE_EXTRA_SPECS): New macro.
>        (SUBTARGET_EXTRA_SPECS): Add LINUX_GRTE_EXTRA_SPECS.
>        * config/i386/linux64.h (LINUX_GRTE_EXTRA_SPECS): New macro.
>        (SUBTARGET_EXTRA_SPECS): New macro with LINUX_GRTE_EXTRA_SPECS.
>        * config/linux-grtev2.h: New file.

OK.


Diego.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-27 19:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 20:03 [google] GRTE static link spec (issue4426065) Ollie Wild
2011-04-27 20:24 ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).