This patch adds support for GNU/kFreeBSD systems running on MIPS.

-- 
Robert Millan
2011-07-22  Robert Millan  <r...@gnu.org>

	Support for GNU/kFreeBSD systems running on MIPS.

	* config.gcc: Detect mips*-*-kfreebsd*-gnu.
	* config.host: Likewise.
	* config/mips/kfreebsd-gnu.h: New file.
	* config/mips/kfreebsd-gnu64.h: New file.
	* config/mips/gnu-user.h: Restrict `-march=native' support to GNU/Linux.

Index: libgcc/config.host
===================================================================
--- libgcc/config.host	(revision 176595)
+++ libgcc/config.host	(working copy)
@@ -478,6 +478,14 @@
 	tmake_file="{$tmake_file} t-crtfm"
 	md_unwind_header=mips/linux-unwind.h
 	;;
+mips64*-*-kfreebsd*-gnu)
+	extra_parts="$extra_parts crtfastmath.o"
+	tmake_file="{$tmake_file} t-crtfm"
+	;;
+mips*-*-kfreebsd*-gnu)			# GNU/kFreeBSD MIPS, either endian.
+	extra_parts="$extra_parts crtfastmath.o"
+	tmake_file="{$tmake_file} t-crtfm"
+	;;
 mips*-*-openbsd*)
 	;;
 mipsisa32-*-elf* | mipsisa32el-*-elf*)
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 176595)
+++ gcc/config.gcc	(working copy)
@@ -1819,20 +1819,28 @@
 	tm_file="elfos.h ${tm_file} mips/elf.h netbsd.h netbsd-elf.h mips/netbsd.h"
 	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
 	;;
-mips64*-*-linux* | mipsisa64*-*-linux*)
-	tm_file="dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/gnu-user64.h mips/linux64.h"
+mips64*-*-linux* | mipsisa64*-*-linux* | mips64*-*-kfreebsd*-gnu | mipsisa64*-*-kfreebsd*-gnu)
+	tm_file="dbxelf.h elfos.h gnu-user.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/gnu-user64.h"
 	tmake_file="${tmake_file} mips/t-linux64 mips/t-libgcc-mips16"
 	tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_N32"
+	case ${target_os} in
+		linux*)
+			tm_file="${tm_file} linux.h mips/linux64.h"
+			;;
+		kfreebsd*-gnu)
+			tm_file="${tm_file} kfreebsd-gnu.h mips/kfreebsd-gnu64.h"
+			;;
+	esac
 	case ${target} in
-		mips64el-st-linux-gnu)
+		mips64el-st-*)
 			tm_file="${tm_file} mips/st.h"
 			tmake_file="${tmake_file} mips/t-st"
 			;;
-		mips64octeon*-*-linux*)
+		mips64octeon*-*-*)
 			tm_defines="${tm_defines} MIPS_CPU_STRING_DEFAULT=\\\"octeon\\\""
 			target_cpu_default=MASK_SOFT_FLOAT_ABI
 			;;
-		mipsisa64r2*-*-linux*)
+		mipsisa64r2*-*-*)
 			tm_defines="${tm_defines} MIPS_ISA_DEFAULT=65"
 			;;
 	esac
@@ -1841,11 +1849,27 @@
 	gas=yes
 	test x$with_llsc != x || with_llsc=yes
 	;;
-mips*-*-linux*)				# Linux MIPS, either endian.
-        tm_file="dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/linux.h"
+mips*-*-linux* | mips*-*-kfreebsd*-gnu)			# GNU/* MIPS, either endian.
+        tm_file="dbxelf.h elfos.h gnu-user.h glibc-stdint.h ${tm_file} mips/gnu-user.h"
 	tmake_file="${tmake_file} mips/t-libgcc-mips16"
+	case ${target_os} in
+		linux*)
+			tm_file="${tm_file} linux.h mips/linux.h"
+			;;
+		kfreebsd*-gnu)
+			tm_file="${tm_file} kfreebsd-gnu.h mips/kfreebsd-gnu.h"
+			;;
+	esac
 	if test x$enable_targets = xall; then
-		tm_file="${tm_file} mips/gnu-user64.h mips/linux64.h"
+		tm_file="${tm_file} mips/gnu-user64.h"
+		case ${target_os} in
+			linux*)
+				tm_file="${tm_file} mips/linux64.h"
+				;;
+			kfreebsd*-gnu)
+				tm_file="${tm_file} mips/kfreebsd-gnu64.h"
+				;;
+		esac
 		tmake_file="${tmake_file} mips/t-linux64"
 		tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_32"
 	fi
Index: gcc/config/mips/gnu-user.h
===================================================================
--- gcc/config/mips/gnu-user.h	(revision 176595)
+++ gcc/config/mips/gnu-user.h	(working copy)
@@ -106,8 +106,8 @@
 #endif
 
 /* -march=native handling only makes sense with compiler running on
-   a MIPS chip.  */
-#if defined(__mips__)
+   a MIPS chip.  Also, for now only Linux targets are supported.  */
+#if defined(__mips__) && defined(__linux__)
 extern const char *host_detect_local_cpu (int argc, const char **argv);
 # define EXTRA_SPEC_FUNCTIONS \
   { "local_cpu_detect", host_detect_local_cpu },
Index: gcc/config/mips/kfreebsd-gnu64.h
===================================================================
--- gcc/config/mips/kfreebsd-gnu64.h	(revision 0)
+++ gcc/config/mips/kfreebsd-gnu64.h	(revision 0)
@@ -0,0 +1,31 @@
+/* Definitions for MIPS running kFreeBSD-based GNU systems with ELF format
+   using n32/64 abi.
+   Copyright (C) 2011
+   Free Software Foundation, Inc.
+   Contributed by Robert Millan.
+
+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 GNU_USER_LINK_EMULATION32	"elf32%{EB:b}%{EL:l}tsmip_fbsd"
+#define GNU_USER_LINK_EMULATION64	"elf64%{EB:b}%{EL:l}tsmip_fbsd"
+#define GNU_USER_LINK_EMULATIONN32	"elf32%{EB:b}%{EL:l}tsmipn32_fbsd"
+
+#define GLIBC_DYNAMIC_LINKER32		"/lib/ld.so.1"
+#define GLIBC_DYNAMIC_LINKER64		"/lib64/ld.so.1"
+#define GLIBC_DYNAMIC_LINKERN32		"/lib32/ld.so.1"
+
+#define GNU_USER_DYNAMIC_LINKERN32	GLIBC_DYNAMIC_LINKERN32
Index: gcc/config/mips/kfreebsd-gnu.h
===================================================================
--- gcc/config/mips/kfreebsd-gnu.h	(revision 0)
+++ gcc/config/mips/kfreebsd-gnu.h	(revision 0)
@@ -0,0 +1,22 @@
+/* Definitions for MIPS running kFreeBSD-based GNU systems with ELF format
+   Copyright (C) 2011
+   Free Software Foundation, Inc.
+   Contributed by Robert Millan.
+
+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 GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"

Reply via email to