target/1647: patch for gcc-2.95.3 on NetBSD/sparc-1.5

Adrian Bunk bunk@fs.tum.de
Sun Dec 16 14:45:00 GMT 2001


On 12 Dec 2001 rodrigc@gcc.gnu.org wrote:

> Synopsis: patch for gcc-2.95.3 on NetBSD/sparc-1.5
>
> State-Changed-From-To: open->feedback
> State-Changed-By: rodrigc
> State-Changed-When: Wed Dec 12 12:15:52 2001
> State-Changed-Why:
>     Do you have an updated version of this patch for
>     gcc 2.95.3 20010315 (release)?


Attached is a stripped-down version of the patch we used for the
gcc-2.95.3 we are using since over 8 months without any problems.
"stripped-down" means that I've cleaned it a bit and removed e.g. 64 bit
specific parts that are completely untested since we don't have any 64 bit
machines. I applied the attached patch to and upgraded config.guess and
config.sub in clean 2.95.3 sources and the compiler bootstrapped
successfully.


cu
Adrian

-------------- next part --------------
--- gcc/config/sparc/netbsd-elf-common.h.orig	Sat Sep 16 00:17:42 2000
+++ gcc/config/sparc/netbsd-elf-common.h	Sat Sep 16 00:17:42 2000
@@ -0,0 +1,69 @@
+/* NetBSD/sparc ELF common 32/64 bit configuration */
+
+#define OBJECT_FORMAT_ELF
+#define NETBSD_ELF
+#include <netbsd.h>
+
+/* Fix up CPP_SPEC.  This merges the code from <netbsd.h> and <sparc/sparc.h> */
+#undef CPP_SPEC
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} \
+%(cpp_cpu) %(cpp_arch) %(cpp_endian) %(cpp_subtarget)"
+
+#undef CPP_PREDEFINES
+#define CPP_PREDEFINES "-D__sparc__ -D__NetBSD__ -D__ELF__ \
+-Asystem(unix) -Asystem(NetBSD)"
+
+#undef SIZE_TYPE
+#define SIZE_TYPE "long unsigned int"
+
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "long int"
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+#undef WCHAR_UNSIGNED
+#define WCHAR_UNSIGNED 0
+
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+
+/* This is the char to use for continuation (in case we need to turn
+   continuation back on).  */
+#undef DBX_CONTIN_CHAR
+#define DBX_CONTIN_CHAR '?'
+
+#undef DBX_REGISTER_NUMBER
+#define DBX_REGISTER_NUMBER(REGNO) \
+  (TARGET_FLAT && REGNO == FRAME_POINTER_REGNUM ? 31 : REGNO)
+
+/* This is how to output a definition of an internal numbered label where
+   PREFIX is the class of label and NUM is the number within the class.  */
+
+#undef  ASM_OUTPUT_INTERNAL_LABEL
+#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)	\
+  fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
+
+/* This is how to store into the string LABEL
+   the symbol_ref name of an internal numbered label where
+   PREFIX is the class of label and NUM is the number within the class.
+   This is suitable for output with `assemble_name'.  */
+
+#undef  ASM_GENERATE_INTERNAL_LABEL
+#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)	\
+  sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
+
+#undef ASM_SPEC
+#define ASM_SPEC "%{fpic:-K PIC} %{fPIC:-K PIC} \
+%{mlittle-endian:-EL} \
+%(asm_cpu) %(asm_arch)\
+"
+
+#undef STDC_0_IN_SYSTEM_HEADERS
+
+/* XXX Redefine this; <sparc/sparc.h> mucks with it. */
+#undef TARGET_VERSION
+#define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);
--- gcc/config/sparc/netbsd-elf.h.orig	Sat Sep 16 00:17:42 2000
+++ gcc/config/sparc/netbsd-elf.h	Sat Sep 16 00:17:42 2000
@@ -0,0 +1,42 @@
+/* NetBSD/sparc ELF configuration */
+
+/*
+ * Pull in generic SPARC ELF configuration, and then clean up
+ * afterwards
+ */
+#include <sparc/elf.h>
+
+/* Name the target CPU. */
+#ifndef TARGET_CPU_DEFAULT
+#define TARGET_CPU_DEFAULT	TARGET_CPU_sparc
+#endif
+
+#undef MULDI3_LIBCALL
+#undef DIVDI3_LIBCALL
+#undef UDIVDI3_LIBCALL
+#undef MODDI3_LIBCALL
+#undef UMODDI3_LIBCALL
+#undef INIT_SUBTARGET_OPTABS  
+#define INIT_SUBTARGET_OPTABS  
+
+#undef CPP_SUBTARGET_SPEC
+#define CPP_SUBTARGET_SPEC "-D__sparc"
+
+#include <sparc/netbsd-elf-common.h>
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "-m elf32_sparc \
+  %{assert*} %{R*} \
+  %{shared:-shared} \
+  %{!shared: \
+    -dy -dc -dp \
+    %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
+    %{static:-static}}"
+
+/* Name the port. */
+#undef TARGET_NAME
+#define TARGET_NAME     "sparc-netbsdelf"
--- gcc/config/sparc/xm-netbsd.h.orig	Sat Sep 16 00:17:42 2000
+++ gcc/config/sparc/xm-netbsd.h	Sat Sep 16 00:17:42 2000
@@ -0,0 +1,4 @@
+/* Configuration for GCC for Sun SPARC running NetBSD as host.  */
+
+#include <sparc/xm-sparc.h>
+#include <xm-netbsd.h>
--- gcc/config/netbsd.h.orig	Wed Dec 16 15:59:58 1998
+++ gcc/config/netbsd.h	Wed Feb 28 18:41:35 2001
@@ -127,6 +147,8 @@
    entries in an ELF object file under SVR4.  These macros also output
    the starting labels for the relevant functions/objects.  */
 
