⛏️ index : buildtools.git

author Augustin Cavalier <waddlesplash@gmail.com> 2021-12-06 22:03:28.0 -05:00:00
committer Augustin Cavalier <waddlesplash@gmail.com> 2021-12-06 22:03:28.0 -05:00:00
commit
2b5dc2481eda4ce33720b2766f08871477f3df15 [patch]
tree
fc764c6917563688fee5f2d4b82d7f21e954cb09
parent
a2d83d7eebb1c122252fb0b6d230e396ad38d424
download
2b5dc2481eda4ce33720b2766f08871477f3df15.tar.gz

Merge our changes into GCC 11.2.



Diff

 gcc/config.rpath                                         |   2 ++
 gcc/configure                                            |  28 ++++++++++++++++++++++++++--
 gcc/configure.ac                                         |  14 +++++++++++++-
 gcc/libtool.m4                                           |  11 ++++-------
 gcc/gcc/Makefile.in                                      |  20 +++++++++++++++-----
 gcc/gcc/config.gcc                                       |  70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config.host                                      |  10 ++++++----
 gcc/gcc/configure                                        |  36 +++++++++++++++++++++++++++++++-----
 gcc/gcc/configure.ac                                     |  20 +++++++++++++++++++-
 gcc/include/filenames.h                                  |   4 ++++
 gcc/libatomic/configure                                  |  33 +++++++++++++++++++++++++--------
 gcc/libatomic/configure.ac                               |  24 +++++++++++++++---------
 gcc/libatomic/configure.tgt                              |   2 +-
 gcc/libcody/configure                                    |   2 +-
 gcc/libgcc/config.host                                   |  37 +++++++++++++++++++++++++++++++++++--
 gcc/libgcc/crtstuff.c                                    |   2 ++
 gcc/libgomp/configure                                    |  40 ++++++++++++++++++++++++++++------------
 gcc/libgomp/configure.ac                                 |  16 +++++++++++-----
 gcc/libstdc++-v3/configure                               |  99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/libstdc++-v3/configure.host                          |   5 ++++-
 gcc/libstdc++-v3/crossconfig.m4                          |  44 ++++++++++++++++++++++++++++++++++++++++++--
 gcc/gcc/config/haiku-protos.h                            |  21 +++++++++++++++++++++
 gcc/gcc/config/haiku-stdint.h                            |  55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/haiku.c                                   |  32 ++++++++++++++++++++++++++++++++
 gcc/gcc/config/haiku.h                                   | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/host-darwin.c                             |   2 ++
 gcc/gcc/config/t-haiku                                   |   9 +++++++++
 gcc/gcc/ginclude/stdarg.h                                |   2 +-
 gcc/gcc/ginclude/stddef.h                                |  10 +++++-----
 gcc/libgcc/config/t-haiku                                |   3 +++
 gcc/libstdc++-v3/libsupc++/tinfo.cc                      |   9 +++++++++
 gcc/gcc/config/aarch64/aarch64-haiku.h                   |  73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/aarch64/aarch64.h                         |   2 +-
 gcc/gcc/config/aarch64/t-aarch64-haiku                   |  21 +++++++++++++++++++++
 gcc/gcc/config/arm/haiku.h                               |  73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/arm/t-haiku                               |  21 +++++++++++++++++++++
 gcc/gcc/config/i386/haiku.h                              |  77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/i386/haiku64.h                            | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/i386/t-haiku64                            |  16 ++++++++++++++++
 gcc/gcc/config/m68k/haiku.h                              | 268 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/mips/haiku.h                              |  44 ++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/riscv/haiku.h                             |  57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/riscv/t-haiku                             |   4 ++++
 gcc/gcc/config/rs6000/haiku.h                            |  56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/sparc/haiku.h                             |  93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/sparc/t-haiku                             |   5 +++++
 gcc/libgcc/config/aarch64/haiku-unwind.h                 |  51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/libstdc++-v3/config/os/haiku/ctype_base.h            |  61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/libstdc++-v3/config/os/haiku/ctype_configure_char.cc |  99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/libstdc++-v3/config/os/haiku/ctype_inline.h          | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/libstdc++-v3/config/os/haiku/error_constants.h       | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/libstdc++-v3/config/os/haiku/os_defines.h            |  48 ++++++++++++++++++++++++++++++++++++++++++++++++
 52 files changed, 2352 insertions(+), 83 deletions(-)

diff --git a/gcc/config.rpath b/gcc/config.rpath
index 4dea759..5bcc5be 100755
--- a/gcc/config.rpath
+++ a/gcc/config.rpath
@@ -161,6 +161,8 @@
      ;;
    netbsd*)
      ;;
    haiku*)
      ;;
    solaris* | sysv5*)
      if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
        ld_shlibs=no
diff --git a/gcc/configure b/gcc/configure
index 504f641..97a67b2 100755
--- a/gcc/configure
+++ a/gcc/configure
@@ -756,6 +756,7 @@
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -922,6 +923,7 @@
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
@@ -1174,6 +1176,15 @@
  | -silent | --silent | --silen | --sile | --sil)
    silent=yes ;;

  -runstatedir | --runstatedir | --runstatedi | --runstated \
  | --runstate | --runstat | --runsta | --runst | --runs \
  | --run | --ru | --r)
    ac_prev=runstatedir ;;
  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
  | --run=* | --ru=* | --r=*)
    runstatedir=$ac_optarg ;;

  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
    ac_prev=sbindir ;;
  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1311,7 +1322,7 @@
for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
		datadir sysconfdir sharedstatedir localstatedir includedir \
		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
		libdir localedir mandir
		libdir localedir mandir runstatedir
do
  eval ac_val=\$$ac_var
  # Remove trailing slashes.
@@ -1471,6 +1482,7 @@
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -3108,6 +3120,9 @@
  i[3456789]86-*-msdosdjgpp*)
    noconfigdirs="$noconfigdirs tcl tk itcl"
    ;;
  *-*-haiku*)
    noconfigdirs="$noconfigdirs tk itcl libgui gdb"
    ;;
esac


@@ -3213,7 +3228,7 @@
	;;
    *-*-solaris2* | *-*-hpux11*)
	;;
    *-*-darwin* | *-*-aix*)
    *-*-darwin* | *-*-aix* | *-*-haiku*)
	;;
    nvptx*-*-* | amdgcn*-*-*)
	;;
@@ -3492,6 +3507,9 @@
    ;;
  *-*-darwin*)
    noconfigdirs="$noconfigdirs target-libffi"
    ;;
  *-*-haiku*)
    noconfigdirs="$noconfigdirs ${libgcj}"
    ;;
  *-*-netware*)
    noconfigdirs="$noconfigdirs target-libffi"
@@ -3702,6 +3720,9 @@
  *-*-freebsd*)
    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
    ;;
  *-*-haiku*)
    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
    ;;
  *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
    ;;
@@ -3765,6 +3786,9 @@
	&& test -f /usr/local/include/gmp.h; then
      with_gmp=/usr/local
    fi
    ;;
  *-*-haiku*)
    noconfigdirs="$noconfigdirs gdb target-libiberty"
    ;;
  *-*-kaos*)
    # Remove unsupported stuff on all kaOS configurations.
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 088e735..57861b2 100644
--- a/gcc/configure.ac
+++ a/gcc/configure.ac
@@ -420,6 +420,9 @@
  i[[3456789]]86-*-msdosdjgpp*)
    noconfigdirs="$noconfigdirs tcl tk itcl"
    ;;
  *-*-haiku*)
    noconfigdirs="$noconfigdirs tk itcl libgui gdb"
    ;;
esac


@@ -511,7 +514,7 @@
	;;
    *-*-solaris2* | *-*-hpux11*)
	;;
    *-*-darwin* | *-*-aix*)
    *-*-darwin* | *-*-aix* | *-*-haiku*)
	;;
    nvptx*-*-* | amdgcn*-*-*)
	;;
@@ -769,6 +772,9 @@
    ;;
  *-*-darwin*)
    noconfigdirs="$noconfigdirs target-libffi"
    ;;
  *-*-haiku*)
    noconfigdirs="$noconfigdirs ${libgcj}"
    ;;
  *-*-netware*)
    noconfigdirs="$noconfigdirs target-libffi"
@@ -976,6 +982,9 @@
  *-*-freebsd*)
    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
    ;;
  *-*-haiku*)
    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
    ;;
  *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
    ;;
@@ -1039,6 +1048,9 @@
	&& test -f /usr/local/include/gmp.h; then
      with_gmp=/usr/local
    fi
    ;;
  *-*-haiku*)
    noconfigdirs="$noconfigdirs gdb target-libiberty"
    ;;
  *-*-kaos*)
    # Remove unsupported stuff on all kaOS configurations.
diff --git a/gcc/libtool.m4 b/gcc/libtool.m4
index 17f8e5f..3afe21d 100644
--- a/gcc/libtool.m4
+++ a/gcc/libtool.m4
@@ -1724,7 +1724,7 @@
  lt_cv_dlopen_libs=

  case $host_os in
  beos*)
  beos* | haiku*)
    lt_cv_dlopen="load_add_on"
    lt_cv_dlopen_libs=
    lt_cv_dlopen_self=yes
@@ -2334,8 +2334,9 @@
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
  hardcode_into_libs=yes
  sys_lib_search_path_spec='/boot/system/non-packaged/develop/lib /boot/system/develop/lib'
  sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib'
  hardcode_into_libs=no
  ;;

hpux9* | hpux10* | hpux11*)
@@ -3623,8 +3624,6 @@
      ;;
    haiku*)
      # PIC is the default for Haiku.
      # The "-static" flag exists, but is broken.
      _LT_TAGVAR(lt_prog_compiler_static, $1)=
      ;;
    interix[[3-9]]*)
      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
@@ -3934,8 +3933,6 @@

    haiku*)
      # PIC is the default for Haiku.
      # The "-static" flag exists, but is broken.
      _LT_TAGVAR(lt_prog_compiler_static, $1)=
      ;;

    hpux*)
diff --git a/gcc/gcc/Makefile.in b/gcc/gcc/Makefile.in
index 8a5fb3f..11a1e63 100644
--- a/gcc/gcc/Makefile.in
+++ a/gcc/gcc/Makefile.in
@@ -106,6 +106,8 @@
build_libobjdir := $(toplevel_builddir)/$(build_libsubdir)
target_objdir := $(toplevel_builddir)/$(target_subdir)

HYBRID_SECONDARY = @HYBRID_SECONDARY@

# --------
# Defined vpaths
# --------
@@ -271,7 +273,7 @@
NO_PIE_FLAG = @NO_PIE_FLAG@

# We don't want to compile the compilers with -fPIE, it make PCH fail.
COMPILER += $(NO_PIE_CFLAGS)
#COMPILER += $(NO_PIE_CFLAGS)

# Link with -no-pie since we compile the compiler with -fno-PIE.
LINKER += $(NO_PIE_FLAG)
@@ -802,9 +804,9 @@
NO_PIE_FLAG_FOR_BUILD = @NO_PIE_FLAG_FOR_BUILD@
BUILD_CFLAGS= @BUILD_CFLAGS@ $(GENERATOR_CFLAGS) -DGENERATOR_FILE
BUILD_CXXFLAGS = @BUILD_CXXFLAGS@ $(GENERATOR_CFLAGS) -DGENERATOR_FILE
BUILD_NO_PIE_CFLAGS = @BUILD_NO_PIE_CFLAGS@
BUILD_CFLAGS += $(BUILD_NO_PIE_CFLAGS)
BUILD_CXXFLAGS += $(BUILD_NO_PIE_CFLAGS)
#BUILD_NO_PIE_CFLAGS = @BUILD_NO_PIE_CFLAGS@
#BUILD_CFLAGS += $(BUILD_NO_PIE_CFLAGS)
#BUILD_CXXFLAGS += $(BUILD_NO_PIE_CFLAGS)

# Native compiler that we use.  This may be C++ some day.
COMPILER_FOR_BUILD = $(CXX_FOR_BUILD)
@@ -2291,6 +2293,10 @@
  -DCONFIGURE_SPECS="\"@CONFIGURE_SPECS@\"" \
  -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
  -DNATIVE_SYSTEM_HEADER_DIR=\"$(NATIVE_SYSTEM_HEADER_DIR)\"
  
ifneq ($(HYBRID_SECONDARY),)
DRIVER_DEFINES += -DHYBRID_SECONDARY="\"$(HYBRID_SECONDARY)\""
endif

CFLAGS-gcc.o += $(DRIVER_DEFINES) -DBASEVER=$(BASEVER_s)
gcc.o: $(BASEVER)
@@ -2935,7 +2941,7 @@
genprog = $(genprogerr) check checksum match

# These programs need libs over and above what they get from the above list.
build/genautomata$(build_exeext) : BUILD_LIBS += -lm
build/genautomata$(build_exeext) : BUILD_LIBS += @build_math_library@

