Adapted dabble's GCC patches for KarlOS
This commit is contained in:
commit
e19eecf647
7 changed files with 245 additions and 0 deletions
87
binutils-karlos-target-2.37.diff
Normal file
87
binutils-karlos-target-2.37.diff
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
diff -Naur -x Makefile.in -x aclocal.m4 binutils-2.37-orig/bfd/config.bfd binutils-2.37/bfd/config.bfd
|
||||||
|
--- binutils-2.37-orig/bfd/config.bfd 2021-07-08 13:37:19.000000000 +0200
|
||||||
|
+++ binutils-2.37/bfd/config.bfd 2021-09-17 21:43:33.046584668 +0200
|
||||||
|
@@ -739,6 +739,13 @@
|
||||||
|
targ_underscore=yes
|
||||||
|
;;
|
||||||
|
|
||||||
|
+#ifdef BFD64
|
||||||
|
+ x86_64-*-karlos*)
|
||||||
|
+ targ_defvec=x86_64_elf64_vec
|
||||||
|
+ want64=true
|
||||||
|
+ ;;
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
ia16-*-elf)
|
||||||
|
targ_defvec=i386_elf32_vec
|
||||||
|
targ_selvecs="i386_msdos_vec i386_aout_vec"
|
||||||
|
diff -Naur -x Makefile.in -x aclocal.m4 binutils-2.37-orig/config.sub binutils-2.37/config.sub
|
||||||
|
--- binutils-2.37-orig/config.sub 2021-07-08 13:37:19.000000000 +0200
|
||||||
|
+++ binutils-2.37/config.sub 2021-09-17 21:34:30.728424266 +0200
|
||||||
|
@@ -1729,6 +1729,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 -x Makefile.in -x aclocal.m4 binutils-2.37-orig/gas/configure.tgt binutils-2.37/gas/configure.tgt
|
||||||
|
--- binutils-2.37-orig/gas/configure.tgt 2021-07-08 13:37:19.000000000 +0200
|
||||||
|
+++ binutils-2.37/gas/configure.tgt 2021-09-17 21:43:15.221415056 +0200
|
||||||
|
@@ -259,6 +259,7 @@
|
||||||
|
i386-*-*nt*) fmt=coff em=pe ;;
|
||||||
|
i386-*-rdos*) fmt=elf ;;
|
||||||
|
i386-*-darwin*) fmt=macho ;;
|
||||||
|
+ i386-*-karlos*) fmt=elf ;;
|
||||||
|
|
||||||
|
ia16-*-elf*) fmt=elf ;;
|
||||||
|
|
||||||
|
diff -Naur -x Makefile.in -x aclocal.m4 binutils-2.37-orig/ld/Makefile.am binutils-2.37/ld/Makefile.am
|
||||||
|
--- binutils-2.37-orig/ld/Makefile.am 2021-07-08 13:37:20.000000000 +0200
|
||||||
|
+++ binutils-2.37/ld/Makefile.am 2021-09-17 23:11:24.688453612 +0200
|
||||||
|
@@ -456,6 +456,7 @@
|
||||||
|
eelf_x86_64_cloudabi.c \
|
||||||
|
eelf_x86_64_fbsd.c \
|
||||||
|
eelf_x86_64_sol2.c \
|
||||||
|
+ eelf_x86_64_karlos.c \
|
||||||
|
ehppa64linux.c \
|
||||||
|
ei386pep.c \
|
||||||
|
emmo.c
|
||||||
|
@@ -942,6 +943,7 @@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Pc@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Pc@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_sol2.Pc@am__quote@
|
||||||
|
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_karlos.Pc@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ehppa64linux.Pc@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ei386pep.Pc@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emmo.Pc@am__quote@
|
||||||
|
diff -Naur -x Makefile.in -x aclocal.m4 binutils-2.37-orig/ld/configure.tgt binutils-2.37/ld/configure.tgt
|
||||||
|
--- binutils-2.37-orig/ld/configure.tgt 2021-07-08 13:37:20.000000000 +0200
|
||||||
|
+++ binutils-2.37/ld/configure.tgt 2021-09-17 22:38:47.128321309 +0200
|
||||||
|
@@ -1001,6 +1001,9 @@
|
||||||
|
targ_extra_emuls=i386pe
|
||||||
|
targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o"
|
||||||
|
;;
|
||||||
|
+x86_64-*-karlos*) targ_emul=elf_x86_64_karlos
|
||||||
|
+ targ_extra_emuls="elf_x86_64"
|
||||||
|
+ ;;
|
||||||
|
xc16x-*-elf) targ_emul=elf32xc16x
|
||||||
|
targ_extra_emuls="elf32xc16xl elf32xc16xs"
|
||||||
|
;;
|
||||||
|
@@ -1085,6 +1088,10 @@
|
||||||
|
NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib'
|
||||||
|
;;
|
||||||
|
|
||||||
|
+*-*-karlos*)
|
||||||
|
+ NATIVE_LIB_DIRS='/lib'
|
||||||
|
+ ;;
|
||||||
|
+
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "${target}" in
|
||||||
|
diff -Naur -x Makefile.in -x aclocal.m4 binutils-2.37-orig/ld/emulparams/elf_x86_64_karlos.sh binutils-2.37/ld/emulparams/elf_x86_64_karlos.sh
|
||||||
|
--- binutils-2.37-orig/ld/emulparams/elf_x86_64_karlos.sh 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
+++ binutils-2.37/ld/emulparams/elf_x86_64_karlos.sh 2021-09-17 21:50:15.081410176 +0200
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+. ${srcdir}/emulparams/elf_x86_64.sh
|
||||||
10
build-binutils.sh
Executable file
10
build-binutils.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/sh
|
||||||
|
. ./vars.sh
|
||||||
|
mkdir -p binutils-2.37-build
|
||||||
|
cd binutils-2.37-build
|
||||||
|
../binutils-2.37/configure \
|
||||||
|
--target="$TARGET" --prefix="$PREFIX" \
|
||||||
|
--disable-nls --disable-werror \
|
||||||
|
--with-sysroot="$SYSROOT"
|
||||||
|
make "$MAKEFLAGS"
|
||||||
|
make install
|
||||||
13
build-gcc.sh
Executable file
13
build-gcc.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/sh
|
||||||
|
. ./vars.sh
|
||||||
|
mkdir -p gcc-11.2.0-build
|
||||||
|
cd gcc-11.2.0-build
|
||||||
|
../gcc-11.2.0/configure \
|
||||||
|
--target="$TARGET" --prefix="$PREFIX" \
|
||||||
|
--disable-nls \
|
||||||
|
--enable-languages=c \
|
||||||
|
--with-sysroot="$SYSROOT"
|
||||||
|
make "$MAKEFLAGS" all-gcc
|
||||||
|
make "$MAKEFLAGS" all-target-libgcc
|
||||||
|
make install-gcc
|
||||||
|
make install-target-libgcc
|
||||||
113
gcc-karlos-target-11.2.0.diff
Normal file
113
gcc-karlos-target-11.2.0.diff
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
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 <stdint.h>
|
||||||
|
|
||||||
|
/* Structures embedded in coveraged program. The structures generated
|
||||||
|
by write_profile must match these. */
|
||||||
6
patch-binutils.sh
Executable file
6
patch-binutils.sh
Executable file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cd binutils-2.37
|
||||||
|
patch -p1 < ../binutils-karlos-target-2.37.diff
|
||||||
|
cd ld
|
||||||
|
aclocal
|
||||||
|
automake
|
||||||
3
patch-gcc.sh
Executable file
3
patch-gcc.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cd gcc-11.2.0
|
||||||
|
patch -p1 < ../gcc-karlos-target-11.2.0.diff
|
||||||
13
vars.sh
Normal file
13
vars.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Modify these definitions to fit your host system
|
||||||
|
# PREFIX: Path on your host system where the toolchain shall be installed
|
||||||
|
export PREFIX="/opt/karlos-toolchain"
|
||||||
|
# SYSROOT: Path to the 'sysroot' folder in your local copy of the karlos repository
|
||||||
|
export SYSROOT="$HOME/karlos/karlos/sysroot"
|
||||||
|
|
||||||
|
export MAKEFLAGS="-j 10"
|
||||||
|
|
||||||
|
# Do not modify the following lines
|
||||||
|
# TARGET: The target triplet
|
||||||
|
export TARGET="x86_64-karlos"
|
||||||
|
# Temporarily add PREFIX to PATH so the toolchain can find itself during compilation
|
||||||
|
export PATH="$PREFIX/bin:$PATH"
|
||||||
Loading…
Add table
Reference in a new issue