+#ifndef NETBSD_ELF
+
 /* Write the extra assembler code needed to declare a function properly.
    Some svr4 assemblers need to also have something extra said about the
    function's return value.  We allow for that here.  */
@@ -207,3 +230,48 @@
 	putc ('\n', FILE);						\
       }									\
   } while (0)
+
+#endif /* ! NETBSD_ELF */
+
+/* NetBSD ELF support begins here. */
+
+#ifdef NETBSD_ELF
+
+/* Provide a STARTFILE_SPEC appropriate for NetBSD ELF targets.  Here we
+   provide support for the special GCC option -static.  On ELF targets,
+   we also add the crtbegin.o file which provides part of the support
+   for getting C++ file-scope static objects constructed before entering
+   `main'. */
+
+#undef STARTFILE_SPEC
+#define	STARTFILE_SPEC \
+ "%{!shared: \
+     %{pg:gcrt0%O%s} \
+     %{!pg: \
+        %{p:gcrt0%O%s} \
+        %{!p:crt0%O%s}}} \
+   %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}"
+
+/* Provide an ENDFILE_SPEC appropriate for NetBSD ELF targets.  Here we
+   add crtend.o, which provides part of the support for getting C++
+   file-scope static objects deconstructed after exiting `main'. */
+
+#undef ENDFILE_SPEC
+#define	ENDFILE_SPEC \
+ "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
+
+/* Provide a LINK_SPEC appropriate for a NetBSD ELF target.  */
+
+#undef LINK_SPEC
+#define	LINK_SPEC \
+ "%{assert*} \
+  %{shared:-shared} \
+  %{!shared: \
+    -dc -dp \
+    %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
+    %{static:-static}}"
+
+#endif /* NETBSD_ELF */
--- gcc/config/xm-netbsd.h.orig	Sat Sep 16 00:17:42 2000
+++ gcc/config/xm-netbsd.h	Sat Sep 16 00:17:42 2000
@@ -0,0 +1,32 @@
+/* Configuration for GNU C-compiler for hosts running NetBSD.
+   Copyright (C) 1995 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.  */
+
+/* This file defines machine-independent things specific to a host
+   running NetBSD.  This file should not be specified as $xm_file itself;
+   instead $xm_file should be CPU/xm-netbsd.h, which should include both
+   CPU/xm-CPU.h and this file xm-netbsd.h.  */
+
+#undef POSIX
+#define POSIX
+
+/* Ensure we get gnu C's defaults.  */
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#endif
--- gcc/configure.in.orig	Wed Oct 13 09:58:02 1999
+++ gcc/configure.in	Sat Sep 16 01:07:10 2000
@@ -3033,6 +3044,12 @@
 		tmake_file=sparc/t-sparcbare
 		tm_file="sparc/aout.h libgloss.h"
 		;;
+	sparc-*-netbsd*elf*)
+		tm_file=sparc/netbsd-elf.h
+		xm_file=sparc/xm-netbsd.h
+		extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
+		tmake_file="t-netbsd sparc/t-netbsd"
+		;;
 	sparc-*-netbsd*)
 		tm_file=sparc/netbsd.h
 		tmake_file=t-netbsd
--- gcc/config/sparc/t-netbsd.orig	Tue Feb 27 14:37:27 2001
+++ gcc/config/sparc/t-netbsd
@@ -0,0 +1,9 @@
+# We have to include libgcc.a also in shared libraries, so 
+# let's compile the code position independent
+
+TARGET_LIBGCC2_CFLAGS = -fPIC
+
+# Same for crtbeginS.o and crtendS.o . All code that goes into a shared
+# library has to be PIC
+
+CRTSTUFF_T_CFLAGS_S = -fPIC


More information about the Gcc-bugs mailing list