build/genrecog$(build_exeext) : build/hash-table.o build/inchash.o
build/gencfn-macros$(build_exeext) : build/hash-table.o build/vec.o \
@@ -3030,6 +3036,10 @@
  -DPREFIX=\"$(prefix)/\" \
  -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
  @TARGET_SYSTEM_ROOT_DEFINE@

ifneq ($(HYBRID_SECONDARY),)
PREPROCESSOR_DEFINES += -DHYBRID_SECONDARY="\"$(HYBRID_SECONDARY)\""
endif

CFLAGS-cppbuiltin.o += $(PREPROCESSOR_DEFINES) -DBASEVER=$(BASEVER_s)
cppbuiltin.o: $(BASEVER)
diff --git a/gcc/gcc/config.gcc b/gcc/gcc/config.gcc
index 357b0be..3d6f3e0 100644
--- a/gcc/gcc/config.gcc
+++ a/gcc/gcc/config.gcc
@@ -180,7 +180,7 @@
#			the --with-sysroot configure option or the
#			--sysroot command line option is used this
#			will be relative to the sysroot.
# target_type_format_char 
# target_type_format_char
# 			The default character to be used for formatting
#			the attribute in a
#			.type symbol_name, ${t_t_f_c}<property>
@@ -825,6 +825,21 @@
*-*-fuchsia*)
  native_system_header_dir=/include
  ;;
*-*-haiku*)
  # This is the generic ELF configuration of Haiku.  Later
  # machine-specific sections may refine and add to this
  # configuration.
  #
  gas=yes
  gnu_ld=yes
  tmake_file="t-slibgcc"
  case ${enable_threads} in
    "" | yes | posix) thread_file='posix' ;;
  esac
  default_use_cxa_atexit=yes
  tm_p_file="${tm_p_file} haiku-protos.h"
  extra_objs="${extra_objs} haiku.o"
  ;;
*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu | *-*-uclinuxfdpiceabi)
  extra_options="$extra_options gnu-user.opt"
  gas=yes
@@ -1132,6 +1147,12 @@
	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-netbsd.h"
	tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-netbsd"
	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
	;;
aarch64*-*-haiku*)
	gcc_cv_initfini_array=yes
	tm_file="${tm_file} dbxelf.h elfos.h haiku.h haiku-stdint.h"
	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-haiku.h"
	tmake_file="${tmake_file} t-haiku aarch64/t-aarch64 aarch64/t-aarch64-haiku"
	;;
aarch64*-*-linux*)
	tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h"
@@ -1302,6 +1323,16 @@
	armv6*) target_cpu_cname="arm1176jzf-s";;
	armv7*) target_cpu_cname="generic-armv7-a";;
	esac
	;;
arm*-*-haiku*)
	tmake_file="${tmake_file} t-haiku arm/t-arm arm/t-arm-elf arm/t-bpabi arm/t-haiku"
	tm_file="dbxelf.h elfos.h haiku.h arm/elf.h arm/bpabi.h arm/haiku.h haiku-stdint.h"
	# The BPABI long long divmod functions return a 128-bit value in
	# registers r0-r3.  Correctly modeling that requires the use of
	# TImode.
	need_64bit_hwint=yes
	default_use_cxa_atexit=yes
	tm_file="${tm_file} arm/aout.h arm/arm.h"
	;;
arm*-*-linux-* | arm*-*-uclinuxfdpiceabi)
	tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
@@ -1922,7 +1953,15 @@
	;;
x86_64-*-freebsd*)
	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${fbsd_tm_file} i386/x86-64.h i386/freebsd.h i386/freebsd64.h"
	;;
i[34567]86-*-haiku*)
	tmake_file="${tmake_file} t-haiku i386/t-crtpic"
	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h haiku.h i386/haiku.h haiku-stdint.h"
	;;
x86_64-*-haiku*)
	tmake_file="${tmake_file} t-haiku i386/t-haiku64"
	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h haiku.h i386/haiku64.h haiku-stdint.h"
	;;
i[34567]86-*-netbsdelf*)
	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${nbsd_tm_file} i386/netbsd-elf.h"
	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
@@ -2413,6 +2452,13 @@
	default_cf_cpu=5206
	tmake_file="${tmake_file} m68k/t-floatlib m68k/t-m68kbare m68k/t-crtstuff m68k/t-rtems m68k/t-mlibs"
	tm_file="${tm_file} m68k/m68k-none.h m68k/m68kelf.h dbxelf.h elfos.h m68k/m68kemb.h m68k/m68020-elf.h m68k/rtemself.h rtems.h newlib-stdint.h"
	tm_defines="${tm_defines} MOTOROLA=1"
	;;
m68k-*-haiku*)
	default_m68k_cpu=68020
	default_cf_cpu=5206
	tmake_file="${tmake_file} m68k/t-m68kbare m68k/t-crtstuff t-haiku" #??
	tm_file="${tm_file} dbxelf.h elfos.h haiku.h m68k/haiku.h"
	tm_defines="${tm_defines} MOTOROLA=1"
	;;
mcore-*-elf)
@@ -2466,6 +2512,13 @@
	cxx_target_objs="${cxx_target_objs} microblaze-c.o"
	tmake_file="${tmake_file} microblaze/t-microblaze"
        ;;
riscv*-*-haiku*)
	gcc_cv_initfini_array=yes
	tm_file="elfos.h haiku.h ${tm_file} riscv/haiku.h haiku-stdint.h"
	tmake_file="${tmake_file} t-haiku riscv/t-riscv riscv/t-haiku"
	gnu_ld=yes
	gas=yes
	;;
riscv*-*-linux*)
	tm_file="elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} riscv/linux.h"
	case "x${enable_multilib}" in
@@ -2551,6 +2604,11 @@
	with_arch_64="mips64r2"
	gnu_ld=yes
	gas=yes
	;;
mipsel-*-haiku*)
	target_cpu_default="MASK_ABICALLS"
	tm_file="elfos.h ${tm_file} haiku.h mips/haiku.h"
	tmake_file="${tmake_file} mips/t-elf t-haiku"
	;;
mips*-*-linux*)				# Linux MIPS, either endian.
	tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/linux.h mips/linux-common.h"
@@ -2976,6 +3034,11 @@
	extra_options="${extra_options} rs6000/sysv4.opt"
	tmake_file="rs6000/t-fprules rs6000/t-ppcgas rs6000/t-ppccomm"
	use_gcc_stdint=wrap
	;;
powerpc-*-haiku*)
	tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-ppcos rs6000/t-ppccomm t-haiku"
	tm_file="${tm_file} dbxelf.h elfos.h freebsd-spec.h rs6000/sysv4.h haiku.h rs6000/haiku.h haiku-stdint.h"
	extra_options="${extra_options} rs6000/sysv4.opt"
	;;
powerpc-*-rtems*)
	tm_file="rs6000/biarch64.h ${tm_file} dbxelf.h elfos.h gnu-user.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/rtems.h rtems.h"
@@ -3428,6 +3491,11 @@
	tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h sparc/sysv4.h sparc/sp64-elf.h sparc/rtemself.h rtems.h"
	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 haiku.h sparc/haiku.h haiku-stdint.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"
diff --git a/gcc/gcc/config.host b/gcc/gcc/config.host
index 0a02c33..4ab7ae6 100644
--- a/gcc/gcc/config.host
+++ a/gcc/gcc/config.host
@@ -99,7 +99,7 @@
esac

case ${host} in
  aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia*)
  aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia* | aarch64*-*-haiku*)
    case ${target} in
      aarch64*-*-*)
	host_extra_gcc_objs="driver-aarch64.o"
@@ -107,7 +107,7 @@
	;;
    esac
    ;;
  arm*-*-freebsd* | arm*-*-netbsd* | arm*-*-linux* | arm*-*-fuchsia*)
  arm*-*-freebsd* | arm*-*-netbsd* | arm*-*-linux* | arm*-*-fuchsia* | arm*-*-haiku*)
    case ${target} in
      arm*-*-*)
	host_extra_gcc_objs="driver-arm.o"
@@ -133,9 +133,11 @@
	;;
    esac
    ;;
  mips*-*-linux*)
  mips*-*-linux* \
  |  mips*-*-haiku*)
    case ${target} in
      mips*-*-linux*)
      mips*-*-linux* \
      |  mips*-*-haiku*)
	host_extra_gcc_objs="driver-native.o"
	host_xmake_file="${host_xmake_file} mips/x-native"
      ;;
diff --git a/gcc/gcc/configure b/gcc/gcc/configure
index 9b28369..c90e211 100755
--- a/gcc/gcc/configure
+++ a/gcc/gcc/configure
@@ -798,6 +798,7 @@
EXTRA_GCC_LIBS
GNAT_LIBEXC
COLLECT2_LIBS
build_math_library
CXXDEPMODE
DEPDIR
am__leading_dot
@@ -838,6 +839,7 @@
with_cpu
enable_multiarch
enable_multilib
HYBRID_SECONDARY
coverage_flags
valgrind_command
valgrind_path_defines
@@ -1815,6 +1817,8 @@
  --with-demangler-in-ld  try to use demangler in GNU ld
  --with-gnu-as           arrange to work with GNU as
  --with-as               arrange to use the specified as (full pathname)
  --with-hybrid_secondary specify the packaging architecture for building a
                          secondary compiler for a Haiku hybrid system
  --with-stabs            arrange to use stabs instead of host debug format
  --with-stack-clash-protection-guard-size=size
                          Set the default stack clash protection guard size
@@ -7559,6 +7563,17 @@
# Miscenalleous configure options
# -------------------------------

# handle --with-hybrid-secondary

# Check whether --with-hybrid_secondary was given.
if test "${with_hybrid_secondary+set}" = set; then :
  withval=$with_hybrid_secondary; HYBRID_SECONDARY=$withval
else
  HYBRID_SECONDARY=

fi


# With stabs

# Check whether --with-stabs was given.
@@ -9691,6 +9706,15 @@
# UNSORTED
# --------


# Configure -lm usage for host tools that need it
build_math_library="-lm"
case $build in
  *-*-haiku*)
    # no separate math library needed
    build_math_library=
    ;;
esac

# These libraries may be used by collect2.
# We may need a special search path to get them linked.
@@ -12593,7 +12617,7 @@
    # default
    target_thread_file='single'
    ;;
  aix | dce | lynx | mipssde | posix | rtems | \
  aix | dce | haiku | lynx | mipssde | posix | rtems | \
  single | tpf | vxworks | win32)
    target_thread_file=${enable_threads}
    ;;
@@ -18591,8 +18615,9 @@
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
  hardcode_into_libs=yes
  sys_lib_search_path_spec='/boot/system/non-packaged/develop/lib /boot/system/develop/lib'
  sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib'
  hardcode_into_libs=no
  ;;

hpux9* | hpux10* | hpux11*)
@@ -22246,8 +22271,9 @@
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
  hardcode_into_libs=yes
  sys_lib_search_path_spec='/boot/system/non-packaged/develop/lib /boot/system/develop/lib'
  sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib'
  hardcode_into_libs=no
  ;;

hpux9* | hpux10* | hpux11*)
diff --git a/gcc/gcc/configure.ac b/gcc/gcc/configure.ac
index 162e08c..a696688 100644
--- a/gcc/gcc/configure.ac
+++ a/gcc/gcc/configure.ac
@@ -814,6 +814,15 @@
# Miscenalleous configure options
# -------------------------------

# handle --with-hybrid-secondary
AC_ARG_WITH(hybrid_secondary,
  [AS_HELP_STRING([--with-hybrid_secondary],
                  [specify the packaging architecture for building a secondary compiler for a Haiku hybrid system])],
  [HYBRID_SECONDARY=$withval],
  [HYBRID_SECONDARY=]
)
AC_SUBST(HYBRID_SECONDARY)

# With stabs
AC_ARG_WITH(stabs,
[AS_HELP_STRING([--with-stabs],
@@ -1295,6 +1304,15 @@
# UNSORTED
# --------

# Configure -lm usage for host tools that need it
build_math_library="-lm"
case $build in
  *-*-haiku*)
    # no separate math library needed
    build_math_library=
    ;;
esac
AC_SUBST(build_math_library)

# These libraries may be used by collect2.
# We may need a special search path to get them linked.
@@ -1925,7 +1943,7 @@
    # default
    target_thread_file='single'
    ;;
  aix | dce | lynx | mipssde | posix | rtems | \
  aix | dce | haiku | lynx | mipssde | posix | rtems | \
  single | tpf | vxworks | win32)
    target_thread_file=${enable_threads}
    ;;
diff --git a/gcc/include/filenames.h b/gcc/include/filenames.h
index b3b85b2..911ac96 100644
--- a/gcc/include/filenames.h
+++ a/gcc/include/filenames.h
@@ -37,17 +37,21 @@
#  ifndef HAVE_DOS_BASED_FILE_SYSTEM
#    define HAVE_DOS_BASED_FILE_SYSTEM 1
#  endif
/*
#  ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
#    define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
#  endif
*/
#  define HAS_DRIVE_SPEC(f) HAS_DOS_DRIVE_SPEC (f)
#  define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
#  define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
#else /* not DOSish */
#  if defined(__APPLE__)

/*
#    ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
#      define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
#    endif
*/
#  endif /* __APPLE__ */
#  define HAS_DRIVE_SPEC(f) (0)
#  define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
diff --git a/gcc/libatomic/configure b/gcc/libatomic/configure
index 5867e69..e14d805 100755
--- a/gcc/libatomic/configure
+++ a/gcc/libatomic/configure
@@ -8476,8 +8476,6 @@

    haiku*)
      # PIC is the default for Haiku.
      # The "-static" flag exists, but is broken.
      lt_prog_compiler_static=
      ;;

    hpux*)
