⛏️ index : buildtools.git

author Adrien Destugues <pulkomandy@gmail.com> 2019-02-17 13:40:36.0 +01:00:00
committer waddlesplash <waddlesplash@gmail.com> 2019-02-19 18:28:17.0 +00:00:00
commit
198e0fde5e533da0b2187c71abecb3e6cb1e1adf [patch]
tree
61fd2fc0ba0768429e6c756a3b4887f444449087
parent
b3407e33b36bf1bfaee2c97739986ab8afb9d106
download
198e0fde5e533da0b2187c71abecb3e6cb1e1adf.tar.gz

haiku: Get sparc buildtools going

- If kallisti5 is having fun with RISC-V, why can't I too?
- Gets as far as complaining we don't have a libsolv package in
  non-bootstrap builds

Change-Id: I0bb2b632d8f9007d5ad130f8cfddda36787050fc
Reviewed-on: https://review.haiku-os.org/c/1060
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>

Diff

 binutils/bfd/config.bfd      |   2 +-
 binutils/gas/configure.tgt   |   1 +
 binutils/ld/configure.tgt    |   1 +
 gcc/gcc/config.gcc           |   5 +++++
 gcc/libgcc/config.host       |   2 ++
 gcc/gcc/config/sparc/haiku.h | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/sparc/t-haiku |   5 +++++
 7 files changed, 237 insertions(+), 1 deletion(-)

diff --git a/binutils/bfd/config.bfd b/binutils/bfd/config.bfd
index ee202b2..9945105 100644
--- a/binutils/bfd/config.bfd
+++ a/binutils/bfd/config.bfd
@@ -1724,7 +1724,7 @@
    targ_selvecs="sparc_elf32_vec sparc_aout_linux_vec sparc_aout_sunos_be_vec"
    want64=true
    ;;
  sparc64-*-elf* | sparc64-*-rtems* )
  sparc64-*-elf* | sparc64-*-rtems* | sparc64-*-haiku*)
    targ_defvec=sparc_elf64_vec
    targ_selvecs=sparc_elf32_vec
    want64=true
diff --git a/binutils/gas/configure.tgt b/binutils/gas/configure.tgt
index 4a322f1..2741999 100644
--- a/binutils/gas/configure.tgt
+++ a/binutils/gas/configure.tgt
@@ -433,6 +433,7 @@
  sh64-*-elf*)				fmt=elf ;;

  sparc64-*-rtems*)			fmt=elf ;;
  sparc-*-haiku*)			fmt=elf em=haiku ;;
  sparc-*-rtems*)			fmt=elf ;;
  sparc-*-sunos4*)			fmt=aout em=sun3 ;;
  sparc-*-aout)				fmt=aout em=sparcaout ;;
diff --git a/binutils/ld/configure.tgt b/binutils/ld/configure.tgt
index cb0cac9..32ed6f8 100644
--- a/binutils/ld/configure.tgt
+++ a/binutils/ld/configure.tgt
@@ -769,6 +769,7 @@
sparc64-*-aout*)	targ_emul=sparcaout ;;
sparc64-*-elf*)		targ_emul=elf64_sparc ;;
sparc64-*-rtems*)	targ_emul=elf64_sparc ;;
sparc64-*-haiku*)	targ_emul=elf64_sparc ;;
sparc-sun-sunos4*) 	targ_emul=sun4 ;;
sparclite*-*-elf)	targ_emul=elf32_sparc ;;
sparclite*-*-coff)	targ_emul=coff_sparc ;;
diff --git a/gcc/gcc/config.gcc b/gcc/gcc/config.gcc
index 6aa1cf5..071b671 100644
--- a/gcc/gcc/config.gcc
+++ a/gcc/gcc/config.gcc
@@ -2939,6 +2939,11 @@
	extra_options="${extra_options}"
	tmake_file="${tmake_file} sparc/t-sparc sparc/t-rtems-64"
	;;
