sync OpenBSD targets with reality

Jonathan Gray jsg@openbsd.org
Sat Sep 19 18:14:00 GMT 2009


The following updates OpenBSD targets to take into account
type changes that happened several years ago, alpha moving
to ELF, and a few other things besides.  This was initially
based on the local OpenBSD changes in the ports tree version of
GCC 4.2.4 and updated for trunk/4.5.0.

There are still several other changes to make like
adding additional targets, pch support, dwarf2 unwind,
boehm-gc, libstdc++ wchar etc but I would like to see this
go in as a starting point.

trunk/4.5.0 seems to be very volatile at the moment, I built
it fine a few days ago on i386 but almost every day since
I seem to have a different problem building it.

So with a similiar set of changes against 4.4.1 I see:

                === gcc Summary ===

# of expected passes            58769
# of unexpected failures        75
# of unexpected successes       1
# of expected failures          187
# of unsupported tests          1144
/usr/users/jsg/src/obj/gcc/xgcc  version 4.4.1 (GCC)

The test failures above seem to largely relate to things like long double.

2009-09-19  Jonathan Gray <jsg@openbsd.org>

	* config.gcc: update OpenBSD targets
	* config/openbsd-stdint.h: New
	* config/openbsd-libpthread.h: New, common OpenBSD LIB_SPEC
	* config/openbsd/i386/openbsdelf.h config/vax/openbsd.h config/mips/openbsd.h: Correct types
	* config/alpha/openbsd.h: Overhaul to reflect ELF migration
	* config/openbsd.h: Update and break out LIB_SPEC definition

Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 151882)
+++ gcc/config.gcc	(working copy)
@@ -629,11 +629,11 @@ alpha*-*-netbsd*)
 	tmake_file="${tmake_file} alpha/t-alpha alpha/t-ieee"
 	;;
 alpha*-*-openbsd*)
-	tm_defines="${tm_defines} OBSD_NO_DYNAMIC_LIBRARIES OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_FUNCTION_SIZE OBSD_HAS_DECLARE_OBJECT"
-	tm_file="alpha/alpha.h openbsd.h alpha/openbsd.h"
+	tm_defines="${tm_defines} OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_FUNCTION_SIZE OBSD_HAS_DECLARE_OBJECT"
+	tm_file="alpha/alpha.h alpha/elf.h openbsd.h openbsd-stdint.h alpha/openbsd.h openbsd-libpthread.h"
 	# default x-alpha is only appropriate for dec-osf.
 	target_cpu_default="MASK_GAS"
-	tmake_file="alpha/t-alpha alpha/t-ieee"
+	tmake_file="${tmake_file} alpha/t-alpha alpha/t-ieee"
 	;;
 alpha*-dec-osf[45]*)
 	if test x$stabs = xyes
@@ -1117,7 +1117,7 @@ i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123])
 	;;
 i[34567]86-*-openbsd*)
 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h"
-	tm_file="${tm_file} openbsd.h i386/openbsdelf.h"
+	tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h i386/openbsdelf.h"
 	gas=yes
 	gnu_ld=yes
 	;;
@@ -1558,7 +1558,7 @@ m68k*-*-openbsd*)
 	default_cf_cpu=5475
 	# needed to unconfuse gdb
 	tm_defines="${tm_defines} OBSD_OLD_GAS"
-	tm_file="${tm_file} openbsd.h m68k/openbsd.h"
+	tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h m68k/openbsd.h"
 	tmake_file="t-libc-ok t-openbsd m68k/t-openbsd"
 	# we need collect2 until our bug is fixed...
 	use_collect2=yes
@@ -1696,7 +1696,7 @@ mips*-*-linux*)				# Linux MIPS, either endian.
 mips*-*-openbsd*)
 	tm_defines="${tm_defines} OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_OBJECT OBSD_HAS_CORRECT_SPECS"
 	target_cpu_default="MASK_ABICALLS"
-	tm_file="mips/mips.h openbsd.h mips/openbsd.h mips/sdb.h"
+	tm_file="mips/mips.h openbsd.h openbsd-stdint.h openbsd-libpthread.h mips/openbsd.h mips/sdb.h"
 	case ${target} in
 	mips*el-*-openbsd*)
 	    tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=0";;
