feat: native GCC - cc1, cc1plus and the gcc driver run on MontaukOS

Cross-build GCC 14.2.0 with --host=x86_64-montauk: the driver, cc1,
cc1plus and collect2 now link as static Montauk ET_EXEC binaries
against the hosted libstdc++, and ship in the SDK. Together with the
native binutils, TCC and the target sysroot, MontaukOS carries a
complete self-contained C and C++ toolchain at 0:/sdk.

libc: anonymous mmap/munmap over SYS_ALLOC (GCC's page allocator
wants mmap; SYS_ALLOC memory is page-aligned by construction),
getpagesize, minimal sysconf, MB_CUR_MAX, isascii/toascii, POSIX id
typedefs (ino_t, dev_t, nlink_t, ...), struct stat fields switched to
proper POSIX types (st_size is a signed off_t now), and a
conventional _STDIO_H guard marker so GMP's FILE detection works.

Build recipe and the five host-build gotchas (bundled config.subs,
gettext removal, stdio guard sniffing, endianness cache preset,
sysroot sdk symlink) are documented in toolchain/README.md. The
devkit stages the driver as gcc.elf/g++.elf/cpp.elf, the backends in
the libexec layout the driver expects, a copy of ld where collect2
searches, and a 0:/tmp scratch dir. Ramdisk: 1604 files, 368 MB.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
2026-07-16 23:51:30 +02:00
co-authored by Claude Fable 5
parent 03d1a1bc2f
commit f234c67a2b
13 changed files with 195 additions and 17 deletions
+20
View File
@@ -405,6 +405,26 @@ ifneq ($(wildcard $(NATIVE_BIN)/as),)
cp -r ../toolchain/local/x86_64-montauk/include/c++ $(BINDIR)/sdk/include/c++
../toolchain/local/bin/x86_64-montauk-gcc -O2 ../toolchain/files/tls-test.c -o $(BINDIR)/sdk/bin/tls-test.elf
../toolchain/local/bin/x86_64-montauk-g++ -O2 ../toolchain/files/cxx-test.cpp -o $(BINDIR)/sdk/bin/cxx-test.elf
ifneq ($(wildcard ../toolchain/native-gcc/sdk/bin/gcc),)
cp ../toolchain/native-gcc/sdk/bin/gcc $(BINDIR)/sdk/bin/gcc.elf
cp ../toolchain/native-gcc/sdk/bin/g++ $(BINDIR)/sdk/bin/g++.elf
cp ../toolchain/native-gcc/sdk/bin/cpp $(BINDIR)/sdk/bin/cpp.elf
mkdir -p $(BINDIR)/sdk/libexec/gcc/x86_64-montauk/14.2.0
cp ../toolchain/native-gcc/sdk/libexec/gcc/x86_64-montauk/14.2.0/cc1 \
../toolchain/native-gcc/sdk/libexec/gcc/x86_64-montauk/14.2.0/cc1plus \
../toolchain/native-gcc/sdk/libexec/gcc/x86_64-montauk/14.2.0/collect2 \
$(BINDIR)/sdk/libexec/gcc/x86_64-montauk/14.2.0/
cp -r ../toolchain/native-gcc/sdk/lib/gcc $(BINDIR)/sdk/lib/gcc
cp ../toolchain/local/lib/gcc/x86_64-montauk/14.2.0/libgcc.a \
../toolchain/local/lib/gcc/x86_64-montauk/14.2.0/crtbegin.o \
../toolchain/local/lib/gcc/x86_64-montauk/14.2.0/crtend.o \
$(BINDIR)/sdk/lib/gcc/x86_64-montauk/14.2.0/
cp ../toolchain/native/sdk/bin/ld $(BINDIR)/sdk/libexec/gcc/x86_64-montauk/14.2.0/ld
mkdir -p $(BINDIR)/tmp
printf 'scratch space for compiler intermediates\n' > $(BINDIR)/tmp/readme.txt
else
@echo "devkit: toolchain/native-gcc/ not built; skipping native GCC"
endif
else
@echo "devkit: toolchain/native/ not built; skipping native dev tools"
endif