From d0edf2627c3d72fa1d59ba173bac1c0cc3cb27e9 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Tue, 17 May 2022 09:52:17 +0430 Subject: [PATCH] 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 --- .github/workflows/cmake.yml | 4 +- .../workflows/pvs-studio-static-analysis.yml | 4 +- .../workflows/sonar-cloud-static-analysis.yml | 4 +- Meta/Azure/Caches.yml | 2 +- Ports/gcc/patches | 1 + Ports/gcc/patches/gcc.patch | 1 - Toolchain/BuildIt.sh | 12 +- Toolchain/Patches/gcc.patch | 332 ------------------ ...0001-Add-a-gcc-driver-for-SerenityOS.patch | 178 ++++++++++ ...includes-Skip-for-SerenityOS-targets.patch | 29 ++ .../0003-libgcc-Build-for-SerenityOS.patch | 82 +++++ ...-libgcc-Do-not-link-libgcc_s-to-LibC.patch | 33 ++ ...86-Disable-math-errno-for-SerenityOS.patch | 30 ++ .../gcc/0006-libstdc-Support-SerenityOS.patch | 120 +++++++ Toolchain/Patches/gcc/ReadMe.md | 53 +++ 15 files changed, 538 insertions(+), 347 deletions(-) create mode 120000 Ports/gcc/patches delete mode 120000 Ports/gcc/patches/gcc.patch delete mode 100644 Toolchain/Patches/gcc.patch create mode 100644 Toolchain/Patches/gcc/0001-Add-a-gcc-driver-for-SerenityOS.patch create mode 100644 Toolchain/Patches/gcc/0002-fixincludes-Skip-for-SerenityOS-targets.patch create mode 100644 Toolchain/Patches/gcc/0003-libgcc-Build-for-SerenityOS.patch create mode 100644 Toolchain/Patches/gcc/0004-libgcc-Do-not-link-libgcc_s-to-LibC.patch create mode 100644 Toolchain/Patches/gcc/0005-i386-Disable-math-errno-for-SerenityOS.patch create mode 100644 Toolchain/Patches/gcc/0006-libstdc-Support-SerenityOS.patch create mode 100644 Toolchain/Patches/gcc/ReadMe.md diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 03d3f0710c7..4ec7778f19d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -76,8 +76,8 @@ jobs: # *and* as actual output variable, in this order. message(" set-output name=time::${current_date}") message("::set-output name=time::${current_date}") - message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}") - message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}") + message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch' 'Toolchain/BuildIt.sh') }}") + message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch' 'Toolchain/BuildIt.sh') }}") - name: Toolchain cache # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. diff --git a/.github/workflows/pvs-studio-static-analysis.yml b/.github/workflows/pvs-studio-static-analysis.yml index c5b93b143a3..29a8be3b0d7 100644 --- a/.github/workflows/pvs-studio-static-analysis.yml +++ b/.github/workflows/pvs-studio-static-analysis.yml @@ -43,8 +43,8 @@ jobs: # *and* as actual output variable, in this order. message(" set-output name=time::${current_date}") message("::set-output name=time::${current_date}") - message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}") - message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}") + message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch' 'Toolchain/BuildIt.sh') }}") + message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch' 'Toolchain/BuildIt.sh') }}") - name: Toolchain cache # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. diff --git a/.github/workflows/sonar-cloud-static-analysis.yml b/.github/workflows/sonar-cloud-static-analysis.yml index 43b65321661..a72218940ab 100644 --- a/.github/workflows/sonar-cloud-static-analysis.yml +++ b/.github/workflows/sonar-cloud-static-analysis.yml @@ -76,8 +76,8 @@ jobs: # *and* as actual output variable, in this order. message(" set-output name=time::${current_date}") message("::set-output name=time::${current_date}") - message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}") - message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/BuildIt.sh') }}") + message(" set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch' 'Toolchain/BuildIt.sh') }}") + message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch' 'Toolchain/BuildIt.sh') }}") - name: Toolchain cache # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. diff --git a/Meta/Azure/Caches.yml b/Meta/Azure/Caches.yml index 1865918af29..9be6792cd03 100644 --- a/Meta/Azure/Caches.yml +++ b/Meta/Azure/Caches.yml @@ -25,7 +25,7 @@ steps: - ${{ if eq(parameters.toolchain, 'gcc') }}: - task: Cache@2 inputs: - key: '"toolchain" | "${{ parameters.arch }}" | Toolchain/BuildIt.sh | Toolchain/Patches/{gcc*,binutils}.patch | Userland/Libraries/LibC/**/*.h | Userland/Libraries/LibPthread/**/*.h' + key: '"toolchain" | "${{ parameters.arch }}" | Toolchain/BuildIt.sh | Toolchain/Patches/binutils.patch | Toolchain/Patches/gcc/*.patch | Userland/Libraries/LibC/**/*.h | Userland/Libraries/LibPthread/**/*.h' path: $(Build.SourcesDirectory)/Toolchain/Cache displayName: 'Toolchain Prebuilt Cache' diff --git a/Ports/gcc/patches b/Ports/gcc/patches new file mode 120000 index 00000000000..9f4f4cf2c07 --- /dev/null +++ b/Ports/gcc/patches @@ -0,0 +1 @@ +../../Toolchain/Patches/gcc \ No newline at end of file diff --git a/Ports/gcc/patches/gcc.patch b/Ports/gcc/patches/gcc.patch deleted file mode 120000 index 4008c90846e..00000000000 --- a/Ports/gcc/patches/gcc.patch +++ /dev/null @@ -1 +0,0 @@ -../../../Toolchain/Patches/gcc.patch \ No newline at end of file diff --git a/Toolchain/BuildIt.sh b/Toolchain/BuildIt.sh index d471fec6a9a..6a003e32ef2 100755 --- a/Toolchain/BuildIt.sh +++ b/Toolchain/BuildIt.sh @@ -271,11 +271,13 @@ pushd "$DIR/Tarballs" git init > /dev/null git add . > /dev/null git commit -am "BASE" > /dev/null - git apply "$DIR"/Patches/gcc.patch > /dev/null + git am --keep-non-patch "$DIR"/Patches/gcc/*.patch > /dev/null else - patch -p1 < "$DIR/Patches/gcc.patch" > /dev/null + for patch in "$DIR"/Patches/gcc/*.patch; do + patch -p1 < "$patch" > /dev/null + done fi - $MD5SUM "$DIR/Patches/gcc.patch" > .patch.applied + $MD5SUM $DIR/Patches/gcc/*.patch > .patch.applied popd if [ "$SYSTEM_NAME" = "Darwin" ]; then @@ -392,10 +394,6 @@ pushd "$DIR/Build/$ARCH" perl -pi -e 's/-no-pie/-nopie/g' "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/configure" fi - if [ ! -f "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-userland.h" ]; then - cp "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h" "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-kernel.h" - fi - rm -rf gcc mkdir -p gcc diff --git a/Toolchain/Patches/gcc.patch b/Toolchain/Patches/gcc.patch deleted file mode 100644 index e7dea0504ef..00000000000 --- a/Toolchain/Patches/gcc.patch +++ /dev/null @@ -1,332 +0,0 @@ -diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh -index df90720b7..a45cdd0de 100755 ---- a/fixincludes/mkfixinc.sh -+++ b/fixincludes/mkfixinc.sh -@@ -11,6 +11,7 @@ target=fixinc.sh - - # Check for special fix rules for particular targets - case $machine in -+ *-serenity* | \ - i?86-*-cygwin* | \ - i?86-*-mingw32* | \ - x86_64-*-mingw32* | \ -diff --git a/gcc/common.opt b/gcc/common.opt -index 8a0dafc52..a4f888953 100644 ---- a/gcc/common.opt -+++ b/gcc/common.opt -@@ -3607,4 +3607,8 @@ fipa-ra - Common Var(flag_ipa_ra) Optimization - Use caller save register across calls if possible. - -+arch -+Driver Ignore Separate -+-arch Generate output for architecture . -+ - ; This comment is to ensure we retain the blank line above. -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 -+; -+; 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 -+; . -+ -+; 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. -diff --git a/gcc/configure b/gcc/configure -index 5ce055771..2deaac5bc 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -31608,6 +31608,9 @@ case "$target" in - *-linux-musl*) - gcc_cv_target_dl_iterate_phdr=yes - ;; -+ *-serenity*) -+ gcc_cv_target_dl_iterate_phdr=yes -+ ;; - esac - - if test x$gcc_cv_target_dl_iterate_phdr = xyes; then -diff --git a/libgcc/config.host b/libgcc/config.host -index 8c56fcae5..f5855cfa6 100644 ---- a/libgcc/config.host -+++ b/libgcc/config.host -@@ -1534,6 +1534,22 @@ nvptx-*) - tmake_file="$tmake_file nvptx/t-nvptx" - extra_parts="crt0.o" - ;; -+i[34567]86-*-serenity*) -+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o" -+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-eh-dw2-dip" -+ ;; -+x86_64-*-serenity*) -+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o" -+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-eh-dw2-dip" -+ ;; -+aarch64-*-serenity*) -+ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o" -+ extra_parts="$extra_parts crtfastmath.o" -+ tmake_file="$tmake_file ${cpu_type}/t-aarch64" -+ tmake_file="$tmake_file ${cpu_type}/t-lse t-slibgcc-libgcc" -+ tmake_file="$tmake_file ${cpu_type}/t-softfp t-softp t-crtfm" -+ md_unwind_header=aarch64/aarch64-unwind.h -+ ;; - *) - echo "*** Configuration ${host} not supported" 1>&2 - exit 1 -diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc -index 4efd7b43d..932fa0cfb 100644 ---- a/libgcc/config/t-slibgcc -+++ b/libgcc/config/t-slibgcc -@@ -26,7 +26,6 @@ SHLIB_MAP = @shlib_map_file@ - SHLIB_OBJS = @shlib_objs@ - SHLIB_DIR = @multilib_dir@ - SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual@ --SHLIB_LC = -lc - SHLIB_MAKE_SOLINK = $(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK) - SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \ - $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK) -diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c -index 7f9be5e6b..817c3fe21 100644 ---- a/libgcc/unwind-dw2-fde-dip.c -+++ b/libgcc/unwind-dw2-fde-dip.c -@@ -57,6 +57,12 @@ - # define USE_PT_GNU_EH_FRAME - #endif - -+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ -+ && defined(TARGET_DL_ITERATE_PHDR) \ -+ && defined(__serenity__) -+# define USE_PT_GNU_EH_FRAME -+#endif -+ - #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ - && defined(TARGET_DL_ITERATE_PHDR) \ - && defined(__linux__) -diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 -index 138bd58d8..6cd7564b6 100644 ---- a/libstdc++-v3/acinclude.m4 -+++ b/libstdc++-v3/acinclude.m4 -@@ -1374,7 +1374,7 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ - ac_has_nanosleep=yes - ac_has_sched_yield=yes - ;; -- freebsd*|netbsd*|dragonfly*|rtems*) -+ freebsd*|netbsd*|dragonfly*|rtems*|serenity*) - ac_has_clock_monotonic=yes - ac_has_clock_realtime=yes - ac_has_nanosleep=yes -@@ -2421,7 +2421,7 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ - dragonfly* | freebsd*) - enable_clocale_flag=dragonfly - ;; -- openbsd*) -+ openbsd* | serenity*) - enable_clocale_flag=newlib - ;; - *) -diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure -index 9b94fd71e..51e45878f 100755 ---- a/libstdc++-v3/configure -+++ b/libstdc++-v3/configure -@@ -11914,6 +11914,11 @@ else - lt_cv_dlopen_libs= - ;; - -+ serenity*) -+ lt_cv_dlopen="dlopen" -+ lt_cv_dlopen_libs="-ldl" -+ ;; -+ - darwin*) - # if libdl is installed we need to link against it - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -@@ -16478,7 +16483,7 @@ fi - dragonfly* | freebsd*) - enable_clocale_flag=dragonfly - ;; -- openbsd*) -+ openbsd* | serenity*) - enable_clocale_flag=newlib - ;; - *) -@@ -20569,7 +20574,7 @@ fi - ac_has_nanosleep=yes - ac_has_sched_yield=yes - ;; -- freebsd*|netbsd*|dragonfly*|rtems*) -+ freebsd*|netbsd*|dragonfly*|rtems*|serenity*) - ac_has_clock_monotonic=yes - ac_has_clock_realtime=yes - ac_has_nanosleep=yes -@@ -29245,7 +29250,7 @@ case "${host}" in - # This is a freestanding configuration; there is nothing to do here. - ;; - -- avr*-*-*) -+ avr*-*-* | *serenity*) - $as_echo "#define HAVE_ACOSF 1" >>confdefs.h - - $as_echo "#define HAVE_ASINF 1" >>confdefs.h -diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host -index ec32980aa..e060300f3 100644 ---- a/libstdc++-v3/configure.host -+++ b/libstdc++-v3/configure.host -@@ -297,6 +297,9 @@ case "${host_os}" in - # Use libatomic if necessary and avoid libstdc++ specific atomicity support - atomicity_dir="cpu/generic/atomicity_builtins" - ;; -+ serenity*) -+ os_include_dir="os/newlib" -+ ;; - solaris2*) - os_include_dir="os/solaris" - ;; -diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 -index ae5283b7a..b9fc96e94 100644 ---- a/libstdc++-v3/crossconfig.m4 -+++ b/libstdc++-v3/crossconfig.m4 -@@ -9,7 +9,7 @@ case "${host}" in - # This is a freestanding configuration; there is nothing to do here. - ;; - -- avr*-*-*) -+ avr*-*-* | *serenity*) - AC_DEFINE(HAVE_ACOSF) - AC_DEFINE(HAVE_ASINF) - AC_DEFINE(HAVE_ATAN2F) diff --git a/Toolchain/Patches/gcc/0001-Add-a-gcc-driver-for-SerenityOS.patch b/Toolchain/Patches/gcc/0001-Add-a-gcc-driver-for-SerenityOS.patch new file mode 100644 index 00000000000..2360b95bec3 --- /dev/null +++ b/Toolchain/Patches/gcc/0001-Add-a-gcc-driver-for-SerenityOS.patch @@ -0,0 +1,178 @@ +From 00ad6c7f79fffa5fe13a9e5b77ad06e987fde3e8 Mon Sep 17 00:00:00 2001 +From: Andreas Kling +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 +Co-Authored-By: Itamar +Co-Authored-By: Daniel Bertalan +Co-Authored-By: Nico Weber +Co-Authored-By: Tim Schumacher +Co-Authored-By: Andrew Kaster +Co-Authored-By: Brian Gianforcaro +Co-Authored-By: Philip Herron +Co-Authored-By: Shannon Booth +--- + 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 ++; ++; 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 ++; . ++ ++; 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 + diff --git a/Toolchain/Patches/gcc/0002-fixincludes-Skip-for-SerenityOS-targets.patch b/Toolchain/Patches/gcc/0002-fixincludes-Skip-for-SerenityOS-targets.patch new file mode 100644 index 00000000000..926f4664d3f --- /dev/null +++ b/Toolchain/Patches/gcc/0002-fixincludes-Skip-for-SerenityOS-targets.patch @@ -0,0 +1,29 @@ +From e7d65e2c0943078214d9231cbb5c5e8eb9b5c726 Mon Sep 17 00:00:00 2001 +From: Andreas Kling +Date: Fri, 5 Apr 2019 03:02:52 +0200 +Subject: [PATCH 2/6] fixincludes: Skip for SerenityOS targets + +`fixincludes` is responsible for fixing mistakes in system headers that +rely in compiler extensions that GCC doesn't support or cause errors in +C++ mode. + +Our headers don't have such problems, so this hack is of no use for us. +--- + fixincludes/mkfixinc.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh +index df90720b7..a45cdd0de 100755 +--- a/fixincludes/mkfixinc.sh ++++ b/fixincludes/mkfixinc.sh +@@ -11,6 +11,7 @@ target=fixinc.sh + + # Check for special fix rules for particular targets + case $machine in ++ *-serenity* | \ + i?86-*-cygwin* | \ + i?86-*-mingw32* | \ + x86_64-*-mingw32* | \ +-- +2.36.1 + diff --git a/Toolchain/Patches/gcc/0003-libgcc-Build-for-SerenityOS.patch b/Toolchain/Patches/gcc/0003-libgcc-Build-for-SerenityOS.patch new file mode 100644 index 00000000000..d615a4e8484 --- /dev/null +++ b/Toolchain/Patches/gcc/0003-libgcc-Build-for-SerenityOS.patch @@ -0,0 +1,82 @@ +From 9297a27635e83df95c644b9f776d65078c97162e Mon Sep 17 00:00:00 2001 +From: Andreas Kling +Date: Mon, 16 May 2022 15:01:06 +0200 +Subject: [PATCH 3/6] libgcc: Build for SerenityOS + +This patch enables building gcc's own C runtime files, and sets up +exception handling support. + +Co-Authored-By: Gunnar Beutner +Co-Authored-By: Itamar +Co-Authored-By: Nico Weber +Co-Authored-By: Andrew Kaster +Co-Authored-By: Daniel Bertalan +Co-Authored-By: Philip Herron +Co-Authored-By: Shannon Booth +--- + gcc/configure | 3 +++ + libgcc/config.host | 16 ++++++++++++++++ + libgcc/unwind-dw2-fde-dip.c | 6 ++++++ + 3 files changed, 25 insertions(+) + +diff --git a/gcc/configure b/gcc/configure +index 5ce055771..2deaac5bc 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -31608,6 +31608,9 @@ case "$target" in + *-linux-musl*) + gcc_cv_target_dl_iterate_phdr=yes + ;; ++ *-serenity*) ++ gcc_cv_target_dl_iterate_phdr=yes ++ ;; + esac + + if test x$gcc_cv_target_dl_iterate_phdr = xyes; then +diff --git a/libgcc/config.host b/libgcc/config.host +index 8c56fcae5..f5855cfa6 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -1534,6 +1534,22 @@ nvptx-*) + tmake_file="$tmake_file nvptx/t-nvptx" + extra_parts="crt0.o" + ;; ++i[34567]86-*-serenity*) ++ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o" ++ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-eh-dw2-dip" ++ ;; ++x86_64-*-serenity*) ++ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o" ++ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-eh-dw2-dip" ++ ;; ++aarch64-*-serenity*) ++ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o" ++ extra_parts="$extra_parts crtfastmath.o" ++ tmake_file="$tmake_file ${cpu_type}/t-aarch64" ++ tmake_file="$tmake_file ${cpu_type}/t-lse t-slibgcc-libgcc" ++ tmake_file="$tmake_file ${cpu_type}/t-softfp t-softp t-crtfm" ++ md_unwind_header=aarch64/aarch64-unwind.h ++ ;; + *) + echo "*** Configuration ${host} not supported" 1>&2 + exit 1 +diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c +index 7f9be5e6b..817c3fe21 100644 +--- a/libgcc/unwind-dw2-fde-dip.c ++++ b/libgcc/unwind-dw2-fde-dip.c +@@ -57,6 +57,12 @@ + # define USE_PT_GNU_EH_FRAME + #endif + ++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ ++ && defined(TARGET_DL_ITERATE_PHDR) \ ++ && defined(__serenity__) ++# define USE_PT_GNU_EH_FRAME ++#endif ++ + #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ + && defined(TARGET_DL_ITERATE_PHDR) \ + && defined(__linux__) +-- +2.36.1 + diff --git a/Toolchain/Patches/gcc/0004-libgcc-Do-not-link-libgcc_s-to-LibC.patch b/Toolchain/Patches/gcc/0004-libgcc-Do-not-link-libgcc_s-to-LibC.patch new file mode 100644 index 00000000000..221330925bb --- /dev/null +++ b/Toolchain/Patches/gcc/0004-libgcc-Do-not-link-libgcc_s-to-LibC.patch @@ -0,0 +1,33 @@ +From c4e0f7d997b3f7cd5c5465a636e097e43170d609 Mon Sep 17 00:00:00 2001 +From: Andreas Kling +Date: Mon, 16 May 2022 15:03:14 +0200 +Subject: [PATCH 4/6] libgcc: Do not link libgcc_s to LibC + +The toolchain is built before LibC, so linking to the C runtime library +would fail. + +Co-Authored-By: Gunnar Beutner +Co-Authored-By: Daniel Bertalan +Co-Authored-By: Itamar +Co-Authored-By: Nico Weber +Co-Authored-By: Philip Herron +Co-Authored-By: Shannon Booth +--- + libgcc/config/t-slibgcc | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc +index 4efd7b43d..932fa0cfb 100644 +--- a/libgcc/config/t-slibgcc ++++ b/libgcc/config/t-slibgcc +@@ -26,7 +26,6 @@ SHLIB_MAP = @shlib_map_file@ + SHLIB_OBJS = @shlib_objs@ + SHLIB_DIR = @multilib_dir@ + SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual@ +-SHLIB_LC = -lc + SHLIB_MAKE_SOLINK = $(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK) + SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \ + $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK) +-- +2.36.1 + diff --git a/Toolchain/Patches/gcc/0005-i386-Disable-math-errno-for-SerenityOS.patch b/Toolchain/Patches/gcc/0005-i386-Disable-math-errno-for-SerenityOS.patch new file mode 100644 index 00000000000..404eeecbbe1 --- /dev/null +++ b/Toolchain/Patches/gcc/0005-i386-Disable-math-errno-for-SerenityOS.patch @@ -0,0 +1,30 @@ +From 7cb91a236863aa5c582d25a920ffbb7408c10e2f Mon Sep 17 00:00:00 2001 +From: Daniel Bertalan +Date: Mon, 16 May 2022 15:04:33 +0200 +Subject: [PATCH 5/6] i386: Disable math errno for SerenityOS + +SerenityOS uses exceptions for math error handling, which allows the +compiler to do more optimizations on calls to math functions. This patch +has the effect of setting -fno-math-errno by default. +--- + gcc/common/config/i386/i386-common.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/gcc/common/config/i386/i386-common.cc b/gcc/common/config/i386/i386-common.cc +index 07fdd045f..6e2419563 100644 +--- a/gcc/common/config/i386/i386-common.cc ++++ b/gcc/common/config/i386/i386-common.cc +@@ -1707,6 +1707,10 @@ ix86_option_init_struct (struct gcc_options *opts) + avoid calling them when that's the only reason we would. */ + opts->x_flag_errno_math = 0; + ++#ifdef TARGET_SERENITY ++ opts->x_flag_errno_math = 0; ++#endif ++ + opts->x_flag_pcc_struct_return = 2; + opts->x_flag_asynchronous_unwind_tables = 2; + } +-- +2.36.1 + diff --git a/Toolchain/Patches/gcc/0006-libstdc-Support-SerenityOS.patch b/Toolchain/Patches/gcc/0006-libstdc-Support-SerenityOS.patch new file mode 100644 index 00000000000..1fbb3554b03 --- /dev/null +++ b/Toolchain/Patches/gcc/0006-libstdc-Support-SerenityOS.patch @@ -0,0 +1,120 @@ +From b581fd421af5691bdafda7d30b20723f77d0cc88 Mon Sep 17 00:00:00 2001 +From: Andreas Kling +Date: Mon, 16 May 2022 15:08:53 +0200 +Subject: [PATCH 6/6] libstdc++: Support SerenityOS + +During the toolchain build, SerenityOS libraries are not available, so +we have to manually tell libstdc++ about what our LibC supports. + +In most places, we take the Newlib code paths. + +Co-Authored-By: Gunnar Beutner +Co-Authored-By: Daniel Bertalan +Co-Authored-By: Itamar +Co-Authored-By: James Mintram +Co-Authored-By: Martin Bříza +Co-Authored-By: Nico Weber +Co-Authored-By: Philip Herron +Co-Authored-By: Shannon Booth +--- + libstdc++-v3/acinclude.m4 | 4 ++-- + libstdc++-v3/configure | 11 ++++++++--- + libstdc++-v3/configure.host | 3 +++ + libstdc++-v3/crossconfig.m4 | 2 +- + 4 files changed, 14 insertions(+), 6 deletions(-) + +diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 +index 138bd58d8..6cd7564b6 100644 +--- a/libstdc++-v3/acinclude.m4 ++++ b/libstdc++-v3/acinclude.m4 +@@ -1374,7 +1374,7 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; +- freebsd*|netbsd*|dragonfly*|rtems*) ++ freebsd*|netbsd*|dragonfly*|rtems*|serenity*) + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ac_has_nanosleep=yes +@@ -2421,7 +2421,7 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ + dragonfly* | freebsd*) + enable_clocale_flag=dragonfly + ;; +- openbsd*) ++ openbsd* | serenity*) + enable_clocale_flag=newlib + ;; + *) +diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure +index 9b94fd71e..51e45878f 100755 +--- a/libstdc++-v3/configure ++++ b/libstdc++-v3/configure +@@ -11914,6 +11914,11 @@ else + lt_cv_dlopen_libs= + ;; + ++ serenity*) ++ lt_cv_dlopen="dlopen" ++ lt_cv_dlopen_libs="-ldl" ++ ;; ++ + darwin*) + # if libdl is installed we need to link against it + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +@@ -16478,7 +16483,7 @@ fi + dragonfly* | freebsd*) + enable_clocale_flag=dragonfly + ;; +- openbsd*) ++ openbsd* | serenity*) + enable_clocale_flag=newlib + ;; + *) +@@ -20569,7 +20574,7 @@ fi + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; +- freebsd*|netbsd*|dragonfly*|rtems*) ++ freebsd*|netbsd*|dragonfly*|rtems*|serenity*) + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ac_has_nanosleep=yes +@@ -29245,7 +29250,7 @@ case "${host}" in + # This is a freestanding configuration; there is nothing to do here. + ;; + +- avr*-*-*) ++ avr*-*-* | *serenity*) + $as_echo "#define HAVE_ACOSF 1" >>confdefs.h + + $as_echo "#define HAVE_ASINF 1" >>confdefs.h +diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host +index ec32980aa..e060300f3 100644 +--- a/libstdc++-v3/configure.host ++++ b/libstdc++-v3/configure.host +@@ -297,6 +297,9 @@ case "${host_os}" in + # Use libatomic if necessary and avoid libstdc++ specific atomicity support + atomicity_dir="cpu/generic/atomicity_builtins" + ;; ++ serenity*) ++ os_include_dir="os/newlib" ++ ;; + solaris2*) + os_include_dir="os/solaris" + ;; +diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 +index ae5283b7a..b9fc96e94 100644 +--- a/libstdc++-v3/crossconfig.m4 ++++ b/libstdc++-v3/crossconfig.m4 +@@ -9,7 +9,7 @@ case "${host}" in + # This is a freestanding configuration; there is nothing to do here. + ;; + +- avr*-*-*) ++ avr*-*-* | *serenity*) + AC_DEFINE(HAVE_ACOSF) + AC_DEFINE(HAVE_ASINF) + AC_DEFINE(HAVE_ATAN2F) +-- +2.36.1 + diff --git a/Toolchain/Patches/gcc/ReadMe.md b/Toolchain/Patches/gcc/ReadMe.md new file mode 100644 index 00000000000..0dbae0a2abd --- /dev/null +++ b/Toolchain/Patches/gcc/ReadMe.md @@ -0,0 +1,53 @@ +# Patches for gcc on SerenityOS + +## `0001-Add-a-gcc-driver-for-SerenityOS.patch` + +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. + +## `0002-fixincludes-Skip-for-SerenityOS-targets.patch` + +fixincludes: Skip for SerenityOS targets + +`fixincludes` is responsible for fixing mistakes in system headers that +rely in compiler extensions that GCC doesn't support or cause errors in +C++ mode. + +Our headers don't have such problems, so this hack is of no use for us. + +## `0003-libgcc-Build-for-SerenityOS.patch` + +libgcc: Build for SerenityOS + +This patch enables building gcc's own C runtime files, and sets up +exception handling support. + +## `0004-libgcc-Do-not-link-libgcc_s-to-LibC.patch` + +libgcc: Do not link libgcc_s to LibC + +The toolchain is built before LibC, so linking to the C runtime library +would fail. + +## `0005-i386-Disable-math-errno-for-SerenityOS.patch` + +i386: Disable math errno for SerenityOS + +SerenityOS uses exceptions for math error handling, which allows the +compiler to do more optimizations on calls to math functions. This patch +has the effect of setting -fno-math-errno by default. + +## `0006-libstdc-Support-SerenityOS.patch` + +libstdc++: Support SerenityOS + +During the toolchain build, SerenityOS libraries are not available, so +we have to manually tell libstdc++ about what our LibC supports. + +In most places, we take the Newlib code paths. +