@@ -2298,7 +2298,8 @@ sparc-*-netbsdelf*)
 	extra_options="${extra_options} sparc/long-double-switch.opt"
 	;;
 sparc64-*-openbsd*)
-	tm_file="sparc/openbsd1-64.h ${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sp64-elf.h openbsd.h sparc/openbsd64.h"
+	tm_file="sparc/openbsd1-64.h ${tm_file} dbxelf.h elfos.h svr4.h sparc/sysv4.h sparc/sp64-elf.h"
+	tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h sparc/openbsd64.h"
 	extra_options="${extra_options} sparc/little-endian.opt"
 	gas=yes gnu_ld=yes
 	with_cpu=ultrasparc
@@ -2508,7 +2509,7 @@ vax-*-netbsd*)
 	use_collect2=yes
 	;;
 vax-*-openbsd*)
-	tm_file="vax/vax.h vax/openbsd1.h openbsd.h vax/openbsd.h"
+	tm_file="vax/vax.h vax/openbsd1.h openbsd.h openbsd-stdint.h openbsd-pthread.h vax/openbsd.h"
 	use_collect2=yes
 	;;
 xstormy16-*-elf)
Index: gcc/config/alpha/openbsd.h
===================================================================
--- gcc/config/alpha/openbsd.h	(revision 151882)
+++ gcc/config/alpha/openbsd.h	(working copy)
@@ -17,23 +17,13 @@ You should have received a copy of the GNU General Pub
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/* We settle for little endian for now.  */
-#define TARGET_ENDIAN_DEFAULT 0
-
 /* Controlling the compilation driver.  */
 
-/* alpha needs __start.  */
-#undef LINK_SPEC
-#define LINK_SPEC \
-  "%{!nostdlib:%{!r*:%{!e*:-e __start}}} -dc -dp %{assert*}"
-
 /* run-time target specifications */
 #define TARGET_OS_CPP_BUILTINS()		\
     do {					\
-	builtin_define ("__OpenBSD__");		\
-	builtin_define ("__ANSI_COMPAT");	\
-	builtin_define ("__unix__");		\
-	builtin_assert ("system=unix");		\
+	OPENBSD_OS_CPP_BUILTINS_ELF();		\
+	OPENBSD_OS_CPP_BUILTINS_LP64();		\
     } while (0)
 
 /* Layout of source language data types.  */
@@ -52,47 +42,4 @@ along with GCC; see the file COPYING3.  If not see
 #define WCHAR_TYPE_SIZE 32
 
 
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
 #define LOCAL_LABEL_PREFIX	"."
