I've invested some time into adding the mips64(el) backend. It gets
quite far (xgcc seems to be fine), but then our ld takes a dump:

/usr/bin/ld: not enough GOT space for local GOT entries
/usr/bin/ld: BFD 2.15 internal error, aborting at /usr/src/gnu/usr.bin/binutils
 /bfd/elfxx-mips.c line 6483 in _bfd_mips_elf_relocate_section

/usr/bin/ld: Please report this bug.

Log: http://www.tmux.org/~tobiasu/tmp/gcc48-mips64-build.txt

Others have run into this, and it's possibly fixed in newer binutils,
but I have not been able to make sense of the BFD guts enough to fix ld.


Question is, should I commit this in its current form so others can try
their luck? I'm pretty sure this patch is 95% there.


Untested on mips64el, but I don't expect wonders...

diff --git a/lang/gcc/4.8/Makefile b/lang/gcc/4.8/Makefile
index b528088..2b6fb4a 100644
--- a/lang/gcc/4.8/Makefile
+++ b/lang/gcc/4.8/Makefile
@@ -1,6 +1,9 @@
 # $OpenBSD: Makefile,v 1.33 2014/03/30 19:30:28 naddy Exp $
 
-ONLY_FOR_ARCHS = alpha amd64 i386 powerpc sparc64
+BROKEN-mips64 = ld: not enough GOT space for local GOT entries
+BROKEN-mips64el = ld: not enough GOT space for local GOT entries
+
+ONLY_FOR_ARCHS = alpha amd64 i386 powerpc sparc64 mips64 mips64el
 DPB_PROPERTIES = parallel
 
 V = 4.8.2
diff --git a/lang/gcc/4.8/patches/patch-gcc_config_gcc 
b/lang/gcc/4.8/patches/patch-gcc_config_gcc
index 310e4a4..50ad33a 100644
--- a/lang/gcc/4.8/patches/patch-gcc_config_gcc
+++ b/lang/gcc/4.8/patches/patch-gcc_config_gcc
@@ -1,6 +1,6 @@
 $OpenBSD: patch-gcc_config_gcc,v 1.5 2014/03/23 17:30:19 pascal Exp $
 --- gcc/config.gcc.orig        Thu Oct  3 02:47:24 2013
-+++ gcc/config.gcc     Sun Mar 23 18:03:05 2014
++++ gcc/config.gcc     Mon May  5 18:39:28 2014
 @@ -712,6 +712,14 @@ case ${target} in
        default_use_cxa_atexit=yes
        ;;
@@ -49,7 +49,26 @@ $OpenBSD: patch-gcc_config_gcc,v 1.5 2014/03/23 17:30:19 
pascal Exp $
        tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h"
        tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h 
i386/x86-64.h i386/openbsdelf.h"
        extra_options="${extra_options} openbsd.opt"
-@@ -1973,11 +1984,12 @@ picochip-*)
+@@ -1787,6 +1798,18 @@ mips*-*-netbsd*)                        # NetBSD/mips, 
either endian.
+       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-*-openbsd*)
++      set
++      tm_file="dbxelf.h elfos.h openbsd.h mips/mips.h mips/openbsd.h 
openbsd-libpthread.h"
++      tm_defines="MIPS_ISA_DEFAULT=3 MIPS_ABI_DEFAULT=ABI_64"
++      extra_options="${extra_options} openbsd.opt"
++      ;;
++mips64el-*-openbsd*)
++      set
++      tm_file="dbxelf.h elfos.h openbsd.h mips/mips.h mips/openbsd.h 
openbsd-libpthread.h"
++      tm_defines="MIPS_ISA_DEFAULT=3 MIPS_ABI_DEFAULT=ABI_64 
TARGET_ENDIAN_DEFAULT=0"
++      extra_options="${extra_options} openbsd.opt"
++      ;;
+ mips*-mti-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 mips/linux-common.h 
mips/mti-linux.h"
+       tmake_file="${tmake_file} mips/t-mti-linux"
+@@ -1973,11 +1996,12 @@ picochip-*)
        use_gcc_stdint=wrap
        tmake_file="picochip/t-picochip t-pnt16-warn"
          ;;
@@ -67,7 +86,7 @@ $OpenBSD: patch-gcc_config_gcc,v 1.5 2014/03/23 17:30:19 
pascal Exp $
  powerpc-*-darwin*)
        extra_options="${extra_options} rs6000/darwin.opt"
        case ${target} in
