feat: x86_64-montauk userspace cross toolchain

Add build-montauk-toolchain.sh: builds an OS-aware cross GCC/binutils
(same versions and prefix as the bare-metal x86_64-elf toolchain) whose
x86_64-montauk target links static ET_EXEC binaries against the Montauk
libc sysroot with no special flags: 4 KiB max page size for the kernel
ELF loader, -mno-red-zone by default, crt1/crti/crtn + -lc from the
sysroot, __montauk__ defined. Target patches are checked into
toolchain/patches/, the GCC target header into toolchain/files/.

sys/types.h now includes <stdint.h> so hosted code (libgcov and
friends) sees intptr_t via the stdio include chain.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
2026-07-14 10:19:35 +02:00
co-authored by Claude Fable 5
parent 182520a585
commit 778f897f1a
7 changed files with 404 additions and 0 deletions
@@ -0,0 +1,49 @@
--- a/config.sub
+++ b/config.sub
@@ -1749,7 +1749,7 @@
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
- | fiwix* )
+ | fiwix* | montauk* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1935,6 +1935,12 @@
x86_64-*-elf*)
tm_file="${tm_file} i386/unix.h i386/att.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h"
;;
+x86_64-*-montauk*)
+ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h montauk.h"
+ # The Montauk libc has no stdint.h of its own (programs normally use
+ # the freestanding kernel headers), so GCC must provide one.
+ use_gcc_stdint=provide
+ ;;
x86_64-*-rtems*)
tm_file="${tm_file} i386/unix.h i386/att.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h i386/rtemself.h rtems.h"
;;
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -741,6 +741,10 @@
i[34567]86-*-elf*)
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
;;
+x86_64-*-montauk*)
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ extra_parts="crtbegin.o crtend.o"
+ ;;
x86_64-*-elf* | x86_64-*-rtems*)
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
case ${host} in
--- a/fixincludes/mkfixinc.sh
+++ b/fixincludes/mkfixinc.sh
@@ -20,6 +20,7 @@
powerpcle-*-eabisim* | \
powerpcle-*-eabi* | \
*-*-vxworks7* | \
+ *-montauk* | \
*-musl* )
# IF there is no include fixing,
# THEN create a no-op fixer and exit