@@ -10579,8 +10577,9 @@
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
  hardcode_into_libs=yes
  sys_lib_search_path_spec='/boot/system/non-packaged/develop/lib /boot/system/develop/lib'
  sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib'
  hardcode_into_libs=no
  ;;

hpux9* | hpux10* | hpux11*)
@@ -11102,7 +11101,7 @@
  lt_cv_dlopen_libs=

  case $host_os in
  beos*)
  beos* | haiku* )
    lt_cv_dlopen="load_add_on"
    lt_cv_dlopen_libs=
    lt_cv_dlopen_self=yes
@@ -14864,11 +14863,26 @@
case " $config_path " in
 *" posix "*)
  XPCFLAGS=""
  CFLAGS="$CFLAGS -pthread"
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include <pthread.h>
      void *g(void *d) { return NULL; }
int
main ()
{
pthread_t t; pthread_create(&t,NULL,g,NULL);
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :

else
  CFLAGS="$CFLAGS -pthread"
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include <pthread.h>
         void *g(void *d) { return NULL; }
int
main ()
{
@@ -14881,10 +14895,10 @@
  XPCFLAGS=" -pthread"
else
  CFLAGS="$save_CFLAGS $XCFLAGS" LIBS="-lpthread $LIBS"
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include <pthread.h>
        void *g(void *d) { return NULL; }
            void *g(void *d) { return NULL; }
int
main ()
{
@@ -14897,6 +14911,9 @@

else
  as_fn_error $? "Pthreads are required to build libatomic" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
diff --git a/gcc/libatomic/configure.ac b/gcc/libatomic/configure.ac
index 2a37187..1a6f550 100644
--- a/gcc/libatomic/configure.ac
+++ a/gcc/libatomic/configure.ac
@@ -217,21 +217,27 @@
case " $config_path " in
 *" posix "*)
  XPCFLAGS=""
  CFLAGS="$CFLAGS -pthread"
  AC_LINK_IFELSE(
    [AC_LANG_PROGRAM(
     [#include <pthread.h>
      void *g(void *d) { return NULL; }],
     [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
    [XPCFLAGS=" -pthread"],
    [CFLAGS="$save_CFLAGS $XCFLAGS" LIBS="-lpthread $LIBS"
    [],
    [CFLAGS="$CFLAGS -pthread"
     AC_LINK_IFELSE(
      [AC_LANG_PROGRAM(
       [#include <pthread.h>
        void *g(void *d) { return NULL; }],
       [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
      [],
      [AC_MSG_ERROR([Pthreads are required to build libatomic])])])
       [AC_LANG_PROGRAM(
        [#include <pthread.h>
         void *g(void *d) { return NULL; }],
        [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
       [XPCFLAGS=" -pthread"],
       [CFLAGS="$save_CFLAGS $XCFLAGS" LIBS="-lpthread $LIBS"
        AC_LINK_IFELSE(
          [AC_LANG_PROGRAM(
           [#include <pthread.h>
            void *g(void *d) { return NULL; }],
           [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
          [],
          [AC_MSG_ERROR([Pthreads are required to build libatomic])])])])
  CFLAGS="$save_CFLAGS $XPCFLAGS"
  ;;
esac
diff --git a/gcc/libatomic/configure.tgt b/gcc/libatomic/configure.tgt
index 670b0d7..8159a41 100644
--- a/gcc/libatomic/configure.tgt
+++ a/gcc/libatomic/configure.tgt
@@ -151,7 +151,7 @@
  *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \
  | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* \
  | *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \
  | *-*-darwin* | *-*-aix* | *-*-cygwin*)
  | *-*-darwin* | *-*-aix* | *-*-cygwin* | *-*-haiku*)
	# POSIX system.  The OS is supported.
	config_path="${config_path} posix"
	;;
diff --git a/gcc/libcody/configure b/gcc/libcody/configure
index da52a5c..d92e55a 100755
--- a/gcc/libcody/configure
+++ a/gcc/libcody/configure
@@ -2496,7 +2496,7 @@
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

#if __cplusplus != 201103
#if __cplusplus < 201103
#error "C++11 is required"
#endif

diff --git a/gcc/libgcc/config.host b/gcc/libgcc/config.host
index 50f0006..e7e0045 100644
--- a/gcc/libgcc/config.host
+++ a/gcc/libgcc/config.host
@@ -103,7 +103,7 @@
	;;
avr-*-*)
	cpu_type=avr
	;;    
	;;
bfin*-*)
	cpu_type=bfin
	;;
@@ -244,6 +244,14 @@
*-*-fuchsia*)
  tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-fuchsia"
  extra_parts="crtbegin.o crtend.o"
  ;;
*-*-haiku*)
  # This is the generic ELF configuration of Haiku.  Later
  # machine-specific sections may refine and add to this
  # configuration.
  tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-haiku t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver"
  tmake_file="$tmake_file t-slibgcc-libgcc t-slibgcc-nolc-override"
  extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
  ;;
*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu | *-*-uclinuxfdpiceabi)
  tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux"
@@ -382,6 +390,11 @@
	tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
	;;
aarch64*-*-haiku*)
	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
	md_unwind_header=aarch64/haiku-unwind.h
	;;
aarch64*-*-linux*)
	extra_parts="$extra_parts crtfastmath.o"
	md_unwind_header=aarch64/linux-unwind.h
@@ -467,6 +480,12 @@
	    tmake_file="${tmake_file} arm/t-netbsd t-slibgcc-gld-nover"
	    ;;
	esac
	;;
arm-*-haiku*)
	tmake_file="${tmake_file} arm/t-arm arm/t-elf arm/t-bpabi"
	tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
	tm_file="${tm_file} arm/bpabi-lib.h"
	unwind_header=config/arm/unwind-arm.h
	;;
arm*-*-linux* | arm*-*-uclinuxfdpiceabi)
	tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix t-crtfm"
@@ -718,6 +737,12 @@
x86_64-*-freebsd*)
	tmake_file="${tmake_file} i386/t-freebsd i386/t-crtstuff"
	md_unwind_header=i386/freebsd-unwind.h
	;;
i[34567]86-*-haiku*)
	tmake_file="${tmake_file} i386/t-crtstuff i386/t-eh-dw2"
	;;
x86_64-*-haiku*)
	tmake_file="${tmake_file} i386/t-crtstuff i386/t-eh-dw2"
	;;
i[34567]86-*-netbsdelf*)
	tmake_file="${tmake_file} i386/t-crtstuff"
@@ -919,7 +944,7 @@
lm32-*-uclinux*)
        extra_parts="$extra_parts crtbegin.o crtendS.o crtbeginT.o"
        tmake_file="lm32/t-lm32 lm32/t-uclinux t-libgcc-pic t-softfp-sfdf t-softfp"
	;;	
	;;
m32r-*-elf*)
	tmake_file="$tmake_file m32r/t-m32r t-fdpbit"
	extra_parts="$extra_parts crtinit.o crtfini.o"
@@ -932,6 +957,8 @@
 	;;
m32rle-*-linux*)
	tmake_file="$tmake_file m32r/t-linux t-fdpbit"
	;;
m68k-*-haiku*)
	;;
m68k-*-elf* | fido-*-elf)
	tmake_file="$tmake_file m68k/t-floatlib"
@@ -1003,6 +1030,8 @@
	esac
	extra_parts="$extra_parts crti.o crtn.o"
	;;
mipsel-*-haiku*)
	;;
mipsisa32-*-elf* | mipsisa32el-*-elf* | \
mipsisa32r2-*-elf* | mipsisa32r2el-*-elf* | \
mipsisa32r6-*-elf* | mipsisa32r6el-*-elf* | \
@@ -1157,6 +1186,8 @@
	  ;;
	esac
	;;
powerpc-*-haiku*)
	;;
powerpc-*-netbsd*)
	tmake_file="$tmake_file rs6000/t-netbsd rs6000/t-crtstuff"
	;;
@@ -1434,6 +1465,8 @@
		tmake_file="${tmake_file} sparc/t-softmul"
	fi
	md_unwind_header=sparc/linux-unwind.h
	;;
sparc64-*-haiku*)
	;;
sparc64-*-netbsd*)
	;;
diff --git a/gcc/libgcc/crtstuff.c b/gcc/libgcc/crtstuff.c
index 675930d..d971879 100644
--- a/gcc/libgcc/crtstuff.c
+++ a/gcc/libgcc/crtstuff.c
@@ -108,7 +108,9 @@
    && defined(HAVE_LD_EH_FRAME_HDR) \
    && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
    && defined(__GLIBC__) && __GLIBC__ >= 2
#ifndef __HAIKU__
#include <link.h>
#endif
/* uClibc pretends to be glibc 2.2 and DT_CONFIG is defined in its link.h.
   But it doesn't use PT_GNU_EH_FRAME ELF segment currently.  */
# if !defined(__UCLIBC__) \
diff --git a/gcc/libgomp/configure b/gcc/libgomp/configure
index 1917d7e..12bb7eb 100755
--- a/gcc/libgomp/configure
+++ a/gcc/libgomp/configure
@@ -8517,8 +8517,6 @@

    haiku*)
      # PIC is the default for Haiku.
      # The "-static" flag exists, but is broken.
      lt_prog_compiler_static=
      ;;

    hpux*)
@@ -10620,8 +10618,9 @@
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
  hardcode_into_libs=yes
  sys_lib_search_path_spec='/boot/system/non-packaged/develop/lib /boot/system/develop/lib'
  sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib'
  hardcode_into_libs=no
  ;;

hpux9* | hpux10* | hpux11*)
@@ -11143,7 +11142,7 @@
  lt_cv_dlopen_libs=

  case $host_os in
  beos*)
  beos* | haiku* )
    lt_cv_dlopen="load_add_on"
    lt_cv_dlopen_libs=
    lt_cv_dlopen_self=yes
@@ -12392,8 +12391,6 @@

    haiku*)
      # PIC is the default for Haiku.
      # The "-static" flag exists, but is broken.
      lt_prog_compiler_static_FC=
      ;;

    hpux*)
@@ -14260,8 +14257,9 @@
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
  hardcode_into_libs=yes
  sys_lib_search_path_spec='/boot/system/non-packaged/develop/lib /boot/system/develop/lib'
  sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib'
  hardcode_into_libs=no
  ;;

hpux9* | hpux10* | hpux11*)
@@ -14942,7 +14940,6 @@
  *)
    # Check to see if -pthread or -lpthread is needed.  Prefer the former.
    # In case the pthread.h system header is not found, this test will fail.
    CFLAGS="$CFLAGS -pthread"
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include <pthread.h>
@@ -14956,13 +14953,29 @@
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  XPCFLAGS=" -Wc,-pthread"

else
  CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
  CFLAGS="$CFLAGS -pthread"
      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include <pthread.h>
         void *g(void *d) { return NULL; }