-
-/* We don't have an init section yet.  */
-#undef HAS_INIT_SECTION
-
-/* collect2 support (assembler format: macros for initialization).  */
-
-/* Don't tell collect2 we use COFF as we don't have (yet ?) a dynamic ld
-   library with the proper functions to handle this -> collect2 will
-   default to using nm.  */
-#undef OBJECT_FORMAT_COFF
-#undef EXTENDED_COFF
-
-/* Assembler format: exception region output.  */
-
-/* All configurations that don't use elf must be explicit about not using
-   dwarf unwind information.  */
-#ifdef INCOMING_RETURN_ADDR_RTX
-#undef DWARF2_UNWIND_INFO
-#define DWARF2_UNWIND_INFO 0
-#endif
-
-/* Assembler format: label output.  */
-
-/* alpha ecoff supports only weak aliases.  */
-#undef ASM_WEAKEN_LABEL
-#define ASM_WEAKEN_LABEL(FILE,NAME) ASM_OUTPUT_WEAK_ALIAS (FILE,NAME,0)
-
-#define ASM_OUTPUT_WEAK_ALIAS(FILE,NAME,VALUE)	\
- do {						\
-  fputs ("\t.weakext\t", FILE);			\
-  assemble_name (FILE, NAME);			\
-  if (VALUE)					\
-    {						\
-      fputs (" , ", FILE);			\
-      assemble_name (FILE, VALUE);		\
-    }						\
-  fputc ('\n', FILE);				\
- } while (0)
-
-
Index: gcc/config/openbsd-stdint.h
===================================================================
--- gcc/config/openbsd-stdint.h	(revision 0)
+++ gcc/config/openbsd-stdint.h	(revision 0)
@@ -0,0 +1,31 @@
+#define SIG_ATOMIC_TYPE		"int"
+ 
+#define INT8_TYPE		"signed char"
+#define INT16_TYPE		"short int"
+#define INT32_TYPE		"int"
+#define INT64_TYPE		"long long int"
+#define UINT8_TYPE		"unsigned char"
+#define UINT16_TYPE		"unsigned short int"
+#define UINT32_TYPE		"unsigned int"
+#define UINT64_TYPE		"unsigned long long int"
+ 
+#define INT_LEAST8_TYPE		"signed char"
+#define INT_LEAST16_TYPE	"short int"
+#define INT_LEAST32_TYPE	"int"
+#define INT_LEAST64_TYPE	"long long int"
+#define UINT_LEAST8_TYPE	"unsigned char"
+#define UINT_LEAST16_TYPE	"unsigned short int"
+#define UINT_LEAST32_TYPE	"unsigned int"
+#define UINT_LEAST64_TYPE	"unsigned long long int"
+ 
+#define INT_FAST8_TYPE		"int"
+#define INT_FAST16_TYPE		"int"
+#define INT_FAST32_TYPE		"int"
+#define INT_FAST64_TYPE		"long long int"
+#define UINT_FAST8_TYPE		"unsigned int"
+#define UINT_FAST16_TYPE	"unsigned int"
+#define UINT_FAST32_TYPE	"unsigned int"
+#define UINT_FAST64_TYPE	"unsigned long long int"
+ 
+#define INTPTR_TYPE		"long int"
+#define UINTPTR_TYPE		"unsigned long int"
Index: gcc/config/i386/openbsdelf.h
===================================================================
--- gcc/config/i386/openbsdelf.h	(revision 151882)
+++ gcc/config/i386/openbsdelf.h	(working copy)
@@ -55,16 +55,19 @@ along with GCC; see the file COPYING3.  If not see
 
 /* This must agree with <machine/ansi.h> */
 #undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
+#define SIZE_TYPE "long unsigned int"
 
 #undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
+#define PTRDIFF_TYPE "long int"
 
 #undef WCHAR_TYPE
 #define WCHAR_TYPE "int"
 
 #undef WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE BITS_PER_WORD
+
+#undef WINT_TYPE
+#define WINT_TYPE "int"
 
 /* Assembler format: overall framework.  */
 
Index: gcc/config/openbsd-libpthread.h
===================================================================
--- gcc/config/openbsd-libpthread.h	(revision 0)
+++ gcc/config/openbsd-libpthread.h	(revision 0)
@@ -0,0 +1,22 @@
+/* LIB_SPEC appropriate for OpenBSD.  Include -lpthread if -pthread is
+   specified on the command line. */
+/*   Copyright (C) 2004 Free Software Foundation, Inc.
+
+   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.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#define OBSD_LIB_SPEC "%{!shared:%{pthread:-lpthread} -lc}"
+
Index: gcc/config/m68k/openbsd.h
===================================================================
--- gcc/config/m68k/openbsd.h	(revision 151882)
+++ gcc/config/m68k/openbsd.h	(working copy)
@@ -42,16 +42,19 @@ along with GCC; see the file COPYING3.  If not see
 
 /* This must agree with <machine/ansi.h> */
 #undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
+#define SIZE_TYPE "long unsigned int"
 
 #undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
+#define PTRDIFF_TYPE "long int"
 
 #undef WCHAR_TYPE
 #define WCHAR_TYPE "int"
 
 #undef WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 32
+
+#undef WINT_TYPE
+#define WINT_TYPE "int"
 
 /* Storage layout.  */
 
Index: gcc/config/mips/openbsd.h
===================================================================
--- gcc/config/mips/openbsd.h	(revision 151882)
+++ gcc/config/mips/openbsd.h	(working copy)
@@ -57,16 +57,19 @@ along with GCC; see the file COPYING3.  If not see
 
 /* This must agree with <machine/ansi.h>.  */
 #undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
+#define SIZE_TYPE "long unsigned int"
 
 #undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
+#define PTRDIFF_TYPE "long int"
 
 #undef WCHAR_TYPE
 #define WCHAR_TYPE "int"
 
 #undef WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 32
+
+#undef WINT_TYPE
+#define WINT_TYPE "int"
 
 /* Controlling the compilation driver.  */
 
