diff -Naur gcc-11.2.0-orig/config.sub gcc-11.2.0/config.sub --- gcc-11.2.0-orig/config.sub 2021-07-28 08:55:06.620278039 +0200 +++ gcc-11.2.0/config.sub 2021-09-17 23:35:01.028076318 +0200 @@ -1725,6 +1725,7 @@ | skyos* | haiku* | rdos* | toppers* | drops* | es* \ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | karlos* \ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*) ;; # This one is extra strict with allowed versions diff -Naur gcc-11.2.0-orig/fixincludes/mkfixinc.sh gcc-11.2.0/fixincludes/mkfixinc.sh --- gcc-11.2.0-orig/fixincludes/mkfixinc.sh 2021-07-28 08:55:06.644278372 +0200 +++ gcc-11.2.0/fixincludes/mkfixinc.sh 2021-09-17 23:56:39.729512958 +0200 @@ -20,6 +20,7 @@ powerpcle-*-eabisim* | \ powerpcle-*-eabi* | \ *-*-vxworks7* | \ + *-*-karlos* | \ *-musl* ) # IF there is no include fixing, # THEN create a no-op fixer and exit diff -Naur gcc-11.2.0-orig/gcc/config/karlos.h gcc-11.2.0/gcc/config/karlos.h --- gcc-11.2.0-orig/gcc/config/karlos.h 1970-01-01 01:00:00.000000000 +0100 +++ gcc-11.2.0/gcc/config/karlos.h 2021-09-17 23:59:55.059154015 +0200 @@ -0,0 +1,24 @@ +#undef TARGET_KARLOS +#define TARGET_KARLOS 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 STANDARD_STARTFILE_PREFIX +#define STANDARD_STARTFILE_PREFIX "/lib/" + +#undef TARGET_OS_CPP_BUILTINS +#define TARGET_OS_CPP_BUILTINS() \ + do { \ + builtin_define ("__karlos__"); \ + builtin_define ("__unix__"); \ + builtin_assert ("system=karlos"); \ + builtin_assert ("system=unix"); \ + builtin_assert ("system=posix"); \ + } while(0); diff -Naur gcc-11.2.0-orig/gcc/config/i386/t-karlos gcc-11.2.0/gcc/config/i386/t-karlos --- gcc-11.2.0-orig/gcc/config/i386/t-karlos 1970-01-01 01:00:00.000000000 +0100 +++ gcc-11.2.0/gcc/config/i386/t-karlos 2021-09-18 00:10:44.930613877 +0200 @@ -0,0 +1,2 @@ +MULTILIB_OPTIONS += mno-red-zone +MULTILIB_DIRNAMES += no-red-zone diff -Naur gcc-11.2.0-orig/gcc/config.gcc gcc-11.2.0/gcc/config.gcc --- gcc-11.2.0-orig/gcc/config.gcc 2021-07-28 08:55:07.000283339 +0200 +++ gcc-11.2.0/gcc/config.gcc 2021-09-18 00:59:44.265308559 +0200 @@ -686,6 +686,13 @@ # Common parts for widely ported systems. case ${target} in +*-*-karlos*) + gas=yes + gnu_ld=yes + default_use_cxa_exit=yes + use_gcc_stdint="provide" + native_system_header_dir="/include" + ;; *-*-darwin*) tmake_file="t-darwin " tm_file="${tm_file} darwin.h" @@ -1909,6 +1916,10 @@ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h i386/rdos.h i386/rdos64.h" tmake_file="i386/t-i386elf t-svr4" ;; +x86_64-*-karlos*) + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h karlos.h" + tmake_file="${tmake_file} i386/t-karlos" + ;; i[34567]86-*-dragonfly*) tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h dragonfly.h dragonfly-stdint.h i386/dragonfly.h" tmake_file="${tmake_file} i386/t-crtstuff" diff -Naur gcc-11.2.0-orig/libgcc/config.host gcc-11.2.0/libgcc/config.host --- gcc-11.2.0-orig/libgcc/config.host 2021-07-28 08:55:08.752307785 +0200 +++ gcc-11.2.0/libgcc/config.host 2021-09-18 01:01:00.231946788 +0200 @@ -676,6 +676,10 @@ hppa*-*-netbsd*) tmake_file="$tmake_file pa/t-netbsd" ;; +x86_64-*-karlos*) + tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" + extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o" + ;; i[34567]86-*-darwin*) tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi" tm_file="$tm_file i386/darwin-lib.h" diff -Naur gcc-11.2.0-orig/libgcc/libgcov.h gcc-11.2.0/libgcc/libgcov.h --- gcc-11.2.0-orig/libgcc/libgcov.h 2021-07-28 08:55:08.812308622 +0200 +++ gcc-11.2.0/libgcc/libgcov.h 2021-09-18 01:33:51.204505811 +0200 @@ -183,6 +183,11 @@ #endif #include "gcov-io.h" +/* NOTE(Thomas Oltmann): I have no idea why stdint isn't included by + * default, and I suspect this modification isn't the right way to go + * about this. But still, managarm gets away with the same solution, + * so it's probably alright. */ +#include /* Structures embedded in coveraged program. The structures generated by write_profile must match these. */