int
main ()
{
pthread_t t; pthread_create(&t,NULL,g,NULL);
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  XPCFLAGS=" -Wc,-pthread"
else
  CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include <pthread.h>
           void *g(void *d) { return NULL; }
int
main ()
{
@@ -14975,6 +14988,9 @@

else
  as_fn_error $? "Pthreads are required to build libgomp" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
diff --git a/gcc/libgomp/configure.ac b/gcc/libgomp/configure.ac
index c23fe00..caf60d7 100644
--- a/gcc/libgomp/configure.ac
+++ a/gcc/libgomp/configure.ac
@@ -194,21 +194,27 @@
  *)
    # Check to see if -pthread or -lpthread is needed.  Prefer the former.
    # In case the pthread.h system header is not found, this test will fail.
    CFLAGS="$CFLAGS -pthread"
    AC_LINK_IFELSE(
     [AC_LANG_PROGRAM(
      [#include <pthread.h>
       void *g(void *d) { return NULL; }],
      [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
     [XPCFLAGS=" -Wc,-pthread"],
     [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
     [],
     [CFLAGS="$CFLAGS -pthread"
      AC_LINK_IFELSE(
       [AC_LANG_PROGRAM(
        [#include <pthread.h>
         void *g(void *d) { return NULL; }],
        [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
       [],
       [AC_MSG_ERROR([Pthreads are required to build libgomp])])])
       [XPCFLAGS=" -Wc,-pthread"],
       [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
        AC_LINK_IFELSE(
         [AC_LANG_PROGRAM(
          [#include <pthread.h>
           void *g(void *d) { return NULL; }],
          [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
         [],
         [AC_MSG_ERROR([Pthreads are required to build libgomp])])])])
esac

if test x$libgomp_use_pthreads != xno; then
diff --git a/gcc/libstdc++-v3/configure b/gcc/libstdc++-v3/configure
index 326a279..5df00e1 100755
--- a/gcc/libstdc++-v3/configure
+++ a/gcc/libstdc++-v3/configure
@@ -9199,8 +9199,6 @@

    haiku*)
      # PIC is the default for Haiku.
      # The "-static" flag exists, but is broken.
      lt_prog_compiler_static=
      ;;

    hpux*)
@@ -11311,8 +11309,9 @@
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
  hardcode_into_libs=yes
  sys_lib_search_path_spec='/boot/system/non-packaged/develop/lib /boot/system/develop/lib'
  sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib'
  hardcode_into_libs=no
  ;;

hpux9* | hpux10* | hpux11*)
@@ -11837,7 +11836,7 @@
  lt_cv_dlopen_libs=

  case $host_os in
  beos*)
  beos* | haiku*)
    lt_cv_dlopen="load_add_on"
    lt_cv_dlopen_libs=
    lt_cv_dlopen_self=yes
@@ -14078,8 +14077,6 @@
      ;;
    haiku*)
      # PIC is the default for Haiku.
      # The "-static" flag exists, but is broken.
      lt_prog_compiler_static_CXX=
      ;;
    interix[3-9]*)
      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
@@ -14990,8 +14987,9 @@
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
  hardcode_into_libs=yes
  sys_lib_search_path_spec='/boot/system/non-packaged/develop/lib /boot/system/develop/lib'
  sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib'
  hardcode_into_libs=no
  ;;

hpux9* | hpux10* | hpux11*)
@@ -47515,10 +47513,93 @@
if test "x$ac_cv_func_uselocale" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_USELOCALE 1
_ACEOF

fi
done

    ;;

  *-haiku*)
    for ac_header in nan.h ieeefp.h endian.h sys/isa_defs.h \
      machine/endian.h machine/param.h sys/machine.h sys/types.h \
      fp.h float.h endian.h inttypes.h locale.h float.h stdint.h
do :
  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
   if test "x$as_val" = x""yes; then :
  cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF

fi

done

    SECTION_FLAGS='-ffunction-sections -fdata-sections'


    $as_echo "#define HAVE_INT64_T 1" >>confdefs.h


    $as_echo "#define HAVE_ACOSF 1" >>confdefs.h

    $as_echo "#define HAVE_ASINF 1" >>confdefs.h

    $as_echo "#define HAVE_ATANF 1" >>confdefs.h

    $as_echo "#define HAVE_ATAN2F 1" >>confdefs.h

    $as_echo "#define HAVE_CEILF 1" >>confdefs.h

    $as_echo "#define HAVE_COSF 1" >>confdefs.h

    $as_echo "#define HAVE_COSHF 1" >>confdefs.h

    $as_echo "#define HAVE_EXPF 1" >>confdefs.h

    $as_echo "#define HAVE_FABSF 1" >>confdefs.h

    $as_echo "#define HAVE_FINITE 1" >>confdefs.h

    $as_echo "#define HAVE_FINITEF 1" >>confdefs.h

    $as_echo "#define HAVE_FLOORF 1" >>confdefs.h

    $as_echo "#define HAVE_FMODF 1" >>confdefs.h

    $as_echo "#define HAVE_FREXPF 1" >>confdefs.h

    $as_echo "#define HAVE_HYPOT 1" >>confdefs.h

    $as_echo "#define HAVE_HYPOTF 1" >>confdefs.h

    $as_echo "#define HAVE_ISINF 1" >>confdefs.h

    $as_echo "#define HAVE_ISINFF 1" >>confdefs.h

    $as_echo "#define HAVE_ISNAN 1" >>confdefs.h

    $as_echo "#define HAVE_ISNANF 1" >>confdefs.h

    $as_echo "#define HAVE_LOGF 1" >>confdefs.h

    $as_echo "#define HAVE_LOG10F 1" >>confdefs.h

    $as_echo "#define HAVE_MODFF 1" >>confdefs.h

    $as_echo "#define HAVE_SINF 1" >>confdefs.h

    $as_echo "#define HAVE_SINHF 1" >>confdefs.h

    $as_echo "#define HAVE_SQRTF 1" >>confdefs.h

    $as_echo "#define HAVE_TANF 1" >>confdefs.h

    $as_echo "#define HAVE_TANHF 1" >>confdefs.h

    $as_echo "#define HAVE_TLS 1" >>confdefs.h

    ;;

diff --git a/gcc/libstdc++-v3/configure.host b/gcc/libstdc++-v3/configure.host
index ec32980..8dbe77c 100644
--- a/gcc/libstdc++-v3/configure.host
+++ a/gcc/libstdc++-v3/configure.host
@@ -267,6 +267,9 @@
      os_include_dir="os/gnu-linux"
    fi
    ;;
  haiku*)
    os_include_dir="os/haiku"
    ;;
  hpux*)
    os_include_dir="os/hpux"
    ;;
@@ -354,7 +357,7 @@
	;;
    esac
    ;;
  arm*-*-freebsd*)
  arm*-*-freebsd* | arm*-*-haiku*)
     port_specific_symbol_files="\$(srcdir)/../config/os/gnu-linux/arm-eabi-extra.ver"
     ;;
  powerpc*-*-darwin*)
diff --git a/gcc/libstdc++-v3/crossconfig.m4 b/gcc/libstdc++-v3/crossconfig.m4
index ff44d5a..c3a1e0c 100644
--- a/gcc/libstdc++-v3/crossconfig.m4
+++ a/gcc/libstdc++-v3/crossconfig.m4
@@ -90,7 +90,7 @@

  *-freebsd*)
    SECTION_FLAGS='-ffunction-sections -fdata-sections'
    AC_SUBST(SECTION_FLAGS) 
    AC_SUBST(SECTION_FLAGS)
    GLIBCXX_CHECK_LINKER_FEATURES
    AC_DEFINE(HAVE_SETENV)
    AC_DEFINE(HAVE_FINITEF)
@@ -134,6 +134,46 @@
    AC_CHECK_FUNCS(timespec_get)
    AC_CHECK_FUNCS(sockatmark)
    AC_CHECK_FUNCS(uselocale)
    ;;

  *-haiku*)
    AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
      machine/endian.h machine/param.h sys/machine.h sys/types.h \
      fp.h float.h endian.h inttypes.h locale.h float.h stdint.h])
    SECTION_FLAGS='-ffunction-sections -fdata-sections'
    AC_SUBST(SECTION_FLAGS)

    AC_DEFINE(HAVE_INT64_T)

    AC_DEFINE(HAVE_ACOSF)
    AC_DEFINE(HAVE_ASINF)
    AC_DEFINE(HAVE_ATANF)
    AC_DEFINE(HAVE_ATAN2F)
    AC_DEFINE(HAVE_CEILF)
    AC_DEFINE(HAVE_COSF)
    AC_DEFINE(HAVE_COSHF)
    AC_DEFINE(HAVE_EXPF)
    AC_DEFINE(HAVE_FABSF)
    AC_DEFINE(HAVE_FINITE)
    AC_DEFINE(HAVE_FINITEF)
    AC_DEFINE(HAVE_FLOORF)
    AC_DEFINE(HAVE_FMODF)
    AC_DEFINE(HAVE_FREXPF)
    AC_DEFINE(HAVE_HYPOT)
    AC_DEFINE(HAVE_HYPOTF)
    AC_DEFINE(HAVE_ISINF)
    AC_DEFINE(HAVE_ISINFF)
    AC_DEFINE(HAVE_ISNAN)
    AC_DEFINE(HAVE_ISNANF)
    AC_DEFINE(HAVE_LOGF)
    AC_DEFINE(HAVE_LOG10F)
    AC_DEFINE(HAVE_MODFF)
    AC_DEFINE(HAVE_SINF)
    AC_DEFINE(HAVE_SINHF)
    AC_DEFINE(HAVE_SQRTF)
    AC_DEFINE(HAVE_TANF)
    AC_DEFINE(HAVE_TANHF)
    AC_DEFINE(HAVE_TLS)
    ;;

  *-fuchsia*)
@@ -228,7 +268,7 @@
    ;;
  *-qnx6.1* | *-qnx6.2*)
    SECTION_FLAGS='-ffunction-sections -fdata-sections'
    AC_SUBST(SECTION_FLAGS) 
    AC_SUBST(SECTION_FLAGS)
    GLIBCXX_CHECK_LINKER_FEATURES
    AC_DEFINE(HAVE_COSF)
    AC_DEFINE(HAVE_COSL)
diff --git a/gcc/gcc/config/haiku-protos.h b/gcc/gcc/config/haiku-protos.h
new file mode 100644
index 0000000..22d8e59 100644
--- /dev/null
+++ a/gcc/gcc/config/haiku-protos.h
@@ -1,0 +1,21 @@
/* Operating system specific prototypes to be used when targeting GCC for Haiku.
   Copyright (C) 2021 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/>.  */

/* In haiku.c.  */
extern void haiku_override_options (void);
diff --git a/gcc/gcc/config/haiku-stdint.h b/gcc/gcc/config/haiku-stdint.h
new file mode 100644
index 0000000..19f1412 100644
--- /dev/null
+++ a/gcc/gcc/config/haiku-stdint.h
@@ -1,0 +1,55 @@
/* Definitions for <stdint.h> types on Haiku.
   Copyright (C) 2014 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.

Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.

You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
<http://www.gnu.org/licenses/>.  */

#define SIG_ATOMIC_TYPE "int"

#define INT8_TYPE "signed char"
#define INT16_TYPE "short int"
#define INT32_TYPE "int"
#define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
#define UINT8_TYPE "unsigned char"
#define UINT16_TYPE "short unsigned int"
#define UINT32_TYPE "unsigned int"
#define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")

#define INT_LEAST8_TYPE "signed char"
#define INT_LEAST16_TYPE "short int"
#define INT_LEAST32_TYPE "int"
#define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
#define UINT_LEAST8_TYPE "unsigned char"
#define UINT_LEAST16_TYPE "short unsigned int"
#define UINT_LEAST32_TYPE "unsigned int"
#define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")

#define INT_FAST8_TYPE "int"
#define INT_FAST16_TYPE "int"
#define INT_FAST32_TYPE "int"
#define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "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 (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")

#define INTPTR_TYPE "long int"
#define UINTPTR_TYPE "long unsigned int"
diff --git a/gcc/gcc/config/haiku.c b/gcc/gcc/config/haiku.c
new file mode 100644
index 0000000..bf62ad5 100644
--- /dev/null
+++ a/gcc/gcc/config/haiku.c
@@ -1,0 +1,32 @@
/* General Haiku system support.
   Copyright (C) 2021 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/>.  */

#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"

void
haiku_override_options (void)
{
  if (!global_options_set.x_dwarf_strict)
    dwarf_strict = 1;
  if (!global_options_set.x_dwarf_version)
    dwarf_version = 4;
}
diff --git a/gcc/gcc/config/haiku.h b/gcc/gcc/config/haiku.h
new file mode 100644
index 0000000..316d384 100644
--- /dev/null
+++ a/gcc/gcc/config/haiku.h
@@ -1,0 +1,218 @@
/* Definitions of target machine for GCC.
   Common Haiku definitions for all architectures.
   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005
   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, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */


/* Change debugging to Dwarf2.  */
#undef PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG

#undef MCOUNT_NAME
#define MCOUNT_NAME "_mcount"

#define TARGET_DECLSPEC 1

#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

/* Haiku uses lots of multichars, so don't warn about them unless the
   user explicitly asks for the warnings with -Wmultichar.  Note that
   CC1_SPEC is used for both cc1 and cc1plus.  */
#undef CC1_SPEC
#define CC1_SPEC \
  "%{fpic|fPIC|fpie|fPIE|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-fPIC} \

   %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}"

#undef CC1PLUS_SPEC
#define CC1PLUS_SPEC "%{!Wctor-dtor-privacy:-Wno-ctor-dtor-privacy}"

#define SUBTARGET_OVERRIDE_OPTIONS			\
  do {							\
    haiku_override_options ();			\
  } while (0)

/* LIB_SPEC for Haiku */
#undef LIB_SPEC
#define LIB_SPEC "-lroot"

/* Use --as-needed -lgcc_s for eh support.  */
#ifdef HAVE_LD_AS_NEEDED
#define USE_LD_AS_NEEDED 1
#endif

#undef  STARTFILE_SPEC
#define STARTFILE_SPEC "crti.o%s crtbeginS.o%s %{!shared:%{!nostart:start_dyn.o%s}} init_term_dyn.o%s"

#undef  ENDFILE_SPEC
#define ENDFILE_SPEC "crtendS.o%s crtn.o%s"

/* Every program on Haiku links against libroot which contains the pthread
   routines, so there's no need to explicitly call out when doing threaded
   work.  */
#undef GOMP_SELF_SPECS
#define GOMP_SELF_SPECS ""
#undef GTM_SELF_SPECS
#define GTM_SELF_SPECS ""