Index: gcc/config/openbsd.h
===================================================================
--- gcc/config/openbsd.h	(revision 151882)
+++ gcc/config/openbsd.h	(working copy)
@@ -84,6 +84,24 @@ along with GCC; see the file COPYING3.  If not see
     }						\
   while (0)
 
+/* TARGET_OS_CPP_BUILTINS() common to all OpenBSD ELF targets.  */
+#define OPENBSD_OS_CPP_BUILTINS_ELF()		\
+  do						\
+    {						\
+      OPENBSD_OS_CPP_BUILTINS();		\
+      builtin_define ("__ELF__");		\
+    }						\
+while (0)
+
+/* TARGET_OS_CPP_BUILTINS() common to all LP64 OpenBSD targets.  */
+#define OPENBSD_OS_CPP_BUILTINS_LP64()		\
+  do						\
+    {						\
+      builtin_define ("_LP64");			\
+      builtin_define ("__LP64__");		\
+    }						\
+  while (0)
+
 /* CPP_SPEC appropriate for OpenBSD. We deal with -posix and -pthread.
    XXX the way threads are handled currently is not very satisfying,
    since all code must be compiled with -pthread to work. 
@@ -95,16 +113,9 @@ along with GCC; see the file COPYING3.  If not see
 #define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
 #endif
 
-/* LIB_SPEC appropriate for OpenBSD.  */
-#ifdef HAS_LIBC_R
-/*   -lc(_r)?(_p)?, select _r for threads, and _p for p or pg.  */
-# define OBSD_LIB_SPEC "%{!shared:-lc%{pthread:_r}%{p:_p}%{!p:%{pg:_p}}}"
-#else
-/* Include -lpthread if -pthread is specified on the command line. */
-# define OBSD_LIB_SPEC "%{!shared:%{pthread:-lpthread%{p:_p}%{!p:%{pg:_p}}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}"
-#endif
+#undef LIB_SPEC
+#define LIB_SPEC OBSD_LIB_SPEC
 
-
 #ifndef OBSD_HAS_CORRECT_SPECS
 
 #ifndef OBSD_NO_DYNAMIC_LIBRARIES
@@ -128,15 +139,11 @@ along with GCC; see the file COPYING3.  If not see
 /* Since we use gas, stdin -> - is a good idea.  */
 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
 
-/* LINK_SPEC appropriate for OpenBSD.  Support for GCC options 
-   -static, -assert, and -nostdlib.  */
-#undef LINK_SPEC
-#ifdef OBSD_NO_DYNAMIC_LIBRARIES
-#define LINK_SPEC \
-  "%{g:%{!nostdlib:-L/usr/lib/debug}} %{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{assert*}"
-#else
-#define LINK_SPEC \
-  "%{g:%{!nostdlib:-L/usr/lib/debug}} %{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}}} %{shared:-Bshareable -x} -dc -dp %{R*} %{static:-Bstatic} %{assert*}"
+#undef LIB_SPEC
+#define LIB_SPEC OBSD_LIB_SPEC
+
+#if defined(HAVE_LD_EH_FRAME_HDR)
+#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
 #endif
 
 #undef LIB_SPEC
@@ -281,10 +288,6 @@ do {									 \
 /* Storage layout.  */
 
 
-/* Otherwise, since we support weak, gthr.h erroneously tries to use
-   #pragma weak.  */
-#define GTHREAD_USE_WEAK 0
-
 /* bug work around: we don't want to support #pragma weak, but the current
    code layout needs HANDLE_PRAGMA_WEAK asserted for __attribute((weak)) to
    work.  On the other hand, we don't define HANDLE_PRAGMA_WEAK directly,
Index: gcc/config/vax/openbsd.h
===================================================================
--- gcc/config/vax/openbsd.h	(revision 151882)
+++ gcc/config/vax/openbsd.h	(working copy)
@@ -33,13 +33,16 @@ along with GCC; see the file COPYING3.  If not see
 
 /* This must agree with <machine/ansi.h>  */
 #undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
+#define SIZE_TYPE "long unsigned int"
 
 #undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
+#define PTRDIFF_TYPE "long int"
 
 #undef WCHAR_TYPE
 #define WCHAR_TYPE "int"
 
 #undef WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 32
+
+#undef WINT_TYPE
+#define WINT_TYPE "int"



More information about the Gcc-patches mailing list