-@@ -2524,6 +2536,7 @@ sparc64-*-netbsd*)
+@@ -2524,6 +2548,7 @@ sparc64-*-netbsd*)
        tmake_file="${tmake_file} sparc/t-sparc sparc/t-netbsd64"
        ;;
  sparc64-*-openbsd*)
@@ -75,7 +94,7 @@ $OpenBSD: patch-gcc_config_gcc,v 1.5 2014/03/23 17:30:19 
pascal Exp $
        tm_file="sparc/openbsd1-64.h ${tm_file} dbxelf.h elfos.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} openbsd.opt"
-@@ -2710,6 +2723,12 @@ case ${target} in
+@@ -2710,6 +2735,12 @@ case ${target} in
      else
        arch=i386
      fi
diff --git a/lang/gcc/4.8/patches/patch-gcc_config_mips_mips_h 
b/lang/gcc/4.8/patches/patch-gcc_config_mips_mips_h
new file mode 100644
index 0000000..2a0c7d7
--- /dev/null
+++ b/lang/gcc/4.8/patches/patch-gcc_config_mips_mips_h
@@ -0,0 +1,13 @@
+$OpenBSD$
+--- gcc/config/mips/mips.h.orig        Fri May  2 13:26:58 2014
++++ gcc/config/mips/mips.h     Fri May  2 13:27:20 2014
+@@ -1175,7 +1175,9 @@ struct mips_cpu_info {
+ #define SUBTARGET_CPP_SPEC ""
+ #endif
+ 
++#ifndef CPP_SPEC
+ #define CPP_SPEC "%(subtarget_cpp_spec)"
++#endif
+ 
+ /* This macro defines names of additional specifications to put in the specs
+    that can be used in various specifications like CC1_SPEC.  Its definition
diff --git a/lang/gcc/4.8/patches/patch-gcc_config_mips_openbsd_h 
b/lang/gcc/4.8/patches/patch-gcc_config_mips_openbsd_h
new file mode 100644
index 0000000..7af3b28
--- /dev/null
+++ b/lang/gcc/4.8/patches/patch-gcc_config_mips_openbsd_h
@@ -0,0 +1,229 @@
+$OpenBSD$
+--- gcc/config/mips/openbsd.h.orig     Fri May  2 12:54:22 2014
++++ gcc/config/mips/openbsd.h  Sat May  3 03:53:05 2014
+@@ -0,0 +1,225 @@
++/* Configuration file for a mips64 OpenBSD target.
++   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
++   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 2, 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 COPYING.  If not, write to
++the Free Software Foundation, 51 Franklin Street, Fifth Floor,
++Boston, MA 02110-1301, USA.  */
++
++/* This must agree with <machine/_types.h> */
++#undef SIZE_TYPE
++#define SIZE_TYPE "long unsigned int"
++
++#undef PTRDIFF_TYPE
++#define PTRDIFF_TYPE "long int"
++
++#undef INTMAX_TYPE
++#define INTMAX_TYPE "long long int"
++
++#undef UINTMAX_TYPE
++#define UINTMAX_TYPE "long long unsigned int"
++
++#undef WCHAR_TYPE
++#define WCHAR_TYPE "int"
++
++#undef WCHAR_TYPE_SIZE
++#define WCHAR_TYPE_SIZE 32
++
++#if 0
++/* dropped in 2007 in 311f69621cc28f7a626407f55cf2d60392856ccf
++ * See also 2f14b1f9d493c8f64d5ff6b284bfe91ad8433d37 */
++
++/* If defined, a C expression whose value is a string containing the
++   assembler operation to identify the following data as
++   uninitialized global data.  If not defined, and neither
++   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
++   uninitialized global data will be output in the data section if
++   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
++   used.  */
++#define BSS_SECTION_ASM_OP    "\t.section\t.bss"
++
++#define ASM_OUTPUT_ALIGNED_BSS mips_output_aligned_bss
++#endif
++
++#undef ASM_DECLARE_OBJECT_NAME
++#define ASM_DECLARE_OBJECT_NAME mips_declare_object_name
++
++#undef MD_EXEC_PREFIX
++#undef MD_STARTFILE_PREFIX
++
++/* If we don't set MASK_ABICALLS, we can't default to PIC.  */
++#undef TARGET_DEFAULT
++#define TARGET_DEFAULT MASK_ABICALLS
++
++#define TARGET_OS_CPP_BUILTINS()                              \
++  do {                                                                \
++    OPENBSD_OS_CPP_BUILTINS();                                        \
++                                                              \
++    if (TARGET_64BIT)                                         \
++      builtin_define ("__mips64__");                          \
++                                                              \
++    if (TARGET_ABICALLS)                                      \
++      builtin_define ("__ABICALLS__");                                \
++                                                              \
++    if (mips_abi == ABI_EABI)                                 \
++      builtin_define ("__mips_eabi");                         \
++    else if (mips_abi == ABI_N32)                             \
++      builtin_define ("__mips_n32");                          \
++    else if (mips_abi == ABI_64)                              \
++      builtin_define ("__mips_n64");                          \
++    else if (mips_abi == ABI_O64)                             \
++      builtin_define ("__mips_o64");                          \
++                                                              \
++    if (mips_abi == ABI_N32)                                  \
++      {                                                               \
++        builtin_define ("_ABIN32=2");                         \
++        builtin_define ("_MIPS_SIM=_ABIN32");                 \
++        builtin_define ("_MIPS_SZLONG=32");                   \
++        builtin_define ("_MIPS_SZPTR=32");                    \
++      }                                                               \
++    else if (mips_abi == ABI_64)                              \
++      {                                                               \
++        builtin_define ("_ABI64=3");                          \
++        builtin_define ("_MIPS_SIM=_ABI64");                  \
++        builtin_define ("_MIPS_SZLONG=64");                   \
++        builtin_define ("_MIPS_SZPTR=64");                    \
++      }                                                               \
++    else                                                      \
++      {                                                               \
++      builtin_define ("_ABIO32=1");                           \
++      builtin_define ("_MIPS_SIM=_ABIO32");                   \
++        builtin_define ("_MIPS_SZLONG=32");                   \
++        builtin_define ("_MIPS_SZPTR=32");                    \
++      }                                                               \
++    if (TARGET_FLOAT64)                                               \
++      builtin_define ("_MIPS_FPSET=32");                      \
++    else                                                      \
++      builtin_define ("_MIPS_FPSET=16");                      \
++                                                              \
++    builtin_define ("_MIPS_SZINT=32");                                \
++  } while (0)
++
++#undef SUBTARGET_CPP_SPEC
++#define SUBTARGET_CPP_SPEC OBSD_CPP_SPEC
++
++/* A standard GNU/Linux mapping.  On most targets, it is included in
++   CC1_SPEC itself by config/linux.h, but mips.h overrides CC1_SPEC
++   and provides this hook instead.  */
++#undef SUBTARGET_CC1_SPEC
++#define SUBTARGET_CC1_SPEC "%{profile:-p}"
++
++/* From iris5.h */
++/* -G is incompatible with -KPIC which is the default, so only allow objects
++   in the small data section if the user explicitly asks for it.  */
++#undef MIPS_DEFAULT_GVALUE
++#define MIPS_DEFAULT_GVALUE 0
++
++/* Borrowed from sparc/linux.h */
++#undef LINK_SPEC
++#define LINK_SPEC \
++  "%(endian_spec) \
++   %{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
++   %{shared:-shared} %{R*} \
++   %{static:-Bstatic} \
++   %{!static:-Bdynamic} \
++   %{rdynamic:-export-dynamic} \
++   %{assert*} \
++   %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
++
++/* As an elf system, we need crtbegin/crtend stuff.  */
++#undef STARTFILE_SPEC
++#define STARTFILE_SPEC "\
++        %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} %{!p:crt0%O%s}} \
++        crtbegin%O%s} %{shared:crtbeginS%O%s}"
++#undef ENDFILE_SPEC
++#define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
++
++#undef SUBTARGET_ASM_SPEC
++#define SUBTARGET_ASM_SPEC "%{mabi=64: -64} %{!mno-abicalls:-KPIC}"
++
++/* The MIPS assembler has different syntax for .set. We set it to
++   .dummy to trap any errors.  */
++#undef SET_ASM_OP
++#define SET_ASM_OP "\t.dummy\t"
++
++#undef ASM_OUTPUT_DEF
++#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                            \
++ do {                                                                 \
++      fputc ( '\t', FILE);                                            \
++      assemble_name (FILE, LABEL1);                                   \
++      fputs ( " = ", FILE);                                           \
++      assemble_name (FILE, LABEL2);                                   \
++      fputc ( '\n', FILE);                                            \
++ } while (0)
++
++
++#if 0
++gone with a8cceccd90827cb0920c0af1ed823e37d8d72e2a
++
++#undef ASM_DECLARE_FUNCTION_NAME
++#define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                 \
++  do {                                                                        
\
++    if (!flag_inhibit_size_directive)                                 \
++      {                                                                       
\
++      fputs ("\t.ent\t", STREAM);                                     \
++      assemble_name (STREAM, NAME);                                   \
++      putc ('\n', STREAM);                                            \
++      }                                                                       
\
++    ASM_OUTPUT_TYPE_DIRECTIVE (STREAM, NAME, "function");             \
++    assemble_name (STREAM, NAME);                                     \
++    fputs (":\n", STREAM);                                            \
++  } while (0)
++
++#undef ASM_DECLARE_FUNCTION_SIZE
++#define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                 \
++  do {                                                                        
\
++    if (!flag_inhibit_size_directive)                                 \
++      {                                                                       
\
++      fputs ("\t.end\t", STREAM);                                     \
++      assemble_name (STREAM, NAME);                                   \
++      putc ('\n', STREAM);                                            \
++      }                                                                       
\
++  } while (0)
++
++/* Tell function_prologue in mips.c that we have already output the .ent/.end
++   pseudo-ops.  */
++#undef FUNCTION_NAME_ALREADY_DECLARED
++#define FUNCTION_NAME_ALREADY_DECLARED 1
++#endif
++
++#undef LOCAL_LABEL_PREFIX
++#define LOCAL_LABEL_PREFIX    "."
++
++/* The glibc _mcount stub will save $v0 for us.  Don't mess with saving
++   it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the
++   presence of $gp-relative calls.  */
++#undef ASM_OUTPUT_REG_PUSH
++#undef ASM_OUTPUT_REG_POP
++
++#undef LIB_SPEC
++#define LIB_SPEC OBSD_LIB_SPEC
++
++/* #undef ENABLE_EXECUTE_STACK */
++
++/* Default to -mfix-r4000 -mfix-r4400 when compiling big endian.  */
++#undef SUBTARGET_OVERRIDE_OPTIONS
++#define SUBTARGET_OVERRIDE_OPTIONS                                    \
++  do {                                                                        
\
++    if (TARGET_BIG_ENDIAN)                                            \
++      {                                                                       
\
++      target_flags |= MASK_FIX_R4000 | MASK_FIX_R4400;                \
++      }                                                                       
\
++  } while (0)
diff --git a/lang/gcc/4.8/patches/patch-libgcc_config_host 
b/lang/gcc/4.8/patches/patch-libgcc_config_host
index 437b2f8..441f287 100644
--- a/lang/gcc/4.8/patches/patch-libgcc_config_host
+++ b/lang/gcc/4.8/patches/patch-libgcc_config_host
@@ -1,13 +1,26 @@
 $OpenBSD: patch-libgcc_config_host,v 1.2 2013/12/02 22:34:55 pascal Exp $
 --- libgcc/config.host.orig    Tue Jul  9 23:35:57 2013
-+++ libgcc/config.host Wed Oct 16 18:56:50 2013
-@@ -833,6 +833,9 @@ powerpc*-*-freebsd*)
++++ libgcc/config.host Mon May  5 18:40:08 2014
+@@ -720,6 +720,12 @@ microblaze*-*-elf)
+       ;;
+ mips*-*-netbsd*)                      # NetBSD/mips, either endian.
+       ;;
++mips64-*-openbsd*)
++      set
++      ;;
++mips64el-*-openbsd*)
++      set
++      ;;
+ mips*-*-linux*)                               # Linux MIPS, either endian.
+       extra_parts="$extra_parts crtfastmath.o"
+       tmake_file="${tmake_file} t-crtfm mips/t-mips16"
+@@ -832,6 +838,9 @@ powerpc*-*-freebsd*)
+       ;;
  powerpc-*-netbsd*)
        tmake_file="$tmake_file rs6000/t-netbsd rs6000/t-crtstuff"
-       ;;
++      ;;
 +powerpc-*-openbsd*)
 +      tmake_file="$tmake_file rs6000/t-crtstuff"
-+      ;;
+       ;;
  powerpc-*-eabispe*)
        tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr 
rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
-       extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o 
crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
-- 
1.9.2

Reply via email to