#ifdef HYBRID_SECONDARY
/* For a secondary compiler on a hybrid system, use alternative search paths.*/
#define INCLUDE_DEFAULTS \
{ \
    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, \
    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, \
    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, \
    { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, \
    { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, \
    { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 }, \
    { "/boot/system/non-packaged/develop/headers/" HYBRID_SECONDARY, 0, 0, 0, 1, 0 }, \
    { "/boot/system/develop/headers/os", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/app", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/device", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/drivers", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/game", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/interface", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/kernel", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/locale", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/mail", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/media", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/midi", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/midi2", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/net", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/opengl", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/storage", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/support", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/translation", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/graphics", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/input_server", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/mail_daemon", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/registrar", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/screen_saver", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/tracker", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/be_apps/Deskbar", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/be_apps/NetPositive", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/be_apps/Tracker", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/3rdparty", 0, 0, 0, 1, 0 }, \
    { "/boot/system/develop/headers/bsd", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/glibc", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/gnu", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/posix", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/" HYBRID_SECONDARY, 0, 0, 0, 1, 0 }, \
        /* Hybrid secondary folders for os kits not in base haiku package */\
    { "/boot/system/develop/headers/" HYBRID_SECONDARY "/os", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/" HYBRID_SECONDARY "/os/opengl", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers", 0, 0, 0, 1, 0 }, \
    { 0, 0, 0, 0, 0, 0 } \
}
#else /* HYBRID_SECONDARY */
/* For both native and cross compiler, use standard Haiku include file
   search paths.
   For a cross compiler, it is expected that an appropriate sysroot has
   been configured (e.g. /boot/system/develop/cross/x86) which will
   be appended to each search folder given below. */
#define INCLUDE_DEFAULTS \
{ \
    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, \
    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, \
    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, \
    { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, \
    { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, \
    { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 }, \
    { "/boot/system/non-packaged/develop/headers", 0, 0, 0, 1, 0 }, \
    { "/boot/system/develop/headers/os", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/app", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/device", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/drivers", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/game", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/interface", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/kernel", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/locale", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/mail", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/media", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/midi", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/midi2", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/net", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/opengl", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/storage", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/support", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/translation", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/graphics", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/input_server", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/mail_daemon", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/registrar", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/screen_saver", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/add-ons/tracker", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/be_apps/Deskbar", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/be_apps/NetPositive", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/os/be_apps/Tracker", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/3rdparty", 0, 0, 0, 1, 0 }, \
    	/* TODO: To be removed when libtiff has been outsourced. */\
    { "/boot/system/develop/headers/bsd", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/glibc", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/gnu", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers/posix", 0, 0, 1, 1, 0 }, \
    { "/boot/system/develop/headers", 0, 0, 0, 1, 0 }, \
    { 0, 0, 0, 0, 0, 0 } \
}
#endif /* HYBRID_SECONDARY */

/* Whee.  LIBRARY_PATH is Be's LD_LIBRARY_PATH, which of course will
   cause nasty problems if we override it.  */
#define LIBRARY_PATH_ENV        "BELIBRARIES"

/* Set STANDARD_STARTFILE_PREFIX_1 set to "/boot/system/develop/lib/", or the
   respective secondary architecture path. The user specific paths are set via
   LIBRARY_PATH_ENV. */
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#undef MD_STARTFILE_PREFIX
#undef STARTFILE_PREFIX_SPEC
#ifdef HYBRID_SECONDARY
/* For a secondary compiler on a hybrid system, use alternative search paths.*/
#define STANDARD_STARTFILE_PREFIX_1 \
  "/boot/system/non-packaged/develop/lib/" HYBRID_SECONDARY "/"
#define STANDARD_STARTFILE_PREFIX_2 \
  "/boot/system/develop/lib/" HYBRID_SECONDARY "/"
#else /* HYBRID_SECONDARY */
#define STANDARD_STARTFILE_PREFIX_1   "/boot/system/non-packaged/develop/lib/"
#define STANDARD_STARTFILE_PREFIX_2   "/boot/system/develop/lib/"
#endif /* HYBRID_SECONDARY */

/* Haiku doesn't have a separate math library.  */
#define MATH_LIBRARY ""

/* Haiku headers are C++-aware (and often use C++).  */
/* #define NO_IMPLICIT_EXTERN_C */

#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
		       "|fstack-protector-strong|fstack-protector-explicit" \
		       ":-lssp_nonshared}"

/* Do not use TM clone registry in Haiku for now */
#define USE_TM_CLONE_REGISTRY 0
diff --git a/gcc/gcc/config/host-darwin.c b/gcc/gcc/config/host-darwin.c
index 14a01fe..0d26a76 100644
--- a/gcc/gcc/config/host-darwin.c
+++ a/gcc/gcc/config/host-darwin.c
@@ -79,3 +79,5 @@

  return ret;
}

const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff --git a/gcc/gcc/config/t-haiku b/gcc/gcc/config/t-haiku
new file mode 100644
index 0000000..ba1f7f5 100644
--- /dev/null
+++ a/gcc/gcc/config/t-haiku
@@ -1,0 +1,9 @@
# There are system headers elsewhere, but these are the ones that
# we are most likely to want to apply any fixes to.
NATIVE_SYSTEM_HEADER_DIR = /boot/system/develop/headers
LIMITS_H_TEST = [ -f $(SYSTEM_HEADER_DIR)/posix/limits.h ]

# Haiku-specific attributes
haiku.o: $(srcdir)/config/haiku.c
	$(COMPILE) $<
	$(POSTCOMPILE)
diff --git a/gcc/gcc/ginclude/stdarg.h b/gcc/gcc/ginclude/stdarg.h
index 7b6c632..871522c 100644
--- a/gcc/gcc/ginclude/stdarg.h
+++ a/gcc/gcc/ginclude/stdarg.h
@@ -94,7 +94,7 @@
#ifndef _VA_LIST
/* The macro _VA_LIST_T_H is used in the Bull dpx2  */
#ifndef _VA_LIST_T_H
/* The macro __va_list__ is used by BeOS.  */
/* The macro __va_list__ is used by BeOS and Haiku.  */
#ifndef __va_list__
typedef __gnuc_va_list va_list;
#endif /* not __va_list__ */
diff --git a/gcc/gcc/ginclude/stddef.h b/gcc/gcc/ginclude/stddef.h
index 66619fe..68e5024 100644
--- a/gcc/gcc/ginclude/stddef.h
+++ a/gcc/gcc/ginclude/stddef.h
@@ -161,7 +161,7 @@
/* Define this type if we are doing the whole job,
   or if we want this type in particular.  */
#if defined (_STDDEF_H) || defined (__need_size_t)

#ifndef __size_t__	/* BeOS */
#ifndef __size_t__	/* BeOS, Haiku */
#ifndef __SIZE_T__	/* Cray Unicos/Mk */
#ifndef _SIZE_T	/* in case <sys/types.h> has defined it. */
#ifndef _SYS_SIZE_T_H
@@ -178,7 +178,7 @@
#ifndef _GCC_SIZE_T
#ifndef _SIZET_
#ifndef __size_t
#define __size_t__	/* BeOS */
#define __size_t__	/* BeOS, Haiku */
#define __SIZE_T__	/* Cray Unicos/Mk */
#define _SIZE_T
#define _SYS_SIZE_T_H
@@ -207,7 +207,7 @@
#endif
#if !(defined (__GNUG__) && defined (size_t))

typedef __SIZE_TYPE__ size_t;
#ifdef __BEOS__
#if defined(__BEOS__)

typedef long ssize_t;
#endif /* __BEOS__ */
#endif /* !(defined (__GNUG__) && defined (size_t)) */
@@ -240,7 +240,7 @@
/* Define this type if we are doing the whole job,
   or if we want this type in particular.  */
#if defined (_STDDEF_H) || defined (__need_wchar_t)

#ifndef __wchar_t__	/* BeOS */
#ifndef __wchar_t__	/* BeOS, Haiku */
#ifndef __WCHAR_T__	/* Cray Unicos/Mk */
#ifndef _WCHAR_T
#ifndef _T_WCHAR_
@@ -257,7 +257,7 @@
#ifndef ___int_wchar_t_h
#ifndef __INT_WCHAR_T_H
#ifndef _GCC_WCHAR_T
#define __wchar_t__	/* BeOS */
#define __wchar_t__	/* BeOS, Haiku */
#define __WCHAR_T__	/* Cray Unicos/Mk */
#define _WCHAR_T
#define _T_WCHAR_
diff --git a/gcc/libgcc/config/t-haiku b/gcc/libgcc/config/t-haiku
new file mode 100644
index 0000000..b4fff2d 100644
--- /dev/null
+++ a/gcc/libgcc/config/t-haiku
@@ -1,0 +1,3 @@
# Use unwind-dw2-fde
LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \
  $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
diff --git a/gcc/libstdc++-v3/libsupc++/tinfo.cc b/gcc/libstdc++-v3/libsupc++/tinfo.cc
index a620e23..ba024c3 100644
--- a/gcc/libstdc++-v3/libsupc++/tinfo.cc
+++ a/gcc/libstdc++-v3/libsupc++/tinfo.cc
@@ -30,6 +30,15 @@
~type_info ()
{ }

#ifdef __HAIKU__
#ifndef __GXX_MERGED_TYPEINFO_NAMES
#define __GXX_MERGED_TYPEINFO_NAMES 0
#endif
#ifndef __GXX_TYPEINFO_EQUALITY_INLINE
#define __GXX_TYPEINFO_EQUALITY_INLINE 0
#endif
#endif

#if !__GXX_TYPEINFO_EQUALITY_INLINE


// We can't rely on common symbols being shared between shared objects.
diff --git a/gcc/gcc/config/aarch64/aarch64-haiku.h b/gcc/gcc/config/aarch64/aarch64-haiku.h
new file mode 100644
index 0000000..a61ebfa 100644
--- /dev/null
+++ a/gcc/gcc/config/aarch64/aarch64-haiku.h
@@ -1,0 +1,73 @@
/* Machine description for AArch64 architecture.
   Copyright (C) 2009-2018 Free Software Foundation, Inc.
   Contributed by ARM Ltd.
   Updated for Haiku by Jaroslaw Pelczar <jarek@jpelczar.com>

   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/>.  */

#ifndef GCC_AARCH64_HAIKU_H
#define GCC_AARCH64_HAIKU_H

#define TARGET_OS_CPP_BUILTINS()					\
  do									\
    {									\
      builtin_define ("__HAIKU__");					\
      builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
      builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
      builtin_define ("__STDC_ISO_10646__=201103L"); 			\
      builtin_assert ("system=haiku");					\
    }									\
  while (0)

#if TARGET_BIG_ENDIAN_DEFAULT

#define TARGET_LINKER_EMULATION  "aarch64haikub"
#else
#define TARGET_LINKER_EMULATION  "aarch64haiku"
#endif

#if TARGET_FIX_ERR_A53_835769_DEFAULT

#define CA53_ERR_835769_SPEC \
  " %{!mno-fix-cortex-a53-835769:--fix-cortex-a53-835769}"
#else
#define CA53_ERR_835769_SPEC \
  " %{mfix-cortex-a53-835769:--fix-cortex-a53-835769}"
#endif

#if TARGET_FIX_ERR_A53_843419_DEFAULT

#define CA53_ERR_843419_SPEC \
  " %{!mno-fix-cortex-a53-843419:--fix-cortex-a53-843419}"
#else
#define CA53_ERR_843419_SPEC \
  " %{mfix-cortex-a53-843419:--fix-cortex-a53-843419}"
#endif


/* Uninitialized common symbols in non-PIE executables, even with
   strong definitions in dependent shared libraries, will resolve
   to COPY relocated symbol in the executable.  See PR65780.  */
#undef TARGET_BINDS_LOCAL_P
#define TARGET_BINDS_LOCAL_P default_binds_local_p_2

/* Define this to be nonzero if static stack checking is supported.  */
#define STACK_CHECK_STATIC_BUILTIN 1


#undef	LINK_SPEC
#define LINK_SPEC "%{!o*:-o %b} -m " TARGET_LINKER_EMULATION " %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}\
	%{mbig-endian:-EB} %{mlittle-endian:-EL} " CA53_ERR_835769_SPEC " " CA53_ERR_843419_SPEC " -X"

#endif  /* GCC_AARCH64_HAIKU_H */
diff --git a/gcc/gcc/config/aarch64/aarch64.h b/gcc/gcc/config/aarch64/aarch64.h
index bfffbcd..cf33b09 100644
--- a/gcc/gcc/config/aarch64/aarch64.h
+++ a/gcc/gcc/config/aarch64/aarch64.h
@@ -1236,7 +1236,7 @@
#define MCPU_TO_MARCH_SPEC_FUNCTIONS \
  { "rewrite_mcpu", aarch64_rewrite_mcpu },

#if defined(__aarch64__)

#if defined(__aarch64__) && ! defined(__APPLE__)

extern const char *host_detect_local_cpu (int argc, const char **argv);
#define HAVE_LOCAL_CPU_DETECT
# define EXTRA_SPEC_FUNCTIONS						\
diff --git a/gcc/gcc/config/aarch64/t-aarch64-haiku b/gcc/gcc/config/aarch64/t-aarch64-haiku
new file mode 100644
index 0000000..99d3dea 100644
--- /dev/null
+++ a/gcc/gcc/config/aarch64/t-aarch64-haiku
@@ -1,0 +1,21 @@
# Machine description for AArch64 architecture.
#  Copyright (C) 2016-2018 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/>.

LIB1ASMSRC   = aarch64/lib1funcs.asm
LIB1ASMFUNCS = _aarch64_sync_cache_range
diff --git a/gcc/gcc/config/arm/haiku.h b/gcc/gcc/config/arm/haiku.h
new file mode 100644
index 0000000..65d5ee3 100644
--- /dev/null
+++ a/gcc/gcc/config/arm/haiku.h
@@ -1,0 +1,73 @@
/*	Definitions for ARM running Haiku systems using ELF
	Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
	2005 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, 59 Temple Place - Suite 330,
	Boston, MA 02111-1307, USA.  */

/* Unsigned chars produces much better code than signed.  */
#define DEFAULT_SIGNED_CHAR  0

#undef  TARGET_DEFAULT_FLOAT_ABI
#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT

/* We default to the "aapcs-linux" ABI so that enums are int-sized by
   default.  */
#undef  ARM_DEFAULT_ABI
#define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX

/* bpabi.h sets FPUTYPE_DEFAULT to VFP */

#undef  MULTILIB_DEFAULTS
#define MULTILIB_DEFAULTS \
  { "marm", "mlittle-endian", "msoft-float", "mno-thumb-interwork" }

/* Default is set by bpabi.h */
/*
#undef TARGET_DEFAULT
*/

#undef SUBTARGET_CPU_DEFAULT
#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6

/* Now we define the strings used to build the spec file.  */

#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS()		\
  do									\
    {									\
      builtin_define ("__HAIKU__");					\
      builtin_define ("__ARM__");					\
      builtin_define ("__arm__");					\
      builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
      builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
      builtin_define ("__STDC_ISO_10646__=201103L"); \
      builtin_assert ("system=haiku");					\
      TARGET_BPABI_CPP_BUILTINS();					\
    }									\
  while (0)

/* Use the default LIBGCC_SPEC, not the empty version in haiku.h, as we
   do not use multilib (needed ??).  */
#undef LIBGCC_SPEC

/* If ELF is the default format, we should not use /lib/elf.  */

#undef	LINK_SPEC
#define LINK_SPEC "%{!o*:-o %b} -m armelf_haiku %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}\
  %{mbig-endian:-EB} %{mlittle-endian:-EL} -X"

diff --git a/gcc/gcc/config/arm/t-haiku b/gcc/gcc/config/arm/t-haiku
new file mode 100644
index 0000000..3f7f488 100644
--- /dev/null
+++ a/gcc/gcc/config/arm/t-haiku
@@ -1,0 +1,21 @@
# build multilib for soft float and VFP 
# (unsure about how it should be done...)
# mix from t-symbian & t-wince-pe

#LIB1ASMSRC = arm/lib1funcs.asm
#LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX _interwork_call_via_rX


#MULTILIB_OPTIONS    += mhard-float
#MULTILIB_DIRNAMES   += fpu

MULTILIB_OPTIONS    += msoft-float
MULTILIB_DIRNAMES   += fpu soft
MULTILIB_EXCEPTIONS += *mthumb/*mhard-float*

MULTILIB_OPTIONS    += mfloat-abi=softfp
MULTILIB_DIRNAMES   += softfp

#LIBGCC = stmp-multilib
#INSTALL_LIBGCC = install-multilib
#TARGET_LIBGCC2_CFLAGS = 
diff --git a/gcc/gcc/config/i386/haiku.h b/gcc/gcc/config/i386/haiku.h
new file mode 100644
index 0000000..3379e19 100644
--- /dev/null
+++ a/gcc/gcc/config/i386/haiku.h
@@ -1,0 +1,77 @@
/* Definitions for Intel x86 running Haiku
   Copyright (C) 1998, 1999, 2000, 2001, 2002, 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 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, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */


#undef ASM_COMMENT_START
#define ASM_COMMENT_START " #"

/* The SVR4 ABI for the i386 says that records and unions are returned
   in memory.  */
#undef DEFAULT_PCC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 1

#undef DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(n) \
  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])

#define TARGET_OS_CPP_BUILTINS()					\
  do									\
    {									\
	builtin_define ("__HAIKU__");					\
	builtin_define ("__INTEL__");					\
	builtin_define ("_X86_");					\
	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
    builtin_define ("__STDC_ISO_10646__=201103L"); \
	builtin_assert ("system=haiku");					\
    }									\
  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 ELF is the default format, we should not use /lib/elf.  */

#undef	LINK_SPEC
#define LINK_SPEC "-m elf_i386_haiku %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"

/* A C statement (sans semicolon) to output to the stdio stream
   FILE the assembler definition of uninitialized global DECL named
   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
   Try to use asm_output_aligned_bss to implement this macro.  */

#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)

/* A C statement to output to the stdio stream FILE an assembler
   command to advance the location counter to a multiple of 1<<LOG
   bytes if it is within MAX_SKIP bytes.

   This is used to align code labels according to Intel recommendations.  */

#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
  if ((LOG)!=0) \
    if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
    else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP))
#endif
diff --git a/gcc/gcc/config/i386/haiku64.h b/gcc/gcc/config/i386/haiku64.h
new file mode 100644
index 0000000..e2fa55a 100644
--- /dev/null
+++ a/gcc/gcc/config/i386/haiku64.h
@@ -1,0 +1,135 @@
/* Definitions for AMD x86_64 running Haiku with ELF format.
   Copyright (C) 1998, 1999, 2000, 2001, 2002, 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 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, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */


#undef ASM_COMMENT_START
#define ASM_COMMENT_START " #"

/* The SVR4 ABI for the i386 says that records and unions are returned
 * in memory. For 64-bit compilation this definition is ignored, however
 * it is necessary for correct 32-bit code generation.
 */
#undef DEFAULT_PCC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 1

#undef DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(n) \
  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])

