shithub: newlib

ref: 536cef2b2ad9ba00df99f38b8eee764297562799
dir: /patches/gcc-host/jinx-working-patch.patch/

View raw version
diff --git gcc-host-workdir/gcc/config/plan9.h gcc-host-workdir/gcc/config/plan9.h
new file mode 100644
index 0000000..83a3cb1
--- /dev/null
+++ gcc-host-workdir/gcc/config/plan9.h
@@ -0,0 +1,42 @@
+/* Base configuration file for all Plan 9 targets.
+   Copyright (C) 2024 Plan 9 Foundation.
+
+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_PLAN9
+#define TARGET_PLAN9 1
+
+#undef LIB_SPEC
+#define LIB_SPEC "-lc"
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
+
+#undef  TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS()            \
+  do                                        \
+    {                                       \
+       builtin_define ("__unix__");         \
+       builtin_define ("__plan9__");        \
+       builtin_assert ("system=unix");      \
+       builtin_assert ("system=posix");     \
+       builtin_assert ("system=plan9");     \
+    }                                       \
+  while (0)
diff --git gcc-host-clean/gcc/config.gcc gcc-host-workdir/gcc/config.gcc
index 95c91ee..e67b9ca 100644
--- gcc-host-clean/gcc/config.gcc
+++ gcc-host-workdir/gcc/config.gcc
@@ -722,6 +722,12 @@ x86_cpus="generic intel"
 
 # Common parts for widely ported systems.
 case ${target} in
+*-*-plan9*)
+  gas=yes
+  gnu_ld=yes
+  default_use_cxa_atexit=yes
+  use_gcc_stdint=wrap
+  ;;
 *-*-darwin*)
   tmake_file="t-darwin "
   tm_file="${tm_file} darwin.h"
@@ -1189,6 +1195,9 @@ case ${target} in
 esac
 
 case ${target} in
+x86_64-*-plan9*)
+	tm_file="${tm_file} i386/unix.h i386/att.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h plan9.h"
+	;;
 aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
 	tm_file="${tm_file} elfos.h newlib-stdint.h"
 	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-elf-raw.h"
diff --git gcc-host-clean/libgcc/config.host gcc-host-workdir/libgcc/config.host
index e75a7af..ab549d1 100644
--- gcc-host-clean/libgcc/config.host
+++ gcc-host-workdir/libgcc/config.host
@@ -1569,6 +1569,10 @@ nvptx-*)
 	tmake_file="$tmake_file nvptx/t-nvptx"
 	extra_parts="crt0.o"
 	;;
+x86_64-*-plan9*)
+	extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o"
+	tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+	;;
 *)
 	echo "*** Configuration ${host} not supported" 1>&2
 	exit 1