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
+3
View File
@@ -16,6 +16,9 @@ int islower(int c);
int isprint(int c);
int ispunct(int c);
int isxdigit(int c);
#define isascii(c) (((c) & ~0x7F) == 0)
#define toascii(c) ((c) & 0x7F)
int iscntrl(int c);
int isgraph(int c);
int toupper(int c);
+6
View File
@@ -1,6 +1,12 @@
#ifndef _LIBC_STDIO_H
#define _LIBC_STDIO_H
/* Conventional guard marker: packages like GMP sniff the libc's stdio
include-guard name to detect that FILE is available. */
#ifndef _STDIO_H
#define _STDIO_H 1
#endif
#pragma once
#include <stdarg.h>
+2
View File
@@ -62,6 +62,8 @@ int mkstemp(char *template_);
char *mktemp(char *template_);
char *realpath(const char *path, char *resolved);
size_t mbstowcs(wchar_t *dst, const char *src, size_t n);
#define MB_CUR_MAX 1
int mblen(const char *s, size_t n);
int mbtowc(wchar_t *pwc, const char *s, size_t n);
int wctomb(char *s, wchar_t wc);
+41
View File
@@ -0,0 +1,41 @@
#ifndef _LIBC_SYS_MMAN_H
#define _LIBC_SYS_MMAN_H
#pragma once
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Anonymous-memory mmap over SYS_ALLOC. SYS_ALLOC returns
* page-aligned process memory, which is exactly what callers like
* GCC's page allocator need. File-backed mappings are not
* supported and fail with ENODEV.
*/
#define PROT_NONE 0
#define PROT_READ 1
#define PROT_WRITE 2
#define PROT_EXEC 4
#define MAP_SHARED 0x01
#define MAP_PRIVATE 0x02
#define MAP_FIXED 0x10
#define MAP_ANONYMOUS 0x20
#define MAP_ANON MAP_ANONYMOUS
#define MAP_FAILED ((void *)-1)
void *mmap(void *addr, size_t length, int prot, int flags, int fd,
long offset);
int munmap(void *addr, size_t length);
int mprotect(void *addr, size_t length, int prot);
#ifdef __cplusplus
}
#endif
#endif /* _LIBC_SYS_MMAN_H */
+12 -12
View File
@@ -39,18 +39,18 @@ extern "C" {
#define S_IXOTH 0001
struct stat {
unsigned long st_dev;
unsigned long st_ino;
mode_t st_mode;
unsigned long st_nlink;
uid_t st_uid;
gid_t st_gid;
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
off_t st_size;
blksize_t st_blksize;
blkcnt_t st_blocks;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
int mkdir(const char *path, unsigned int mode);
+7
View File
@@ -21,6 +21,13 @@ typedef unsigned int mode_t;
typedef unsigned int uid_t;
typedef unsigned int gid_t;
typedef long time_t;
typedef unsigned long ino_t;
typedef unsigned long dev_t;
typedef unsigned long nlink_t;
typedef long blkcnt_t;
typedef long blksize_t;
typedef long suseconds_t;
typedef int clockid_t;
#ifdef __cplusplus
}
+8
View File
@@ -39,6 +39,14 @@ int execve(const char *path, char *const argv[], char *const envp[]);
int execvp(const char *file, char *const argv[]);
int pipe(int fds[2]);
long pathconf(const char *path, int name);
int getpagesize(void);
long sysconf(int name);
/* sysconf() names (Linux numbering). */
#define _SC_OPEN_MAX 4
#define _SC_PAGESIZE 30
#define _SC_PAGE_SIZE 30
#define _SC_NPROCESSORS_ONLN 84
/* pathconf() names (Linux numbering). */
#define _PC_LINK_MAX 0