#define TARGET_OS_CPP_BUILTINS()					\
  do									\
    {									\
      builtin_define ("__HAIKU__");					\
      if (!TARGET_64BIT)						\
        {								\
          builtin_define ("__INTEL__");					\
          builtin_define ("__X86__");					\
        }								\
      builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
      builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
      builtin_define ("__STDC_ISO_10646__=201103L");			\
      builtin_assert ("system=haiku");					\
    }									\
  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_x86_64_haiku} %{" SPEC_32 ":-m elf_i386_haiku} \
	%{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"

/* A C statement (sans semicolon) to output to the stdio stream
   FILE the assembler definition of uninitialized global DECL named
   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
   Try to use x86_output_aligned_bss to implement this macro.  */

#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
  x86_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)

/* This is used to align code labels according to Intel recommendations.  */

#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)			\
  do {									\
    if ((LOG) != 0) {							\
      if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));	\
      else {								\
        fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
        /* Make sure that we have at least 8 byte alignment if > 8 byte	\
           alignment is preferred.  */					\
        if ((LOG) > 3							\
            && (1 << (LOG)) > ((MAX_SKIP) + 1)				\
            && (MAX_SKIP) >= 7)						\
          fputs ("\t.p2align 3\n", (FILE));				\
      }									\
    }									\
  } while (0)
#undef  ASM_OUTPUT_MAX_SKIP_PAD
#define ASM_OUTPUT_MAX_SKIP_PAD(FILE, LOG, MAX_SKIP)			\
  if ((LOG) != 0)							\
    {									\
      if ((MAX_SKIP) == 0)						\
        fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
      else								\
        fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
    }
#endif


/* Output assembler code to FILE to call the profiler.  */
#define NO_PROFILE_COUNTERS 1

#undef ASM_SPEC
#define ASM_SPEC "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} \
 %{Wa,*:%*} %{" SPEC_32 ":--32} %{" SPEC_64 ":--64}"

#undef  ASM_OUTPUT_ALIGNED_DECL_COMMON
#define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN)	\
  x86_elf_aligned_decl_common (FILE, DECL, NAME, SIZE, ALIGN);


/* i386 System V Release 4 uses DWARF debugging info.
   x86-64 ABI specifies DWARF2.  */

#define DWARF2_DEBUGGING_INFO 1
#define DWARF2_UNWIND_INFO 1

#undef PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG

#undef TARGET_ASM_SELECT_SECTION
#define TARGET_ASM_SELECT_SECTION  x86_64_elf_select_section

#undef TARGET_ASM_UNIQUE_SECTION
#define TARGET_ASM_UNIQUE_SECTION  x86_64_elf_unique_section

#define USE_X86_64_FRAME_POINTER 1
diff --git a/gcc/gcc/config/i386/t-haiku64 b/gcc/gcc/config/i386/t-haiku64
new file mode 100644
index 0000000..9c8f8e6 100644
--- /dev/null
+++ a/gcc/gcc/config/i386/t-haiku64
@@ -1,0 +1,16 @@
MULTILIB_OPTIONS = m32 
MULTILIB_DIRNAMES = 32

LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib

EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o

# The pushl in CTOR initialization interferes with frame pointer elimination.
# crtend*.o cannot be compiled without -fno-asynchronous-unwind-tables,
# because then __FRAME_END__ might not be the last thing in .eh_frame
# section.
CRTSTUFF_T_CFLAGS = -fno-omit-frame-pointer -fno-asynchronous-unwind-tables

# Compile libgcc2.a with pic.
TARGET_LIBGCC2_CFLAGS = -fPIC
diff --git a/gcc/gcc/config/m68k/haiku.h b/gcc/gcc/config/m68k/haiku.h
new file mode 100644
index 0000000..e9495d4 100644
--- /dev/null
+++ a/gcc/gcc/config/m68k/haiku.h
@@ -1,0 +1,268 @@
/* Definitions for Motorola 68k running Haiku
   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2007
   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.  */

/* Default target comes from config.gcc.  */

#undef TARGET_DEFAULT
#ifdef TARGET_CPU_DEFAULT
#define TARGET_DEFAULT TARGET_CPU_DEFAULT
#else
#define TARGET_DEFAULT (MASK_BITFIELD|MASK_68881|MASK_68020)
#endif

/* for 68k machines this only needs to be TRUE for the 68000 */

#undef STRICT_ALIGNMENT
#define STRICT_ALIGNMENT 0

/* Here are four prefixes that are used by asm_fprintf to
   facilitate customization for alternate assembler syntaxes.
   Machines with no likelihood of an alternate syntax need not
   define these and need not use asm_fprintf.  */

/* The prefix for register names.  Note that REGISTER_NAMES
   is supposed to include this prefix. Also note that this is NOT an
   fprintf format string, it is a literal string */

#undef REGISTER_PREFIX
#define REGISTER_PREFIX "%"

/* The prefix for local (compiler generated) labels.
   These labels will not appear in the symbol table.  */

#undef LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX "."

/* The prefix to add to user-visible assembler symbols.  */

#undef USER_LABEL_PREFIX
#define USER_LABEL_PREFIX ""

#undef ASM_COMMENT_START
#define ASM_COMMENT_START "|"

/* Target OS builtins.  */

#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS()					\
  do									\
    {									\
	builtin_define ("__HAIKU__");					\
	builtin_define ("__M68K__");					\
	builtin_define_std ("mc68000");					\
	builtin_define_std ("mc68020");					\
	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
    builtin_define ("__STDC_ISO_10646__=201103L"); \
	builtin_assert ("system=haiku");				\
    }									\
  while (0)

#define TARGET_OBJFMT_CPP_BUILTINS()		\
  do						\
    {						\
	builtin_define ("__ELF__");		\
    }						\
  while (0)

#undef CPP_SPEC
#if TARGET_DEFAULT & MASK_68881

#define CPP_SPEC \
  "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
#else
#define CPP_SPEC \
  "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
#endif

/* We override the ASM_SPEC from svr4.h because we must pass -m68040 down
   to the assembler.  */
#undef ASM_SPEC
#define ASM_SPEC \
  "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \

%{m68040} %{m68060:-m68040}"

/* 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 ELF is the default format, we should not use /lib/elf.  */

#undef	LINK_SPEC
/*#define LINK_SPEC "%{!o*:-o %b} -m elf_m68k_haiku -shared -no-undefined %{nostart:-e 0}"*/
#define LINK_SPEC "%{!o*:-o %b} -m m68kelf %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"

/* XXX: not sure for the rest there... */

/* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to
   keep switch tables in the text section.  */

#define JUMP_TABLES_IN_TEXT_SECTION 1

/* This is how to output an assembler line that says to advance the
   location counter to a multiple of 2**LOG bytes.  */

