mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:27:35 +00:00
Toolchain+Ports: Split the GCC patches
This shouldn't cause any breaking changes, so a toolchain rebuild is not required. As per Hendiadyoin's request, math errno is disabled by default, which should enable some extra compiler optimizations in LibGL and LibSoftGPU code that uses math functions heavily. Co-Authored-By: Ali Mohammad Pur <mpfard@serenityos.org>
This commit is contained in:
parent
83aa5dcbf6
commit
d0edf2627c
15 changed files with 538 additions and 347 deletions
178
Toolchain/Patches/gcc/0001-Add-a-gcc-driver-for-SerenityOS.patch
Normal file
178
Toolchain/Patches/gcc/0001-Add-a-gcc-driver-for-SerenityOS.patch
Normal file
|
@ -0,0 +1,178 @@
|
|||
From 00ad6c7f79fffa5fe13a9e5b77ad06e987fde3e8 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Kling <awesomekling@gmail.com>
|
||||
Date: Fri, 5 Apr 2019 03:02:52 +0200
|
||||
Subject: [PATCH 1/6] Add a gcc driver for SerenityOS
|
||||
|
||||
This patch adds support for the `*-*-serenity` target to gcc.
|
||||
|
||||
It specifies which flags need to be passed to the linker, defines the
|
||||
__serenity__ macro, sets the correct underlying type of `size_t` and
|
||||
`ptrdiff_t`, and enables IFUNCs.
|
||||
|
||||
Co-Authored-By: Gunnar Beutner <gbeutner@serenityos.org>
|
||||
Co-Authored-By: Itamar <itamar8910@gmail.com>
|
||||
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
|
||||
Co-Authored-By: Nico Weber <thakis@chromium.org>
|
||||
Co-Authored-By: Tim Schumacher <timschumi@gmx.de>
|
||||
Co-Authored-By: Andrew Kaster <andrewdkaster@gmail.com>
|
||||
Co-Authored-By: Brian Gianforcaro <bgianf@serenityos.org>
|
||||
Co-Authored-By: Philip Herron <herron.philip@googlemail.com>
|
||||
Co-Authored-By: Shannon Booth <shannon.ml.booth@gmail.com>
|
||||
---
|
||||
gcc/config.gcc | 20 ++++++++++++++++
|
||||
gcc/config/i386/serenity.h | 7 ++++++
|
||||
gcc/config/serenity.h | 47 ++++++++++++++++++++++++++++++++++++++
|
||||
gcc/config/serenity.opt | 35 ++++++++++++++++++++++++++++
|
||||
4 files changed, 109 insertions(+)
|
||||
create mode 100644 gcc/config/i386/serenity.h
|
||||
create mode 100644 gcc/config/serenity.h
|
||||
create mode 100644 gcc/config/serenity.opt
|
||||
|
||||
diff --git a/gcc/config.gcc b/gcc/config.gcc
|
||||
index c5064dd37..f8a468c6f 100644
|
||||
--- a/gcc/config.gcc
|
||||
+++ b/gcc/config.gcc
|
||||
@@ -673,6 +673,13 @@ x86_cpus="generic intel"
|
||||
|
||||
# Common parts for widely ported systems.
|
||||
case ${target} in
|
||||
+*-*-serenity*)
|
||||
+ gas=yes
|
||||
+ gnu_ld=yes
|
||||
+ default_use_cxa_atexit=yes
|
||||
+ extra_options="${extra_options} serenity.opt"
|
||||
+ tmake_file="t-slibgcc"
|
||||
+ ;;
|
||||
*-*-darwin*)
|
||||
tmake_file="t-darwin "
|
||||
tm_file="${tm_file} darwin.h"
|
||||
@@ -1087,6 +1094,19 @@ case ${target} in
|
||||
esac
|
||||
|
||||
case ${target} in
|
||||
+i[34567]86-*-serenity*)
|
||||
+ default_gnu_indirect_function=yes
|
||||
+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h glibc-stdint.h i386/i386elf.h serenity.h i386/serenity.h"
|
||||
+ ;;
|
||||
+x86_64-*-serenity*)
|
||||
+ default_gnu_indirect_function=yes
|
||||
+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h serenity.h i386/serenity.h"
|
||||
+ ;;
|
||||
+aarch64-*-serenity*)
|
||||
+ default_gnu_indirect_function=yes
|
||||
+ tm_file="${tm_file} dbxelf.h elfos.h aarch64/aarch64-elf.h glibc-stdint.h serenity.h"
|
||||
+ tmake_file="${tmake_file} aarch64/t-aarch64"
|
||||
+ ;;
|
||||
aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
|
||||
tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
|
||||
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-elf-raw.h"
|
||||
diff --git a/gcc/config/i386/serenity.h b/gcc/config/i386/serenity.h
|
||||
new file mode 100644
|
||||
index 000000000..53a4b8e93
|
||||
--- /dev/null
|
||||
+++ b/gcc/config/i386/serenity.h
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* Ensure that we are using the SIZE_TYPE indicated by SysV */
|
||||
+#undef SIZE_TYPE
|
||||
+#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
|
||||
+
|
||||
+/* Ensure that ptrdiff_t matches the actual pointer size */
|
||||
+#undef PTRDIFF_TYPE
|
||||
+#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
|
||||
diff --git a/gcc/config/serenity.h b/gcc/config/serenity.h
|
||||
new file mode 100644
|
||||
index 000000000..dc2f5361e
|
||||
--- /dev/null
|
||||
+++ b/gcc/config/serenity.h
|
||||
@@ -0,0 +1,47 @@
|
||||
+/* Useful if you wish to make target-specific GCC changes. */
|
||||
+#undef TARGET_SERENITY
|
||||
+#define TARGET_SERENITY 1
|
||||
+
|
||||
+#if defined(HAVE_LD_EH_FRAME_HDR)
|
||||
+#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
|
||||
+#endif
|
||||
+
|
||||
+/* Default arguments you want when running your
|
||||
+ i686-serenity-gcc/x86_64-serenity-gcc toolchain */
|
||||
+#undef LIB_SPEC
|
||||
+#define LIB_SPEC "%{pthread:-lpthread} -lc" /* link against C standard library */
|
||||
+
|
||||
+/* Files that are linked before user code.
|
||||
+ The %s tells GCC to look for these files in the library directory. */
|
||||
+#undef STARTFILE_SPEC
|
||||
+#define STARTFILE_SPEC "%{!shared:crt0.o%s} crti.o%s %{shared: %{!fbuilding-libgcc:crt0_shared.o%s}} %{shared|static-pie|!no-pie:crtbeginS.o%s; :crtbegin.o%s}"
|
||||
+
|
||||
+/* Files that are linked after user code. */
|
||||
+#undef ENDFILE_SPEC
|
||||
+#define ENDFILE_SPEC "%{shared|static-pie|!no-pie:crtendS.o%s; :crtend.o%s} crtn.o%s"
|
||||
+
|
||||
+#undef LINK_SPEC
|
||||
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!static: %{rdynamic:-export-dynamic} -dynamic-linker /usr/lib/Loader.so}"
|
||||
+
|
||||
+#undef CC1_SPEC
|
||||
+#define CC1_SPEC "-ftls-model=initial-exec %{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}} -fno-semantic-interposition"
|
||||
+
|
||||
+#undef CC1PLUS_SPEC
|
||||
+#define CC1PLUS_SPEC "-ftls-model=initial-exec"
|
||||
+
|
||||
+#undef CPP_SPEC
|
||||
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
|
||||
+
|
||||
+/* Use --as-needed -lgcc_s for eh support. */
|
||||
+#define USE_LD_AS_NEEDED 1
|
||||
+
|
||||
+/* Additional predefined macros. */
|
||||
+#undef TARGET_OS_CPP_BUILTINS
|
||||
+#define TARGET_OS_CPP_BUILTINS() \
|
||||
+ do { \
|
||||
+ builtin_define ("__serenity__"); \
|
||||
+ builtin_define ("__unix__"); \
|
||||
+ builtin_assert ("system=serenity"); \
|
||||
+ builtin_assert ("system=unix"); \
|
||||
+ builtin_assert ("system=posix"); \
|
||||
+ } while(0);
|
||||
diff --git a/gcc/config/serenity.opt b/gcc/config/serenity.opt
|
||||
new file mode 100644
|
||||
index 000000000..2756a5575
|
||||
--- /dev/null
|
||||
+++ b/gcc/config/serenity.opt
|
||||
@@ -0,0 +1,35 @@
|
||||
+; SerenityOS options.
|
||||
+
|
||||
+; Copyright (C) 2021 Gunnar Beutner <gunnar@beutner.name>
|
||||
+;
|
||||
+; 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/>.
|
||||
+
|
||||
+; See the GCC internals manual (options.texi) for a description of
|
||||
+; this file's format.
|
||||
+
|
||||
+; Please try to keep this file in ASCII collating order.
|
||||
+
|
||||
+posix
|
||||
+Driver
|
||||
+
|
||||
+pthread
|
||||
+Driver
|
||||
+
|
||||
+rdynamic
|
||||
+Driver
|
||||
+
|
||||
+; This comment is to ensure we retain the blank line above.
|
||||
--
|
||||
2.36.1
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue