This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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



>Number:         1647
>Category:       target
>Synopsis:       patch for gcc-2.95.3 on NetBSD/sparc-1.5
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 14 06:16:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Adrian Bunk
>Release:        2.95.3 20010111 (prerelease)
>Organization:
Fachschaft MPI TU Muenchen                
>Environment:
System: NetBSD mimas 1.5 NetBSD 1.5 (GENERIC) #1: Wed Nov 29 00:29:52 MET 2000 root@flambard:/usr/src/sys/arch/sparc/compile/GENERIC sparc


	
host: sparc-unknown-netbsdelf1.5
build: sparc-unknown-netbsdelf1.5
target: sparc-unknown-netbsdelf1.5
configured with: ../configure
>Description:
NetBSD/sparc has switched from a.out to ELF in version 1.5 .
The changes below are needed to compile gcc-2.95.3 on this platform.
The patch is based on a not complete patch in the NetBSD Packages Collection
with changes made by Michael Rauch <mrauch@fs.tum.de> and me.

>How-To-Repeat:

>Fix:

1. update config.guess and config.sub to the versions from automake-1.4b
   to get the machine recognized as sparc-unknown-netbsdelf1.5.
2. apply the following patch:

--- 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,73 @@
+/* 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 "-Dunix -Dsparc -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
+
+/** We don't have the C++ support for this (yet). */
+#undef DWARF2_UNWIND_INFO
+#define DWARF2_UNWIND_INFO 0
+
+/* 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/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/config/t-netbsd.old	Sun Jan  7 17:35:30 2001
+++ gcc/config/t-netbsd	Sun Jan  7 17:35:52 2001
@@ -1,6 +1,7 @@
 LIBGCC1=libgcc1.null
 CROSS_LIBGCC1=libgcc1.null
 LIBGCC1_TEST=
+TARGET_LIBGCC2_FLAGS = -fPIC
 
 # Don't run fixproto
 STMP_FIXPROTO =
diff -b -r -N -u ../gcc-2.95.2.orig/gcc/config/netbsd.h ./gcc/config/netbsd.h
--- gcc/config/netbsd.h	Wed Dec 16 21:59:58 1998
+++ gcc/config/netbsd.h	Sat Dec 30 11:27:51 2000
@@ -48,17 +48,31 @@
 #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}"
 
 /* Provide a LIB_SPEC appropriate for NetBSD.  Just select the appropriate
-   libc, depending on whether we're doing profiling.  */
+   libc, depending on whether we're doing profiling; if `-posix' is specified,
+   link against the appropriate libposix first.  */
 
 #undef LIB_SPEC
-#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
+#define LIB_SPEC							\
+  "%{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}}		\
+   %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
+
+#ifdef NETBSD_AOUT
+
+/* Provide a STARTFILE_SPEC appropriate for NetBSD a.out.  Here we
+   provide support for the special GCC option -static.  */
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC \
+  "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:%{!static:crt0%O%s}%{static:scrt0%O%s}}}} %{shared:c++rt0%O%s}"
 
 /* Provide a LINK_SPEC appropriate for NetBSD.  Here we provide support
    for the special GCC options -static, -assert, and -nostdlib.  */
 
 #undef LINK_SPEC
 #define LINK_SPEC \
-  "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} %{static:-Bstatic} %{assert*}"
+  "%{nostdlib:-nostdlib} %{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic}} %{shared:-Bshareable} %{R*} %{assert*}"
+
+#endif /* NETBSD_AOUT */
 
 /* This defines which switch letters take arguments. */
 #undef SWITCH_TAKES_ARG
@@ -127,6 +141,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 +224,51 @@
 	putc ('\n', FILE);						\
       }									\
   } while (0)
+
+#endif /* ! NETBSD_ELF */
+
+/* NetBSD ELF support begins here. */
+
+#ifdef NETBSD_ELF
+
+#undef DWARF_DEBUGGING_INFO	/* XXX */
+#undef DWARF2_DEBUGGING_INFO	/* XXX */
+
+/* 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 */
diff -b -r -N -u ../gcc-2.95.2.orig/gcc/configure.in ./gcc/configure.in
--- gcc/configure.in	Wed Oct 13 09:58:02 1999
+++ gcc/configure.in	Sat Dec 30 10:55:47 2000
@@ -3033,6 +3033,11 @@
 		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
+		tmake_file=t-netbsd
+		;;
 	sparc-*-netbsd*)
 		tm_file=sparc/netbsd.h
 		tmake_file=t-netbsd

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]