sparc64-*-haiku*)
	tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h sparc/sp64-elf.h sparc/haiku.h haiku.h"
	extra_options="${extra_options}"
	tmake_file="${tmake_file} t-haiku sparc/t-sparc sparc/t-haiku"
	;;
sparc64-*-linux*)
	tm_file="sparc/biarch64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h gnu-user.h linux.h glibc-stdint.h sparc/default64.h sparc/linux64.h sparc/tso.h"
	extra_options="${extra_options} sparc/long-double-switch.opt"
diff --git a/gcc/libgcc/config.host b/gcc/libgcc/config.host
index 8a7595a..ba143bf 100644
--- a/gcc/libgcc/config.host
+++ a/gcc/libgcc/config.host
@@ -1276,6 +1276,8 @@
	fi
	md_unwind_header=sparc/linux-unwind.h
	;;
sparc64-*-haiku*)
	;;
sparc64-*-netbsd*)
	;;
spu-*-elf*)
diff --git a/gcc/gcc/config/sparc/haiku.h b/gcc/gcc/config/sparc/haiku.h
new file mode 100644
index 0000000..2bd3e47 100644
--- /dev/null
+++ a/gcc/gcc/config/sparc/haiku.h
@@ -1,0 +1,222 @@
/* Definitions of target machine for GCC, for ELF on Haiku/sparc64.
   Copyright (C) 2002-2017 Free Software Foundation, Inc.
   Contributed by Matthew Green (mrg@eterna.com.au).

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 TARGET_OS_CPP_BUILTINS()			\
  do							\
    {							\
      builtin_define ("__HAIKU__");					\
      if (TARGET_ARCH64)				\
	{						\
	  builtin_define ("__sparc64__");		\
	  builtin_define ("__sparc_v9__");		\
	  builtin_define ("__sparcv9");			\
	}						\
      else						\
	builtin_define ("__sparc");			\
      builtin_define ("__sparc__");			\
    }							\
  while (0)

/* Provide a LINK_SPEC appropriate for Haiku.  Here we provide support
   for the special GCC options -static and -shared, which allow us to
   link things in one of these three modes by applying the appropriate
   combinations of options at link-time.  */

#if TARGET_64BIT_DEFAULT

#define SPEC_32 "m32"
#define SPEC_64 "!m32"
#else
#define SPEC_32 "!m64"
#define SPEC_64 "m64"
#endif