/* Use the default action for outputting the case label.  */
#undef ASM_OUTPUT_CASE_LABEL
#define ASM_RETURN_CASE_JUMP				\
  do {							\
    if (TARGET_COLDFIRE)				\
      {							\
	if (ADDRESS_REG_P (operands[0]))		\
	  return "jmp %%pc@(2,%0:l)";			\
	else						\
	  return "ext%.l %0\n\tjmp %%pc@(2,%0:l)";	\
      }							\
    else						\
      return "jmp %%pc@(2,%0:w)";			\
  } while (0)

#undef ASM_OUTPUT_ALIGN
#define ASM_OUTPUT_ALIGN(FILE,LOG)				\
  if ((LOG) > 0)						\
    fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG));

/* If defined, a C expression whose value is a string containing the
   assembler operation to identify the following data as uninitialized global
   data.  */

#define BSS_SECTION_ASM_OP "\t.section\t.bss"

/* A C statement (sans semicolon) to output to the stdio stream
   FILE the assembler definition of uninitialized global DECL named
   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
   Try to use asm_output_aligned_bss to implement this macro.  */

#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)

/* Output assembler code to FILE to increment profiler label # LABELNO
   for profiling a function entry.  */

#undef FUNCTION_PROFILER
#define FUNCTION_PROFILER(FILE, LABELNO) \
{									\
  asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO));		\
  if (flag_pic)								\
    fprintf (FILE, "\tbsr.l _mcount@PLTPC\n");				\
  else									\
    fprintf (FILE, "\tjbsr _mcount\n");					\
}

/* How to renumber registers for dbx and gdb.
   On the Sun-3, the floating point registers have numbers
   18 to 25, not 16 to 23 as they do in the compiler.  */

#define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)

/* Do not break .stabs pseudos into continuations.  */

#define DBX_CONTIN_LENGTH 0

/* 1 if N is a possible register number for a function value.  For
   m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
   pointer, or floating types, respectively.  Reject fp0 if not using
   a 68881 coprocessor.  */

#undef FUNCTION_VALUE_REGNO_P
#define FUNCTION_VALUE_REGNO_P(N) \
  ((N) == 0 || (N) == 8 || (TARGET_68881 && (N) == 16))

/* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
   more than one register.  */

#undef NEEDS_UNTYPED_CALL
#define NEEDS_UNTYPED_CALL 1

/* Define how to generate (in the callee) the output value of a
   function and how to find (in the caller) the value returned by a
   function.  VALTYPE is the data type of the value (as a tree).  If
   the precise function being called is known, FUNC is its
   FUNCTION_DECL; otherwise, FUNC is 0.  For m68k/SVR4 generate the
   result in d0, a0, or fp0 as appropriate.  */

#undef FUNCTION_VALUE
#define FUNCTION_VALUE(VALTYPE, FUNC)					\
  (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881			\
   ? gen_rtx_REG (TYPE_MODE (VALTYPE), 16)				\
   : (POINTER_TYPE_P (VALTYPE)						\
      ? gen_rtx_REG (TYPE_MODE (VALTYPE), 8)				\
      : gen_rtx_REG (TYPE_MODE (VALTYPE), 0)))

/* For compatibility with the large body of existing code which does
   not always properly declare external functions returning pointer
   types, the m68k/SVR4 convention is to copy the value returned for
   pointer functions from a0 to d0 in the function epilogue, so that
   callers that have neglected to properly declare the callee can
   still find the correct return value.  */

#define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE)				\
do {									\
  if (current_function_returns_pointer					\
      && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode))	\
    asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n");				\
} while (0);

/* Define how to find the value returned by a library function
   assuming the value has mode MODE.
   For m68k/SVR4 look for integer values in d0, pointer values in d0
   (returned in both d0 and a0), and floating values in fp0.  */

#undef LIBCALL_VALUE
#define LIBCALL_VALUE(MODE)						\
  ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode)		\
    && TARGET_68881)							\
   ? gen_rtx_REG ((MODE), 16)						\
   : gen_rtx_REG ((MODE), 0))

/* For m68k SVR4, structures are returned using the reentrant
   technique.  */
#undef PCC_STATIC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 0

/* Finalize the trampoline by flushing the insn cache.  */

#undef FINALIZE_TRAMPOLINE
#define FINALIZE_TRAMPOLINE(TRAMP)					\
  emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"),	\
		     LCT_NORMAL, VOIDmode, TRAMP, Pmode,			\
		     plus_constant (Pmode, TRAMP, TRAMPOLINE_SIZE), \
		     Pmode);

/* Clear the instruction cache from `beg' to `end'.  This makes an
   inline system call to SYS_cacheflush.  The arguments are as
   follows:

	cacheflush (addr, scope, cache, len)

   addr	  - the start address for the flush
   scope  - the scope of the flush (see the cpush insn)
   cache  - which cache to flush (see the cpush insn)
   len    - a factor relating to the number of flushes to perform:
	    len/16 lines, or len/4096 pages.  */

#define CLEAR_INSN_CACHE(BEG, END)					\
{									\
extern void clear_caches(void *address, int length, unsigned long flags); \
  void *ptr = BEG;							\
  int len = (END - BEG + 32);						\
  clear_caches(ptr, len, 0x0005);					\
}
diff --git a/gcc/gcc/config/mips/haiku.h b/gcc/gcc/config/mips/haiku.h
new file mode 100644
index 0000000..f6d2efb 100644
--- /dev/null
+++ a/gcc/gcc/config/mips/haiku.h
@@ -1,0 +1,44 @@
/* Definitions for MIPS running Haiku
   Copyright (C) 1998, 1999, 2000, 2001, 2002, 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 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, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */


#define TARGET_OS_CPP_BUILTINS()					\
  do									\
    {									\
	builtin_define ("__HAIKU__");					\
	builtin_define ("__MIPS__");					\
	builtin_define ("__MIPSEL__");					\
	builtin_define ("_MIPSEL_");					\
	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
    builtin_define ("__STDC_ISO_10646__=201103L"); \
	builtin_assert ("system=haiku");					\
	if (flag_pic)							\
	  {								\
	    builtin_define ("__PIC__");					\
	    builtin_define ("__pic__");					\
	  }								\
    }									\
  while (0)

#undef	LINK_SPEC
#define LINK_SPEC "%{!o*:-o %b} -m elf_mipsel_haiku %{!r:-shared} %{nostart:-e 0}"

diff --git a/gcc/gcc/config/riscv/haiku.h b/gcc/gcc/config/riscv/haiku.h
new file mode 100644
index 0000000..1338375 100644
--- /dev/null
+++ a/gcc/gcc/config/riscv/haiku.h
@@ -1,0 +1,57 @@
/* Definitions for RISC-V Haiku systems with ELF format.
   Copyright (C) 1998-2017 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/>.  */

#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS()		\
  do									\
    {									\
      builtin_define ("__HAIKU__");					\
      if (POINTER_SIZE == 64)						\
        builtin_define ("__riscv64__");				\
      else											\
        builtin_define ("__riscv32__");				\
      builtin_define ("__RISCV__");					\
      builtin_define ("__riscv__");					\
      builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
      builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
      builtin_define ("__STDC_ISO_10646__=201103L"); \
      builtin_assert ("system=haiku");					\
    }									\
  while (0)

#define MUSL_ABI_SUFFIX \
  "%{mabi=ilp32:-sf}" \
  "%{mabi=ilp32f:-sp}" \
  "%{mabi=ilp32d:}" \
  "%{mabi=lp64:-sf}" \
  "%{mabi=lp64f:-sp}" \
  "%{mabi=lp64d:}" \

#undef LIB_SPEC
// Linux adds -latomic because RISC-V only has word-sized atomics
// Not sure if we really need it though.
#define LIB_SPEC " -lroot "

// riscv.h defines /lib and friends which breaks the sysroot
#undef STARTFILE_PREFIX_SPEC

#define ICACHE_FLUSH_FUNC "__riscv_flush_icache"

#undef	LINK_SPEC
#define LINK_SPEC "%{!o*:-o %b} -melf" XLEN_SPEC "lriscv %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}} -X"
diff --git a/gcc/gcc/config/riscv/t-haiku b/gcc/gcc/config/riscv/t-haiku
new file mode 100644
index 0000000..6cccc72 100644
--- /dev/null
+++ a/gcc/gcc/config/riscv/t-haiku
@@ -1,0 +1,4 @@
# Disable for now, only RV64 on Haiku for the moment
# Only XLEN and ABI affect multilib dir names, e.g. /lib32/ilp32d/
#MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
diff --git a/gcc/gcc/config/rs6000/haiku.h b/gcc/gcc/config/rs6000/haiku.h
new file mode 100644
index 0000000..4dff89e 100644
--- /dev/null
+++ a/gcc/gcc/config/rs6000/haiku.h
@@ -1,0 +1,56 @@
/* Definitions for PowerPC running Haiku
   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005
   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, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */


/* long double is 128 bits wide; the documentation claims
   LIBGCC2_LONG_DOUBLE_TYPE_SIZE to default to LONG_DOUBLE_TYPE_SIZE, but
   it apparently does not */
/*#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE 128
#undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128*/

#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS()					\
  do									\
    {									\
	builtin_define ("__HAIKU__");					\
	builtin_define ("__POWERPC__");					\
	builtin_define ("__powerpc__");					\
	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
    builtin_define ("__STDC_ISO_10646__=201103L"); \
	builtin_assert ("system=haiku");					\
	builtin_assert ("cpu=powerpc");					\
	builtin_assert ("machine=powerpc");					\
	TARGET_OS_SYSV_CPP_BUILTINS ();					\
    }									\
  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 ELF is the default format, we should not use /lib/elf.  */

#undef	LINK_SPEC
#define LINK_SPEC "%{!o*:-o %b} -m elf32ppchaiku %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"
diff --git a/gcc/gcc/config/sparc/haiku.h b/gcc/gcc/config/sparc/haiku.h
new file mode 100644
index 0000000..8c81d7e 100644
--- /dev/null
+++ a/gcc/gcc/config/sparc/haiku.h
@@ -1,0 +1,93 @@
/* 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.  */

#undef	LINK_SPEC
#define LINK_SPEC "-m elf64_sparc %{!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)"

#define HAVE_ENABLE_EXECUTE_STACK

#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

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

#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE 128

/* 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 =

diff --git a/gcc/libgcc/config/aarch64/haiku-unwind.h b/gcc/libgcc/config/aarch64/haiku-unwind.h
new file mode 100644
index 0000000..3c8d33d 100644
--- /dev/null
+++ a/gcc/libgcc/config/aarch64/haiku-unwind.h
@@ -1,0 +1,51 @@
/* DWARF2 EH unwinding support for FreeBSD/ARM64 (aarch64).
   Copyright (C) 2017-2018 Free Software Foundation, Inc.
   Contributed by John Marino <gnugcc@marino.st>

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.

Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.

You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
<http://www.gnu.org/licenses/>.  */

/* Identify a signal frame, and set the frame state data appropriately.
   See unwind-dw2.c for the structs. */

/* Always include AArch64 unwinder header file.  */
#include "config/aarch64/aarch64-unwind.h"

#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <signal.h>

#define REG_NAME(reg)   mc_gpregs.gp_## reg
#define XREG(num)       mc_gpregs.gp_x[num]
#define DARC            __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__

#define MD_FALLBACK_FRAME_STATE_FOR aarch64_haiku_fallback_frame_state

static _Unwind_Reason_Code
aarch64_haiku_fallback_frame_state
(struct _Unwind_Context *context, _Unwind_FrameState *fs)
{
  // For now just signal end of stack. Once the Haiku implementation
  // for AArch64 is more mature we can consider writing something similar
  // to Linux or FreeBSD support.
  return _URC_END_OF_STACK;
}
diff --git a/gcc/libstdc++-v3/config/os/haiku/ctype_base.h b/gcc/libstdc++-v3/config/os/haiku/ctype_base.h
new file mode 100644
index 0000000..86e15cb 100644
--- /dev/null
+++ a/gcc/libstdc++-v3/config/os/haiku/ctype_base.h
@@ -1,0 +1,61 @@
// Locale support -*- C++ -*-

// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library 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.

// This library 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.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

//
// ISO C++ 14882: 22.1  Locales
//

// Default information, may not be appropriate for specific host.

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

  /// @brief  Base class for ctype.
  struct ctype_base
  {
    // Non-standard typedefs.
    typedef const int* 		__to_type;

    // NB: Offsets into ctype<char>::_M_table force a particular size
    // on the mask type. Because of this, we don't use an enum.
    typedef unsigned int 	mask;
    static const mask upper    	= 1 << 0;
    static const mask lower 	= 1 << 1;
    static const mask alpha 	= 1 << 2;
    static const mask digit 	= 1 << 3;
    static const mask xdigit 	= 1 << 4;
    static const mask space 	= 1 << 5;
    static const mask print 	= 1 << 6;
    static const mask graph 	= (1 << 2) | (1 << 3) | (1 << 9); // alnum|punct
    static const mask cntrl 	= 1 << 8;
    static const mask punct 	= 1 << 9;
    static const mask alnum 	= (1 << 2) | (1 << 3);  // alpha|digit
#if __cplusplus >= 201103L

    static const mask blank         = 1 << 10;
#endif
  };

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
diff --git a/gcc/libstdc++-v3/config/os/haiku/ctype_configure_char.cc b/gcc/libstdc++-v3/config/os/haiku/ctype_configure_char.cc
new file mode 100644
index 0000000..35e6b80 100644
--- /dev/null
+++ a/gcc/libstdc++-v3/config/os/haiku/ctype_configure_char.cc
@@ -1,0 +1,99 @@
// Locale support -*- C++ -*-

// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library 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.

// This library 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.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file ctype_configure_char.cc */

//
// ISO C++ 14882: 22.1  Locales
//

#include <locale>
#include <cstdlib>
#include <cstring>

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

// Information as gleaned from /usr/include/ctype.h

  const ctype_base::mask*
  ctype<char>::classic_table() throw()
  { return 0; }

  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
		     size_t __refs) 
  : facet(__refs), _M_del(__table != 0 && __del), 
  _M_toupper(NULL), _M_tolower(NULL), 
  _M_table(__table ? __table : classic_table()) 
  { 
    memset(_M_widen, 0, sizeof(_M_widen));
    _M_widen_ok = 0;
    memset(_M_narrow, 0, sizeof(_M_narrow));
    _M_narrow_ok = 0;
  }

  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) 
  : facet(__refs), _M_del(__table != 0 && __del), 
  _M_toupper(NULL), _M_tolower(NULL), 
  _M_table(__table ? __table : classic_table())
  { 
    memset(_M_widen, 0, sizeof(_M_widen));
    _M_widen_ok = 0;
    memset(_M_narrow, 0, sizeof(_M_narrow));
    _M_narrow_ok = 0;
  }

  char
  ctype<char>::do_toupper(char __c) const
  { return ::toupper((int) __c); }

  const char*
  ctype<char>::do_toupper(char* __low, const char* __high) const
  {
    while (__low < __high)
      {
	*__low = ::toupper((int) *__low);
	++__low;
      }
    return __high;
  }

  char
  ctype<char>::do_tolower(char __c) const
  { return ::tolower((int) __c); }

  const char* 
  ctype<char>::do_tolower(char* __low, const char* __high) const
  {
    while (__low < __high)
      {
	*__low = ::tolower((int) *__low);
	++__low;
      }
    return __high;
  }

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
diff --git a/gcc/libstdc++-v3/config/os/haiku/ctype_inline.h b/gcc/libstdc++-v3/config/os/haiku/ctype_inline.h
new file mode 100644
index 0000000..5b5cc56 100644
--- /dev/null
+++ a/gcc/libstdc++-v3/config/os/haiku/ctype_inline.h
@@ -1,0 +1,173 @@
// Locale support -*- C++ -*-

// Copyright (C) 2000-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library 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.

// This library 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.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file bits/ctype_inline.h
 *  This is an internal header file, included by other library headers.
 *  Do not attempt to use it directly. @headername{locale}
 */

//
// ISO C++ 14882: 22.1  Locales
//
  
// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
// functions go in ctype.cc
  
// The following definitions are portable, but insanely slow. If one
// cares at all about performance, then specialized ctype
// functionality should be added for the native os in question: see
// the config/os/bits/ctype_*.h files.

// Constructing a synthetic "C" table should be seriously considered...

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

  bool
  ctype<char>::
  is(mask __m, char __c) const
  { 
    if (_M_table)
      return _M_table[static_cast<unsigned char>(__c)] & __m;
    else
      {
	bool __ret = false;
	const size_t __bitmasksize = 15; 
	size_t __bitcur = 0; // Lowest bitmask in ctype_base == 0
	for (; __bitcur <= __bitmasksize; ++__bitcur)
	  {
	    const mask __bit = static_cast<mask>(1 << __bitcur);
	    if (__m & __bit)
	      {
		bool __testis;
		switch (__bit)
		  {
		  case space:
		    __testis = isspace(__c);
		    break;
		  case print:
		    __testis = isprint(__c);
		    break;
		  case cntrl:
		    __testis = iscntrl(__c);
		    break;
		  case upper:
		    __testis = isupper(__c);
		    break;
		  case lower:
		    __testis = islower(__c);
		    break;
		  case alpha:
		    __testis = isalpha(__c);
		    break;
		  case digit:
		    __testis = isdigit(__c);
		    break;
		  case punct:
		    __testis = ispunct(__c);
		    break;
		  case xdigit:
		    __testis = isxdigit(__c);
		    break;
		  case alnum:
		    __testis = isalnum(__c);
		    break;
		  case graph:
		    __testis = isgraph(__c);
		    break;
#if __cplusplus >= 201103L

		  case blank:
		    __testis = isblank(__c);
		    break;
#endif
		  default:
		    __testis = false;
		    break;
		  }
		__ret |= __testis;
	      }
	  }
	return __ret;
      }
  }
   
  const char*
  ctype<char>::
  is(const char* __low, const char* __high, mask* __vec) const
  {
    if (_M_table)
      while (__low < __high)
	*__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
    else
      {
	// Highest bitmask in ctype_base == 11.
	const size_t __bitmasksize = 15; 
	for (;__low < __high; ++__vec, ++__low)
	  {
	    mask __m = 0;
	    // Lowest bitmask in ctype_base == 0
	    size_t __i = 0; 
	    for (;__i <= __bitmasksize; ++__i)
	      {
		const mask __bit = static_cast<mask>(1 << __i);
		if (this->is(__bit, *__low))
		  __m |= __bit;
	      }
	    *__vec = __m;
	  }
      }
    return __high;
  }

  const char*
  ctype<char>::
  scan_is(mask __m, const char* __low, const char* __high) const
  {
    if (_M_table)
      while (__low < __high
	     && !(_M_table[static_cast<unsigned char>(*__low)] & __m))
	++__low;
    else
      while (__low < __high && !this->is(__m, *__low))
	++__low;
    return __low;
  }

  const char*
  ctype<char>::
  scan_not(mask __m, const char* __low, const char* __high) const
  {
    if (_M_table)
      while (__low < __high
	     && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
	++__low;
    else
      while (__low < __high && this->is(__m, *__low) != 0)
	++__low;
    return __low;
  }

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
diff --git a/gcc/libstdc++-v3/config/os/haiku/error_constants.h b/gcc/libstdc++-v3/config/os/haiku/error_constants.h
new file mode 100644
index 0000000..fa6d889 100644
--- /dev/null
+++ a/gcc/libstdc++-v3/config/os/haiku/error_constants.h
@@ -1,0 +1,178 @@
// Specific definitions for generic platforms  -*- C++ -*-

// Copyright (C) 2007-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library 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.

// This library 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.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file bits/error_constants.h
 *  This is an internal header file, included by other library headers.
 *  Do not attempt to use it directly. @headername{system_error}
 */

#ifndef _GLIBCXX_ERROR_CONSTANTS
#define _GLIBCXX_ERROR_CONSTANTS 1

#include <bits/c++config.h>
#include <cerrno>

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

  enum class errc
    {
      address_family_not_supported = 		EAFNOSUPPORT,
      address_in_use = 				EADDRINUSE,
      address_not_available = 			EADDRNOTAVAIL,
      already_connected = 			EISCONN,
      argument_list_too_long = 			E2BIG,
      argument_out_of_domain = 			EDOM,
      bad_address = 				EFAULT,
      bad_file_descriptor = 			EBADF,

#ifdef _GLIBCXX_HAVE_EBADMSG
      bad_message = 				EBADMSG,
#endif

      broken_pipe = 				EPIPE,
      connection_aborted = 			ECONNABORTED,
      connection_already_in_progress = 		EALREADY,
      connection_refused = 			ECONNREFUSED,
      connection_reset = 			ECONNRESET,
      cross_device_link = 			EXDEV,
      destination_address_required = 		EDESTADDRREQ,
      device_or_resource_busy = 		EBUSY,
      directory_not_empty = 			ENOTEMPTY,
      executable_format_error = 		ENOEXEC,
      file_exists = 	       			EEXIST,
      file_too_large = 				EFBIG,
      filename_too_long = 			ENAMETOOLONG,
      function_not_supported = 			ENOSYS,
      host_unreachable = 			EHOSTUNREACH,

#ifdef _GLIBCXX_HAVE_EIDRM
      identifier_removed = 			EIDRM,
#endif

      illegal_byte_sequence = 			EILSEQ,
      inappropriate_io_control_operation = 	ENOTTY,
      interrupted = 				EINTR,
      invalid_argument = 			EINVAL,
      invalid_seek = 				ESPIPE,
      io_error = 				EIO,
      is_a_directory = 				EISDIR,
      message_size = 				EMSGSIZE,
      network_down = 				ENETDOWN,
      network_reset = 				ENETRESET,
      network_unreachable = 			ENETUNREACH,
      no_buffer_space = 			ENOBUFS,
      no_child_process = 			ECHILD,

#ifdef _GLIBCXX_HAVE_ENOLINK
      no_link = 				ENOLINK,
#endif

      no_lock_available = 			ENOLCK,

#ifdef _GLIBCXX_HAVE_ENODATA
      no_message_available = 			ENODATA, 
#endif

      no_message = 				ENOMSG, 
      no_protocol_option = 			ENOPROTOOPT,
      no_space_on_device = 			ENOSPC,

#ifdef _GLIBCXX_HAVE_ENOSR
      no_stream_resources = 			ENOSR,
#endif

      no_such_device_or_address = 		ENXIO,
      no_such_device = 				ENODEV,
      no_such_file_or_directory = 		ENOENT,
      no_such_process = 			ESRCH,
      not_a_directory = 			ENOTDIR,
      not_a_socket = 				ENOTSOCK,

#ifdef _GLIBCXX_HAVE_ENOSTR
      not_a_stream = 				ENOSTR,
#endif

      not_connected = 				ENOTCONN,
      not_enough_memory = 			ENOMEM,

#ifdef _GLIBCXX_HAVE_ENOTSUP
      not_supported = 				ENOTSUP,
#endif

#ifdef _GLIBCXX_HAVE_ECANCELED
      operation_canceled = 			ECANCELED,
#endif

      operation_in_progress = 			EINPROGRESS,
      operation_not_permitted = 		EPERM,
      operation_not_supported = 		EOPNOTSUPP,
      operation_would_block = 			EWOULDBLOCK,

#ifdef _GLIBCXX_HAVE_EOWNERDEAD
      owner_dead = 				EOWNERDEAD,
#endif

      permission_denied = 			EACCES,

#ifdef _GLIBCXX_HAVE_EPROTO
      protocol_error = 				EPROTO,
#endif

      protocol_not_supported = 			EPROTONOSUPPORT,
      read_only_file_system = 			EROFS,
      resource_deadlock_would_occur = 		EDEADLK,
      resource_unavailable_try_again = 		EAGAIN,
      result_out_of_range = 			ERANGE,

#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
      state_not_recoverable = 			ENOTRECOVERABLE,
#endif

#ifdef _GLIBCXX_HAVE_ETIME
      stream_timeout = 				ETIME,
#endif

#ifdef _GLIBCXX_HAVE_ETXTBSY
      text_file_busy = 				ETXTBSY,
#endif

      timed_out = 				ETIMEDOUT,
      too_many_files_open_in_system = 		ENFILE,
      too_many_files_open = 			EMFILE,
      too_many_links = 				EMLINK,
      too_many_symbolic_link_levels = 		ELOOP,

#ifdef _GLIBCXX_HAVE_EOVERFLOW
      value_too_large = 			EOVERFLOW,
#endif

      wrong_protocol_type = 			EPROTOTYPE
    };

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

#endif
diff --git a/gcc/libstdc++-v3/config/os/haiku/os_defines.h b/gcc/libstdc++-v3/config/os/haiku/os_defines.h
new file mode 100644
index 0000000..02c8693 100644
--- /dev/null
+++ a/gcc/libstdc++-v3/config/os/haiku/os_defines.h
@@ -1,0 +1,48 @@
// Specific definitions for generic platforms  -*- C++ -*-

// Copyright (C) 2000-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library 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.

// This library 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.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file bits/os_defines.h
 *  This is an internal header file, included by other library headers.
 *  Do not attempt to use it directly. @headername{iosfwd}
 */

#ifndef _GLIBCXX_OS_DEFINES
#define _GLIBCXX_OS_DEFINES 1

// System-specific #define, typedefs, corrections, etc, go here.  This
// file will come before all others.

// On Haiku, nanosleep and sched_yield are always available except for the
// kernel and the bootloader, so use them.
#if !defined(_KERNEL_MODE) && !defined(_LOADER_MODE)

	#define _GLIBCXX_USE_NANOSLEEP 1
	#define _GLIBCXX_USE_SCHED_YIELD 1
	#define _GLIBCXX_USE_CLOCK_MONOTONIC 1
	#define _GLIBCXX_USE_CLOCK_REALTIME 1
#endif

// See libstdc++/69506
#define _GLIBCXX_USE_WEAK_REF 0

#endif