3.2 PATCH: Major Solaris 2 configuration cleanup (take 2)

Rainer Orth ro@TechFak.Uni-Bielefeld.DE
Wed Jun 19 06:19:00 GMT 2002


This patch

	http://gcc.gnu.org/ml/gcc-patches/2002-05/msg02143.html

hasn't been reviewed for a couple of weeks despite several reminders.
Since it doesn't apply cleanly to current mainline anymore, I've taken the
time to update it and use TARGET_OS_CPP_BUILTINS as Neil requested.

The comments about the original patch still apply.

Bootstrapped without regressions (without Ada, which doesn't currently
bootstrap on any Solaris 2 version) on sparc-sun-solaris2.8 and
i386-pc-solaris2.8.

Ok for mainline now?

	Rainer


Mon May 27 15:45:50 2002  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* config/sol2.h: New file.
	* config.gcc (i?86-*-solaris2*): Include it before i386/sol2.h.
	(sparc64-wrs-vxworks*): Include it before sparc/sol2.h.
	(sparc-*-chorusos*): Likewise.
	(sparc-*-elf*): Likewise.
	(sparc-*-rtems*, sparc-*-rtemself*): Likewise.
	(sparc64-*-solaris2*, sparcv9-*-solaris2*): Likewise.
	(sparc-hal-solaris2*): Likewise.
	(sparc-*-solaris2*): Likewise.
	(sparclite-*-elf*): Likewise.
	(sparc86x-*-elf*): Likewise.
	(sparc64-*-elf*): Likewise.
	
	* config/i386/sol2.h (PREFERRED_DEBUGGING_TYPE): Moved to
	config/sol2.h.
	(ASM_SPEC): Override config/sol2.h version for now.
	Removed obsolete GAS_REJECTS_MINUS_S variant.
	(WINT_TYPE, WINT_TYPE_SIZE): Moved to config/sol2.h.
	(HANDLE_PRAGMA_REDEFINE_EXTNAME): Likewise.
	(TARGET_OS_CPP_BUILTINS): Likewise.
	Assert system=unix.
	(CPP_SPEC): Simplified using new CPP_SUBTARGET_SPEC.
	(LIB_SPEC, ENDFILE_SPEC, STARTFILE_SPEC, LINK_SPEC): Moved to
	config/sol2.h.
	(SWITCH_TAKES_ARG, STDC_0_IN_SYSTEM_HEADERS): Likewise.
	(ASM_CPU_SPEC): Define.
	(SUBTARGET_EXTRA_SPECS): Define.
	
	* config/sparc/sol2-bi.h (LONG_DOUBLE_TYPE_SIZE): Removed, already
	in config/sparc/sol2.h.
	(ASM_SPEC): Moved to config/sol2.h.
	(CPP_CPU_SPEC): Simplified.
	(STARTFILE_SPEC32): Likewise, renamed to STARTFILE_ARCH32_SPEC for
	consistency.
	(STARTFILE_SPEC64): Renamed to STARTFILE_ARCH64_SPEC.
	(STARTFILE_ARCH_SPEC): Use new names STARTFILE_ARCH32_SPEC,
	STARTFILE_ARCH64_SPEC.
	(STARTFILE_SPEC): Moved to config/sol2.h
	(SUBTARGET_EXTRA_SPECS): Add startfile_arch.
	(LINK_ARCH32_SPEC): Moved to config/sol2.h.
	(LINK_ARCH64_SPEC): Simplified.
	(LINK_ARCH_SPEC): Redefined config/sol2.h version for 64-bit support.
	(LINK_SPEC): Moved to config/sol2.h
	
	* config/sparc/sol2.h (WCHAR_TYPE, WCHAR_TYPE_SIZE): Moved to
	config/sol2.h.
	(WINT_TYPE, WINT_TYPE_SIZE): Likewise.
	(HANDLE_PRAGMA_REDEFINE_EXTNAME): Likewise.
	(CPP_PREDEFINES): Removed OS-specific part handled by
	TARGET_OS_CPP_BUILTINS.
	(CPP_SUBTARGET_SPEC): Moved to config/sol2.h.
	(CPLUSPLUS_CPP_SPEC): Removed, handled by TARGET_OS_CPP_BUILTINS.
	(ASM_SPEC): Moved to config/sol2.h.
	(PREFERRED_DEBUGGING_TYPE): Likewise.
	(STARTFILE_SPEC, LIB_SPEC, LINK_SPEC): Likewise.
	(SWITCH_TAKES_ARG, STDC_0_IN_SYSTEM_HEADERS): Likewise.
	(TARGET_DEFAULT): Reordered to match config/sparc/sol2-bi.h version.
	(TRANSFER_FROM_TRAMPOLINE): Moved to config/sol2.h
	
	* config.gcc (i?86-*-solaris2*): Removed obsolete gas support.
	* config/i386/sol2gas.h: Removed.