#undef	LINK_SPEC
#define LINK_SPEC "%{" SPEC_64 ":-m elf_sparc64_haiku} %{" SPEC_32 ":-m elf_sparc_haiku} \
	%{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"
/* SIZE_TYPE and PTRDIFF_TYPE are wrong from sparc/sparc.h.  */
#undef SIZE_TYPE
#define SIZE_TYPE "long unsigned int"

#undef PTRDIFF_TYPE
#define PTRDIFF_TYPE "long int"

/* 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  LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX  "."

/* 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 USER_LABEL_PREFIX
#define USER_LABEL_PREFIX ""

#undef ASM_SPEC
#define ASM_SPEC "%{" FPIE_OR_FPIC_SPEC ":-K PIC} \
%(asm_cpu) %(asm_arch) %(asm_relax)"

#undef STDC_0_IN_SYSTEM_HEADERS

#define HAVE_ENABLE_EXECUTE_STACK

/* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
   description, allowing one to build 32-bit or 64-bit applications
   on either.  We define the sparc & sparc64 versions of things,
   occasionally a neutral version (should be the same as "netbsd-elf.h")
   and then based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
   we choose the correct version.  */

/* We use the default NetBSD ELF STARTFILE_SPEC and ENDFILE_SPEC
   definitions, even for the SPARC_BI_ARCH compiler, because NetBSD does
   not have a default place to find these libraries..  */

/* TARGET_CPU_DEFAULT is set in Makefile.in.  We test for 64-bit default
   platform here.  */

#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
/* A 64 bit v9 compiler with stack-bias,
   in a Medium/Low code model environment.  */

#undef TARGET_DEFAULT
#define TARGET_DEFAULT \
  (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
   + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)

#undef SPARC_DEFAULT_CMODEL
#define SPARC_DEFAULT_CMODEL CM_MEDANY

#endif

/* CC1_SPEC for NetBSD/sparc.  */
#define CC1_SPEC32 \
 "%{m32:%{m64:%emay not use both -m32 and -m64}} \

  %{m64: \
    -mptr64 -mstack-bias -mno-v8plus -mlong-double-128 \
    %{!mcpu*:%{!mv8plus:-mcpu=ultrasparc}} \
    %{!mno-vis:%{!mcpu=v9:-mvis}} \
    %{p:-mcmodel=medlow} \
    %{pg:-mcmodel=medlow}}"

#define CC1_SPEC64 \
 "%{m32:%{m64:%emay not use both -m32 and -m64}} \

  %{m32: \
    -mptr32 -mno-stack-bias \
    %{!mlong-double-128:-mlong-double-64} \
    %{!mcpu*:%{!mv8plus:-mcpu=cypress}}} \
  %{!m32: \
    %{p:-mcmodel=medlow} \
    %{pg:-mcmodel=medlow}}"

/* Make sure we use the right output format.  Pick a default and then
   make sure -m32/-m64 switch to the right one.  */

#define LINK_ARCH32_SPEC "-m elf32_sparc"

#define LINK_ARCH64_SPEC "-m elf64_sparc"

#define LINK_ARCH_SPEC \
 "%{m32:%(link_arch32)} \

  %{m64:%(link_arch64)} \
  %{!m32:%{!m64:%(link_arch_default)}}"

#undef LINK_SPEC
#define LINK_SPEC \
 "%(link_arch) \

  %{!mno-relax:%{!r:-relax}} \
  %(netbsd_link_spec)"

#define NETBSD_ENTRY_POINT "__start"

#if DEFAULT_ARCH32_P

#define LINK_ARCH_DEFAULT_SPEC LINK_ARCH32_SPEC
#else
#define LINK_ARCH_DEFAULT_SPEC LINK_ARCH64_SPEC
#endif

/* What extra spec entries do we need?  */
#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
  { "link_arch32",		LINK_ARCH32_SPEC }, \
  { "link_arch64",		LINK_ARCH64_SPEC }, \
  { "link_arch_default",	LINK_ARCH_DEFAULT_SPEC }, \
  { "link_arch",		LINK_ARCH_SPEC },


/* Build a compiler that supports -m32 and -m64?  */

#ifdef SPARC_BI_ARCH

#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)

#undef  CC1_SPEC
#if DEFAULT_ARCH32_P

#define CC1_SPEC CC1_SPEC32
#else
#define CC1_SPEC CC1_SPEC64
#endif

#if DEFAULT_ARCH32_P

#define MULTILIB_DEFAULTS { "m32" }
#else
#define MULTILIB_DEFAULTS { "m64" }
#endif

#else	/* SPARC_BI_ARCH */

#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc

#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE 128

#undef  CC1_SPEC
#define CC1_SPEC CC1_SPEC64

#else	/* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
	|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */

/* A 32-bit only compiler.  NetBSD don't support 128 bit `long double'
   for 32-bit code, unlike Solaris.  */

#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE 64

#undef  CC1_SPEC
#define CC1_SPEC CC1_SPEC32

#endif	/* TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
	|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */

#endif	/* SPARC_BI_ARCH */

/* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP
diff --git a/gcc/gcc/config/sparc/t-haiku b/gcc/gcc/config/sparc/t-haiku
new file mode 100644
index 0000000..a8d212d 100644
--- /dev/null
+++ a/gcc/gcc/config/sparc/t-haiku
@@ -1,0 +1,5 @@
# Disable multilib for now, as we don't intend to support SPARC32.
#MULTILIB_OPTIONS = m32/m64
#MULTILIB_DIRNAMES = 32 64
#MULTILIB_MATCHES =