Fennix/tools/gcc.patch
2024-11-26 03:27:08 +02:00

158 lines
5.0 KiB
Diff

diff --git a/config.sub b/config.sub
index 38f3d037a78..e15a98ae991 100755
--- a/config.sub
+++ b/config.sub
@@ -1749,7 +1749,7 @@ case $os in
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
- | fiwix* )
+ | fiwix* | fennix* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 95c91ee02be..2f3e3b006dd 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -825,6 +825,14 @@ case ${target} in
rust_target_objs="${rust_target_objs} dragonfly-rust.o"
target_has_targetrustm=yes
;;
+*-*-fennix*)
+ tmake_file="t-fennix "
+ gas=yes
+ gnu_ld=yes
+ default_use_cxa_atexit=yes
+ use_gcc_stdint=provide
+ native_system_header_dir=/include
+ ;;
*-*-freebsd*)
# This is the generic ELF configuration of FreeBSD. Later
# machine-specific sections may refine and add to this
@@ -1981,6 +1989,14 @@ x86_64-*-openbsd*)
gas=yes
gnu_ld=yes
;;
+i[34567]86-*-fennix*)
+ tmake_file="${tmake_file} i386/t-fennix"
+ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h glibc-stdint.h i386/i386elf.h fennix.h"
+ ;;
+x86_64-*-fennix*)
+ tmake_file="${tmake_file} i386/t-fennix"
+ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h fennix.h"
+ ;;
i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-gnu* | i[34567]86-*-kopensolaris*-gnu)
# Intel 80386's running GNU/*
# with ELF format using glibc 2
diff --git a/gcc/config/fennix.h b/gcc/config/fennix.h
new file mode 100644
index 00000000000..3739abe7983
--- /dev/null
+++ b/gcc/config/fennix.h
@@ -0,0 +1,59 @@
+
+#undef TARGET_FENNIX
+#define TARGET_FENNIX 1
+
+#undef LIB_SPEC
+#define LIB_SPEC "-lc"
+
+#undef CPP_SPEC
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC \
+ "crti.o%s \
+ %{!shared: \
+ %{!static: \
+ crtbeginS.o%s Scrt1.o%s \
+ } \
+ } \
+ %{static:crtbegin.o%s crt1.o%s}"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC \
+ "crtn.o%s \
+ %{!shared: \
+ %{!static: \
+ crtendS.o%s \
+ } \
+ } \
+ %{static:crtend.o%s}"
+
+#undef STANDARD_STARTFILE_PREFIX
+#define STANDARD_STARTFILE_PREFIX "/lib/"
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "%{shared:-shared} \
+ %{static:-static} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+ } \
+ } \
+ %{!static: \
+ %{!dynamic-linker: \
+ -dynamic-linker=/lib/ld.so \
+ } \
+ } \
+ -z max-page-size=4096"
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+ do \
+ { \
+ builtin_define("__fennix__"); \
+ builtin_define("__unix__"); \
+ builtin_assert("system=fennix"); \
+ builtin_assert("system=unix"); \
+ builtin_assert("system=posix"); \
+ } while (0);
diff --git a/gcc/config/i386/t-fennix b/gcc/config/i386/t-fennix
new file mode 100644
index 00000000000..8223e63c0c9
--- /dev/null
+++ b/gcc/config/i386/t-fennix
@@ -0,0 +1,2 @@
+MULTILIB_OPTIONS += mno-red-zone
+MULTILIB_DIRNAMES += no-red-zone
diff --git a/libgcc/config.host b/libgcc/config.host
index e75a7af647f..12ecba7be60 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -760,6 +760,14 @@ x86_64-*-dragonfly*)
tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
md_unwind_header=i386/dragonfly-unwind.h
;;
+i[34567]86-*-fennix*)
+ extra_parts="$extra_parts crti.o crtn.o crtbegin.o crtend.o crtbeginS.o crtendS.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
+x86_64-*-fennix*)
+ extra_parts="$extra_parts crti.o crtn.o crtbegin.o crtend.o crtbeginS.o crtendS.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
i[34567]86-*-freebsd*)
tmake_file="${tmake_file} i386/t-freebsd i386/t-crtstuff"
md_unwind_header=i386/freebsd-unwind.h
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index b3269cb88e0..de1f886b9a6 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -88,6 +88,13 @@ case "${host}" in
AC_DEFINE(HAVE_HYPOT)
;;
+ *-fennix*)
+ GLIBCXX_CHECK_COMPILER_FEATURES
+ GLIBCXX_CHECK_LINKER_FEATURES
+ GLIBCXX_CHECK_MATH_SUPPORT
+ GLIBCXX_CHECK_STDLIB_SUPPORT
+ ;;
+
*-freebsd*)
SECTION_FLAGS='-ffunction-sections -fdata-sections'
AC_SUBST(SECTION_FLAGS)