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]>
42 lines
1.4 KiB
C
42 lines
1.4 KiB
C
/*
|
|
* montauk.h
|
|
* GCC target definitions for x86_64-montauk userspace
|
|
* Copyright (c) 2026 Daniel Hammer
|
|
*
|
|
* Programs are static, non-PIE ET_EXEC images loaded by the kernel
|
|
* ELF loader (kernel/src/Sched/ElfLoader.cpp) at their linked
|
|
* address. The loader maps 4 KiB pages, so segments must not be
|
|
* aligned to the 2 MiB x86-64 default.
|
|
*/
|
|
|
|
#undef TARGET_OS_CPP_BUILTINS
|
|
#define TARGET_OS_CPP_BUILTINS() \
|
|
do { \
|
|
builtin_define("__montauk__"); \
|
|
builtin_define("__MONTAUK__"); \
|
|
builtin_assert("system=montauk"); \
|
|
} while (0)
|
|
|
|
/* The userspace build convention is -mno-red-zone everywhere; keep it
|
|
as the target default. A later -mred-zone on the command line still
|
|
overrides this. */
|
|
#undef CC1_SPEC
|
|
#define CC1_SPEC "-mno-red-zone"
|
|
|
|
#undef LINK_SPEC
|
|
#define LINK_SPEC \
|
|
"-m elf_x86_64 -z max-page-size=0x1000 %{shared:-shared} %{!shared:-static}"
|
|
|
|
/* crt1/crti/crtn come from the Montauk libc (sysroot usr/lib);
|
|
crtbegin/crtend are GCC's. crti/crtn are empty today (the runtime
|
|
does not run global constructors yet) but are kept in the link so
|
|
that enabling them later needs no toolchain change. */
|
|
#undef STARTFILE_SPEC
|
|
#define STARTFILE_SPEC "crt1.o%s crti.o%s crtbegin.o%s"
|
|
|
|
#undef ENDFILE_SPEC
|
|
#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
|
|
|
|
#undef LIB_SPEC
|
|
#define LIB_SPEC "-lc"
|