Index: gcc/config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.215
diff -u -p -r1.215 config.gcc
--- gcc/config.gcc	16 Jun 2002 21:12:27 -0000	1.215
+++ gcc/config.gcc	18 Jun 2002 22:42:03 -0000
@@ -1190,10 +1190,7 @@ i[34567]86-*-sco3.2v5*)	# 80386 running 
 	;;
 i[34567]86-*-solaris2*)
 	xm_defines="POSIX SMALL_ARG_MAX"
-	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h i386/sysv4.h i386/sol2.h"
-	if test x$gas = xyes; then
-		tm_file="i386/sol2gas.h ${tm_file}"
-	fi
+	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h i386/sysv4.h sol2.h i386/sol2.h"
 	tmake_file="i386/t-sol2 t-svr4"
 	if test x$gnu_ld = xyes; then
 		tmake_file="$tmake_file t-slibgcc-elf-ver"
@@ -2313,7 +2334,7 @@ sparc-tti-*)
 	xm_defines=POSIX
 	;;
 sparc64-wrs-vxworks*)
-        tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h sparc/elf.h sparc/biarch64.h gofast.h sparc/vxsparc64.h"
+        tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h sparc/elf.h sparc/biarch64.h gofast.h sparc/vxsparc64.h"
         tmake_file="sparc/t-vxsparc64 sparc/t-crtfm"
         use_collect2=yes
         ;;
@@ -2353,7 +2374,7 @@ sparc-*-bsd*)
 	tm_file="${tm_file} sparc/bsd.h"
 	;;
 sparc-*-chorusos*)
-	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h sparc/elf.h chorus.h"
+	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h sparc/elf.h chorus.h"
 	tmake_file="sparc/t-chorus-elf sparc/t-crtfm"
 	extra_parts="crti.o crtn.o crtbegin.o crtend.o"
 	float_format=i64
@@ -2364,7 +2385,7 @@ sparc-*-chorusos*)
 	esac
 	;;
 sparc-*-elf*)
-	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h sparc/elf.h"
+	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h sparc/elf.h"
 	tmake_file="sparc/t-elf sparc/t-crtfm"
 	extra_parts="crti.o crtn.o crtbegin.o crtend.o"
 	#float_format=i128
@@ -2406,7 +2427,7 @@ sparc-*-rtemsaout*)	# would otherwise be
 	;;
 sparc-*-rtems*)
 	xm_defines=POSIX
-	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h sparc/elf.h sparc/rtemself.h rtems.h"
+	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h sparc/elf.h sparc/rtemself.h rtems.h"
 	tmake_file="sparc/t-elf sparc/t-crtfm t-rtems"
 	extra_parts="crti.o crtn.o crtbegin.o crtend.o"
 	#float_format=i128
@@ -2416,7 +2437,7 @@ sparc-*-rtems*)
 	fi
 	;;
 sparc64-*-solaris2* | sparcv9-*-solaris2*)
-	tm_file="sparc/biarch64.h ${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h sparc/sol2-64.h sparc/sol2-bi.h"
+	tm_file="sparc/biarch64.h ${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h sparc/sol2-64.h sparc/sol2-bi.h"
 	if test x$gnu_ld = xyes; then
 		tm_file="${tm_file} sparc/sol2-gld.h sparc/sol2-gld-bi.h"
 	fi
@@ -2448,7 +2469,7 @@ sparc64-*-solaris2* | sparcv9-*-solaris2
 	;;
 sparc-hal-solaris2*)
         xm_defines=POSIX
-        tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h sparc/hal.h"
+        tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h sparc/hal.h"
         tmake_file="sparc/t-halos sparc/t-sol2 sparc/t-crtfm"
 	if test x$gnu_ld = xyes; then
 		tm_file="${tm_file} sparc/sol2-gld.h"
@@ -2461,7 +2482,7 @@ sparc-hal-solaris2*)
 	thread_file='solaris'
         ;;
 sparc-*-solaris2*)
-	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h"
+	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h"
 	if test x$gnu_ld = xyes; then
 		tm_file="${tm_file} sparc/sol2-gld.h"
 	fi
@@ -2545,7 +2566,7 @@ sparclite-*-aout*)
 	tmake_file=sparc/t-sparclite
 	;;
 sparclite-*-elf*)
-	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h sparc/elf.h gofast.h sparc/liteelf.h"
+	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h sparc/elf.h gofast.h sparc/liteelf.h"
 	tmake_file="sparc/t-sparclite sparc/t-crtfm"
         extra_parts="crtbegin.o crtend.o"
 	;;
@@ -2554,7 +2575,7 @@ sparc86x-*-aout*)
 	tmake_file=sparc/t-sp86x
 	;;
 sparc86x-*-elf*)
-	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h sparc/elf.h gofast.h sparc/sp86x-elf.h"
+	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h sparc/elf.h gofast.h sparc/sp86x-elf.h"
 	tmake_file="sparc/t-sp86x sparc/t-crtfm"
         extra_parts="crtbegin.o crtend.o"
 	;;
@@ -2562,7 +2583,7 @@ sparc64-*-aout*)
 	tm_file="sparc/sparc.h aoutos.h sparc/aout.h sparc/sp64-aout.h"
 	;;
 sparc64-*-elf*)
-	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sol2.h sparc/sp64-elf.h"
+	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sol2.h sparc/sol2.h sparc/sp64-elf.h"
 	tmake_file="${tmake_file} sparc/t-crtfm"
 	extra_parts="crtbegin.o crtend.o"
 	;;
Index: gcc/config/sol2.h
===================================================================
RCS file: gcc/config/sol2.h
diff -N gcc/config/sol2.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/config/sol2.h	18 Jun 2002 22:42:24 -0000
@@ -0,0 +1,207 @@
+/* Operating system specific defines to be used when targeting GCC for any
+   Solaris 2 system.
+   Copyright 2002 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC 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 2, or (at your option)
+any later version.
+
+GNU CC 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.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* We use stabs-in-elf for debugging, because that is what the native
+   toolchain uses.  */
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+
+/* Solaris 2 (at least as of 2.5.1) uses a 32-bit wchar_t.  */
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "long int"
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+/* Solaris 2 uses a wint_t different from the default. This is required
+   by the SCD 2.4.1, p. 6-83, Figure 6-66.  */
+#undef	WINT_TYPE
+#define	WINT_TYPE "long int"
+
+#undef	WINT_TYPE_SIZE
+#define	WINT_TYPE_SIZE 32
+
+#define HANDLE_PRAGMA_REDEFINE_EXTNAME 1
+
+/* ??? Note: in order for -compat-bsd to work fully,
+   we must somehow arrange to fixincludes /usr/ucbinclude
+   and put the result in $(libsubdir)/ucbinclude.  */
+
+#undef CPP_SUBTARGET_SPEC
+#define CPP_SUBTARGET_SPEC "\
+%{pthreads:-D_REENTRANT -D_PTHREADS} \
+%{!pthreads:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}} \
+%{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
+"
+
+/* Names to predefine in the preprocessor for this target machine.  */
+#define TARGET_OS_CPP_BUILTINS()			\
+    do {						\
+	builtin_define_std ("unix");			\
+	builtin_define_std ("sun");			\
+	builtin_define ("__svr4__");			\
+	builtin_define ("__SVR4");			\
+	builtin_define ("__PRAGMA_REDEFINE_EXTNAME");	\
+	builtin_assert ("system=unix");			\
+	builtin_assert ("system=svr4");			\
+	/* For C++ we need to add some additional macro \
+	   definitions required by the C++ standard	\
+	   library.  */					\
+	if (c_language == clk_cplusplus)		\
+	  {						\
+	    builtin_define ("_XOPEN_SOURCE=500");	\
+	    builtin_define ("_LARGEFILE_SOURCE=1");	\
+	    builtin_define ("_LARGEFILE64_SOURCE=1");	\
+	    builtin_define ("__EXTENSIONS__");		\
+	  }						\
+    } while (0)
+
+/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
+   It's safe to pass -s always, even if -g is not used.  */
+#undef ASM_SPEC
+#define ASM_SPEC "\
+%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
+%{fpic:-K PIC} %{fPIC:-K PIC} \
+%(asm_cpu) \
+"
+
+/* We don't use the standard LIB_SPEC only because we don't yet support c++.  */
+#undef LIB_SPEC
+#define LIB_SPEC \
+  "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
+   %{!shared:\
+     %{!symbolic:\
+       %{pthreads:-lpthread} \
+       %{!pthreads:%{threads:-lthread}} \
+       %{p|pg:-ldl} -lc}}"
+
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
+
+/* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us.  */
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "%{!shared: \
+			 %{!symbolic: \
+			  %{p:mcrt1.o%s} \
+                          %{!p: \
+	                    %{pg:gcrt1.o%s gmon.o%s} \
+                            %{!pg:crt1.o%s}}}} \
+			crti.o%s %(startfile_arch) \
+			crtbegin.o%s"
+
+#undef STARTFILE_ARCH32_SPEC
+#define STARTFILE_ARCH32_SPEC "%{ansi:values-Xc.o%s} \
+			    %{!ansi:values-Xa.o%s}"
+
+#undef STARTFILE_ARCH_SPEC
+#define STARTFILE_ARCH_SPEC STARTFILE_ARCH32_SPEC
+
+#undef LINK_ARCH32_SPEC
+#define LINK_ARCH32_SPEC \
+  "%{G:-G} \
+   %{YP,*} \
+   %{R*} \
+   %{compat-bsd: \
+     %{!YP,*:%{p|pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
+             %{!p:%{!pg:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
+             -R /usr/ucblib} \
+   %{!compat-bsd: \
+     %{!YP,*:%{p|pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
+             %{!p:%{!pg:-Y P,/usr/ccs/lib:/usr/lib}}}}"
+
+#undef LINK_ARCH_SPEC
+#define LINK_ARCH_SPEC LINK_ARCH32_SPEC
+
+/* This should be the same as in svr4.h, except with -R added.  */
+#undef  LINK_SPEC
+#define LINK_SPEC \
+  "%{h*} %{v:-V} \
+   %{b} %{Wl,*:%*} \
+   %{static:-dn -Bstatic} \
+   %{shared:-G -dy %{!mimpure-text:-z text}} \
+   %{symbolic:-Bsymbolic -G -dy -z text} \
+   %(link_arch) \
+   %{Qy:} %{!Qn:-Qy}"
+
+/* This defines which switch letters take arguments.
+   It is as in svr4.h but with -R added.  */
+#undef SWITCH_TAKES_ARG
+#define SWITCH_TAKES_ARG(CHAR) \
+  (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
+   || (CHAR) == 'R' \
+   || (CHAR) == 'h' \
+   || (CHAR) == 'z')
+
+#define STDC_0_IN_SYSTEM_HEADERS 1
+
+/*
+ * Attempt to turn on access permissions for the stack.
+ *
+ * This code must be defined when compiling gcc but not when compiling
+ * libgcc2.a, unless we're generating code for 64-bit SPARC
+ *
+ * _SC_STACK_PROT is only defined for post 2.6, but we want this code
+ * to run always.  2.6 can change the stack protection but has no way to
+ * query it.
+ *
+ */
+
+/* This declares mprotect (used in TRANSFER_FROM_TRAMPOLINE) for
+   libgcc2.c.  */
+/* We don't want to include this because sys/mman.h is not present on
+   some non-Solaris configurations that use sol2.h.  */
+#if 0 /* def L_trampoline */
+#include <sys/mman.h>
+#endif
+
+#define TRANSFER_FROM_TRAMPOLINE					\
+									\
+/* #define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC) */	\
+									\
+static int need_enable_exec_stack;					\
+									\
+static void check_enabling(void) __attribute__ ((constructor));		\
+static void check_enabling(void)					\
+{									\
+  extern long sysconf(int);						\
+									\
+  int prot = (int) sysconf(515 /* _SC_STACK_PROT */);			\
+  if (prot != 7 /* STACK_PROT_RWX */)					\
+    need_enable_exec_stack = 1;						\
+}									\
+									\
+extern void __enable_execute_stack (void *);				\
+void									\
+__enable_execute_stack (addr)						\
+     void *addr;							\
+{									\
+  if (!need_enable_exec_stack)						\
+    return;								\
+  else {								\
+    long size = getpagesize ();						\
+    long mask = ~(size-1);						\
+    char *page = (char *) (((long) addr) & mask); 			\
+    char *end  = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
+									\
+    if (mprotect (page, end - page, 7 /* STACK_PROT_RWX */) < 0)	\
+      perror ("mprotect of trampoline code");				\
+  }									\
+}
Index: gcc/config/i386/sol2.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/sol2.h,v
retrieving revision 1.25
diff -u -p -r1.25 sol2.h
--- gcc/config/i386/sol2.h	16 Jun 2002 21:13:10 -0000	1.25
+++ gcc/config/i386/sol2.h	18 Jun 2002 22:42:24 -0000
@@ -20,36 +20,8 @@ along with GNU CC; see the file COPYING.
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-
-/* We use stabs-in-elf for debugging, because that is what the native
-   toolchain uses.  */
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-#if ! GAS_REJECTS_MINUS_S
-
-/*
-  Changed from config/svr4.h in the following ways:
-
-  - Removed -Yd (neither the sun bundled assembler nor gas accept it).
-  - Added "-s" so that stabs are not discarded.
-*/
-
-#undef ASM_SPEC
-#define ASM_SPEC \
-  "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s"
-
 #define CMOV_SUN_AS_SYNTAX 1
 
-#else /* GAS_REJECTS_MINUS_S */
-
-/* Same as above, except for -s, unsupported by GNU as.  */
-#undef ASM_SPEC
-#define ASM_SPEC \
-  "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*}"
-
-#endif /* GAS_REJECTS_MINUS_S */
-
 /* The Solaris 2.0 x86 linker botches alignment of code sections.
    It tries to align to a 16 byte boundary by padding with 0x00000090
    ints, rather than 0x90 bytes (nop).  This generates trash in the
@@ -68,98 +40,26 @@ Boston, MA 02111-1307, USA.  */
   (flag_pic ? (GLOBAL ? DW_EH_PE_indirect : 0) | DW_EH_PE_datarel	\
    : DW_EH_PE_absptr)
 
-/* Solaris 2/Intel uses a wint_t different from the default, as on SPARC.  */
-#undef	WINT_TYPE
-#define	WINT_TYPE "long int"
-
-#undef	WINT_TYPE_SIZE
-#define	WINT_TYPE_SIZE BITS_PER_WORD
-
-#define HANDLE_PRAGMA_REDEFINE_EXTNAME 1
-
-#define TARGET_OS_CPP_BUILTINS()			\
-  do							\
-    {							\
-	builtin_define_std ("unix");			\
-	builtin_define_std ("sun");			\
-	builtin_define ("__svr4__");			\
-	builtin_define ("__SVR4");			\
-	builtin_define ("__PRAGMA_REDEFINE_EXTNAME");	\
-	builtin_assert ("system=svr4");			\
-	/* For C++ we must add some additional macros	\
-	   required by the C++ standard library.  */	\
-	if (c_language == clk_cplusplus)		\
-	  {						\
-	    builtin_define ("_XOPEN_SOURCE=500");	\
-	    builtin_define ("_LARGEFILE_SOURCE=1");	\
-	    builtin_define ("_LARGEFILE64_SOURCE=1");	\
-	    builtin_define ("-D__EXTENSIONS__");	\
-	  }						\
-    }							\
-  while (0)
-
 /* Solaris 2/Intel as chokes on #line directives.  */
 #undef CPP_SPEC
-#define CPP_SPEC \
-  "%{.S:-P} \
-   %{pthreads:-D_REENTRANT -D_PTHREADS} \
-   %{!pthreads:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}} \
-   %{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude}"
-
-#undef LIB_SPEC
-#define LIB_SPEC \
-  "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
-   %{!shared:\
-     %{!symbolic:\
-       %{pthreads:-lpthread} \
-       %{!pthreads:%{threads:-lthread}} \
-       -lc}}"
+#define CPP_SPEC "%{.S:-P} %(cpp_subtarget)"
 
-#undef  ENDFILE_SPEC
-#define ENDFILE_SPEC "crtend.o%s %{pg:crtn.o%s}%{!pg:crtn.o%s}"
-
-#undef	STARTFILE_SPEC
-#define STARTFILE_SPEC "%{!shared: \
-			 %{!symbolic: \
-			  %{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}}\
-			%{pg:gmon.o%s} crti.o%s \
-			%{ansi:values-Xc.o%s} \
-			%{!ansi:values-Xa.o%s} \
- 			crtbegin.o%s"
-  
-/* This should be the same as in svr4.h, except with -R added.  */
-#undef LINK_SPEC
-#define LINK_SPEC \
-  "%{h*} %{v:-V} \
-   %{b} %{Wl,*:%*} \
-   %{static:-dn -Bstatic} \
-   %{shared:-G -dy %{!mimpure-text:-z text}} \
-   %{symbolic:-Bsymbolic -G -dy -z text} \
-   %{G:-G} \
-   %{YP,*} \
-   %{R*} \
-   %{compat-bsd: \
-     %{!YP,*:%{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-             %{!pg:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-                   %{!p:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
-             -R /usr/ucblib} \
-   %{!compat-bsd: \
-     %{!YP,*:%{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-             %{!pg:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-                   %{!p:-Y P,/usr/ccs/lib:/usr/lib}}}} \
-   %{Qy:} %{!Qn:-Qy}"
-
-/* This defines which switch letters take arguments.
-   It is as in svr4.h but with -R added.  */
-
-#undef SWITCH_TAKES_ARG
-#define SWITCH_TAKES_ARG(CHAR) \
-  (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
-   || (CHAR) == 'R' \
-   || (CHAR) == 'h' \
-   || (CHAR) == 'z')
-
-#define STDC_0_IN_SYSTEM_HEADERS 1
+/* FIXME: Removed -K PIC from generic Solaris 2 ASM_SPEC: the native assembler
+   gives many warnings: R_386_32 relocation is used for symbol ".text".  */
+#undef ASM_SPEC
+#define ASM_SPEC "\
+%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
+%(asm_cpu) \
+"
+
+#define ASM_CPU_SPEC ""
+ 
+#undef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS \
+  { "cpp_subtarget",	CPP_SUBTARGET_SPEC },	\
+  { "asm_cpu",		ASM_CPU_SPEC },		\
+  { "startfile_arch",	STARTFILE_ARCH_SPEC },	\
+  { "link_arch",	LINK_ARCH_SPEC }
 
 #undef LOCAL_LABEL_PREFIX
 #define LOCAL_LABEL_PREFIX "."
Index: gcc/config/sparc/sol2-bi.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sol2-bi.h,v
retrieving revision 1.6
diff -u -p -r1.6 sol2-bi.h
--- gcc/config/sparc/sol2-bi.h	15 May 2002 05:30:00 -0000	1.6
+++ gcc/config/sparc/sol2-bi.h	18 Jun 2002 22:42:24 -0000
@@ -5,9 +5,6 @@
 #undef SPARC_DEFAULT_CMODEL
 #define SPARC_DEFAULT_CMODEL CM_MEDANY
 
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 128
-
 #define AS_SPARC64_FLAG	"-xarch=v9"
 
 #undef ASM_CPU32_DEFAULT_SPEC
@@ -30,15 +27,6 @@
 #define ASM_CPU64_DEFAULT_SPEC AS_SPARC64_FLAG "a"
 #endif
 
-/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
-   It's safe to pass -s always, even if -g is not used.  */
-#undef ASM_SPEC
-#define ASM_SPEC "\
-%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
-%{fpic:-K PIC} %{fPIC:-K PIC} \
-%(asm_cpu)\
-"
-
 #if DEFAULT_ARCH32_P
 #define DEF_ARCH32_SPEC(__str) "%{!m64:" __str "}"
 #define DEF_ARCH64_SPEC(__str) "%{m64:" __str "}"
@@ -50,17 +38,14 @@
 #undef CPP_CPU_SPEC
 #define CPP_CPU_SPEC "\
 %{mcypress:} \
-%{msparclite:-D__sparclite__} \
-%{mf930:-D__sparclite__} %{mf934:-D__sparclite__} \
+%{msparclite|mf930|mf934:-D__sparclite__} \
 %{mv8:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
 %{msupersparc:-D__supersparc__ " DEF_ARCH32_SPEC("-D__sparcv8") "} \
-%{mcpu=sparclet:-D__sparclet__} %{mcpu=tsc701:-D__sparclet__} \
-%{mcpu=sparclite:-D__sparclite__} \
-%{mcpu=f930:-D__sparclite__} %{mcpu=f934:-D__sparclite__} \
+%{mcpu=sparclet|mcpu=tsc701:-D__sparclet__} \
+%{mcpu=sparclite|mcpu-f930|mcpu=f934:-D__sparclite__} \
 %{mcpu=v8:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
 %{mcpu=supersparc:-D__supersparc__ " DEF_ARCH32_SPEC("-D__sparcv8") "} \
-%{mcpu=v9:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
-%{mcpu=ultrasparc:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
+%{mcpu=v9|mcpu=ultrasparc:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:%(cpp_cpu_default)}}}}}}} \
 "
 
@@ -72,36 +57,24 @@
 %{!mcpu*:%(asm_cpu_default)} \
 "
 
-#define STARTFILE_SPEC32 "\
-%{ansi:values-Xc.o%s} \
-%{!ansi:values-Xa.o%s}"
-
-#define STARTFILE_SPEC64 "\
+#define STARTFILE_ARCH64_SPEC "\
 %{ansi:/usr/lib/sparcv9/values-Xc.o%s} \
 %{!ansi:/usr/lib/sparcv9/values-Xa.o%s}"
  
+#undef STARTFILE_ARCH_SPEC
+
 #if DEFAULT_ARCH32_P
 #define STARTFILE_ARCH_SPEC "\
-%{m32:" STARTFILE_SPEC32 "} \
-%{m64:" STARTFILE_SPEC64 "} \
-%{!m32:%{!m64:" STARTFILE_SPEC32 "}}"
+%{m32:" STARTFILE_ARCH32_SPEC "} \
+%{m64:" STARTFILE_ARCH64_SPEC "} \
+%{!m32:%{!m64:" STARTFILE_ARCH32_SPEC "}}"
 #else
 #define STARTFILE_ARCH_SPEC "\
-%{m32:" STARTFILE_SPEC32 "} \
-%{m64:" STARTFILE_SPEC64 "} \
-%{!m32:%{!m64:" STARTFILE_SPEC64 "}}"
+%{m32:" STARTFILE_ARCH32_SPEC "} \
+%{m64:" STARTFILE_ARCH64_SPEC "} \
+%{!m32:%{!m64:" STARTFILE_ARCH64_SPEC "}}"
 #endif
 
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "%{!shared: \
-			 %{!symbolic: \
-			  %{p:mcrt1.o%s} \
-                          %{!p: \
-	                    %{pg:gcrt1.o%s gmon.o%s} \
-                            %{!pg:crt1.o%s}}}} \
-			crti.o%s " STARTFILE_ARCH_SPEC " \
-			crtbegin.o%s"
-
 #undef CPP_CPU_DEFAULT_SPEC
 #define CPP_CPU_DEFAULT_SPEC \
 (DEFAULT_ARCH32_P ? "\
@@ -170,41 +143,30 @@
 
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
+  { "startfile_arch",	 STARTFILE_ARCH_SPEC },		  \
   { "link_arch32",       LINK_ARCH32_SPEC },              \
   { "link_arch64",       LINK_ARCH64_SPEC },              \
   { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },	  \
   { "link_arch",	 LINK_ARCH_SPEC },
     
-/* This should be the same as in svr4.h, except with -R added.  */
-#define LINK_ARCH32_SPEC \
-  "%{G:-G} \
-   %{YP,*} \
-   %{R*} \
-   %{compat-bsd: \
-     %{!YP,*:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-       %{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-       %{!p:%{!pg:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
-     -R /usr/ucblib} \
-   %{!compat-bsd: \
-     %{!YP,*:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-       %{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-       %{!p:%{!pg:-Y P,/usr/ccs/lib:/usr/lib}}}}"
-
+/*
+ * This should be the same as in sol2.h, except with "/sparcv9"
+ * appended to the paths and /usr/ccs/lib is no longer necessary
+ */
 #define LINK_ARCH64_SPEC \
   "%{mcmodel=medlow:-M /usr/lib/ld/sparcv9/map.below4G} \
    %{G:-G} \
    %{YP,*} \
    %{R*} \
    %{compat-bsd: \
-     %{!YP,*:%{p:-Y P,/usr/ucblib/sparcv9:/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
-       %{pg:-Y P,/usr/ucblib/sparcv9:/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
+     %{!YP,*:%{p|pg:-Y P,/usr/ucblib/sparcv9:/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
        %{!p:%{!pg:-Y P,/usr/ucblib/sparcv9:/usr/lib/sparcv9}}} \
      -R /usr/ucblib} \
    %{!compat-bsd: \
-     %{!YP,*:%{p:-Y P,/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
-       %{pg:-Y P,/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
+     %{!YP,*:%{p|pg:-Y P,/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
        %{!p:%{!pg:-Y P,/usr/lib/sparcv9}}}}"
 
+#undef LINK_ARCH_SPEC
 #define LINK_ARCH_SPEC "\
 %{m32:%(link_arch32)} \
 %{m64:%(link_arch64)} \
@@ -213,16 +175,6 @@
 
 #define LINK_ARCH_DEFAULT_SPEC \
 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
-
-#undef  LINK_SPEC
-#define LINK_SPEC \
-  "%{h*} %{v:-V} \
-   %{b} %{Wl,*:%*} \
-   %{static:-dn -Bstatic} \
-   %{shared:-G -dy %{!mimpure-text:-z text}} \
-   %{symbolic:-Bsymbolic -G -dy -z text} \
-   %(link_arch) \
-   %{Qy:} %{!Qn:-Qy}"
 
 #undef	CC1_SPEC
 #if DEFAULT_ARCH32_P
Index: gcc/config/sparc/sol2.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sol2.h,v
retrieving revision 1.46
diff -u -p -r1.46 sol2.h
--- gcc/config/sparc/sol2.h	9 May 2002 10:50:22 -0000	1.46
+++ gcc/config/sparc/sol2.h	18 Jun 2002 22:42:24 -0000
@@ -23,51 +23,8 @@ Boston, MA 02111-1307, USA.  */
 
 /* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
 
-/* Solaris 2 (at least as of 2.5.1) uses a 32-bit wchar_t.  */
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "long int"
-
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE 32
-
-/* Solaris 2 uses a wint_t different from the default. This is required
-   by the SCD 2.4.1, p. 6-83, Figure 6-66.  */
-#undef	WINT_TYPE
-#define	WINT_TYPE "long int"
-
-#undef	WINT_TYPE_SIZE
-#define	WINT_TYPE_SIZE 32
-
-#define HANDLE_PRAGMA_REDEFINE_EXTNAME 1
-
 #undef CPP_PREDEFINES
-#define CPP_PREDEFINES \
-"-Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__PRAGMA_REDEFINE_EXTNAME \
--Asystem=unix -Asystem=svr4"
-
-#undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC "\
-%{pthreads:-D_REENTRANT -D_PTHREADS} \
-%{!pthreads:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}} \
-%{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
-"
-
-/* For C++ we need to add some additional macro definitions required
-   by the C++ standard library.  */
-#define CPLUSPLUS_CPP_SPEC "\
--D_XOPEN_SOURCE=500 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
--D__EXTENSIONS__ \
-%(cpp) \
-"
-
-/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
-   It's safe to pass -s always, even if -g is not used.  */
-#undef ASM_SPEC
-#define ASM_SPEC "\
-%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
-%{fpic:-K PIC} %{fPIC:-K PIC} \
-%(asm_cpu) \
-"
+#define CPP_PREDEFINES "-Dsparc"
 
 /* This is here rather than in sparc.h because it's not known what
    other assemblers will accept.  */
@@ -98,11 +55,6 @@ Boston, MA 02111-1307, USA.  */
 #define DBX_REGISTER_NUMBER(REGNO) \
   (TARGET_FLAT && (REGNO) == HARD_FRAME_POINTER_REGNUM ? 31 : REGNO)
 
-/* We use stabs-in-elf by default, because that is what the native
-   toolchain uses.  */
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
 /* The Solaris 2 assembler uses .skip, not .zero, so put this back.  */
 #undef ASM_OUTPUT_SKIP
 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
@@ -135,72 +87,12 @@ Boston, MA 02111-1307, USA.  */
   sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
 
 
-/* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us.
-   We don't use the standard LIB_SPEC only because we don't yet support c++ */
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "%{!shared: \
-			 %{!symbolic: \
-			  %{p:mcrt1.o%s} \
-                          %{!p: \
-	                    %{pg:gcrt1.o%s gmon.o%s} \
-                            %{!pg:crt1.o%s}}}} \
-			crti.o%s \
-			%{ansi:values-Xc.o%s} \
-			%{!ansi:values-Xa.o%s} \
-			crtbegin.o%s"
-
-/* ??? Note: in order for -compat-bsd to work fully,
-   we must somehow arrange to fixincludes /usr/ucbinclude
-   and put the result in $(libsubdir)/ucbinclude.  */
-
-#undef LIB_SPEC
-#define LIB_SPEC \
-  "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
-   %{!shared:\
-     %{!symbolic:\
-       %{pthreads:-lpthread} \
-       %{!pthreads:%{threads:-lthread}} \
-       %{p|pg:-ldl} -lc}}"
 
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
    crtend.o%s crtn.o%s"
 
-/* This should be the same as in svr4.h, except with -R added.  */
-#undef LINK_SPEC
-#define LINK_SPEC \
-  "%{h*} %{v:-V} \
-   %{b} %{Wl,*:%*} \
-   %{static:-dn -Bstatic} \
-   %{shared:-G -dy %{!mimpure-text:-z text}} \
-   %{symbolic:-Bsymbolic -G -dy -z text} \
-   %{G:-G} \
-   %{YP,*} \
-   %{R*} \
-   %{compat-bsd: \
-     %{!YP,*:%{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-             %{!pg:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-                   %{!p:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
-             -R /usr/ucblib} \
-   %{!compat-bsd: \
-     %{!YP,*:%{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-             %{!pg:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
-                   %{!p:-Y P,/usr/ccs/lib:/usr/lib}}}} \
-   %{Qy:} %{!Qn:-Qy}"
-
-/* This defines which switch letters take arguments.
-   It is as in svr4.h but with -R added.  */
-
-#undef SWITCH_TAKES_ARG
-#define SWITCH_TAKES_ARG(CHAR) \
-  (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
-   || (CHAR) == 'R' \
-   || (CHAR) == 'h' \
-   || (CHAR) == 'x' \
-   || (CHAR) == 'z')
-
 /* Select a format to encode pointers in exception handling data.  CODE
    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
    true if the symbol may be affected by dynamic relocations.
@@ -221,8 +113,6 @@ Boston, MA 02111-1307, USA.  */
 /* But indicate that it isn't supported by the hardware.  */
 #define WIDEST_HARDWARE_FP_SIZE 64
 
-#define STDC_0_IN_SYSTEM_HEADERS 1
-
 #define MULDI3_LIBCALL "__mul64"
 #define DIVDI3_LIBCALL "__div64"
 #define UDIVDI3_LIBCALL "__udiv64"
@@ -249,56 +139,4 @@ Boston, MA 02111-1307, USA.  */
 /* Solaris allows 64 bit out and global registers in 32 bit mode.
    sparc_override_options will disable V8+ if not generating V9 code.  */
 #undef TARGET_DEFAULT
-#define TARGET_DEFAULT (MASK_FPU + MASK_V8PLUS + MASK_LONG_DOUBLE_128)
-
-/*
- * Attempt to turn on access permissions for the stack.
- *
- * This code must be defined when compiling gcc but not when compiling
- * libgcc2.a, unless we're generating code for 64 bits SPARC
- *
- * _SC_STACK_PROT is only defined for post 2.6, but we want this code
- * to run always.  2.6 can change the stack protection but has no way to
- * query it.
- *
- */
-
-/* This declares mprotect (used in TRANSFER_FROM_TRAMPOLINE) for
-   libgcc2.c.  */
-/* We don't want to include this because sys/mman.h is not present on
-   some non-Solaris configurations that use sol2.h.  */
-#if 0 /* def L_trampoline */
-#include <sys/mman.h>
-#endif
-
-#define TRANSFER_FROM_TRAMPOLINE					\
-static int need_enable_exec_stack;					\
-									\
-static void check_enabling(void) __attribute__ ((constructor));		\
-static void check_enabling(void)					\
-{									\
-  extern long sysconf(int);						\
-									\
-  int prot = (int) sysconf(515 /*_SC_STACK_PROT */);			\
-  if (prot != 7)							\
-    need_enable_exec_stack = 1;						\
-}									\
-									\
-extern void __enable_execute_stack (void *);				\
-void									\
-__enable_execute_stack (addr)						\
-     void *addr;							\
-{									\
-  if (!need_enable_exec_stack)						\
-    return;								\
-  else {								\
-    long size = getpagesize ();						\
-    long mask = ~(size-1);						\
-    char *page = (char *) (((long) addr) & mask); 			\
-    char *end  = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
-									\
-    /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ 			\
-    if (mprotect (page, end - page, 7) < 0)				\
-      perror ("mprotect of trampoline code");				\
-  }									\
-}
+#define TARGET_DEFAULT (MASK_V8PLUS + MASK_FPU + MASK_LONG_DOUBLE_128)



More information about the Gcc-patches mailing list