Files
MontaukOS/toolchain/patches/gcc-14.2.0-montauk.patch
T
danielandClaude Fable 5 03d1a1bc2f feat: hosted libstdc++ for x86_64-montauk - full C++ on MontaukOS
The cross toolchain now builds real hosted C++: std::string, vector,
unique_ptr, iostreams and exceptions all work in a plain
x86_64-montauk-g++ invocation with no special flags. This is the
library that native cc1plus will link against for the GCC self-host.

crt1 now runs .preinit_array/.init_array before main and hooks
.fini_array through atexit (main returns via exit(), so destructors
run on both exit paths). Global constructors and libgcc's eh_frame
registration both ride this. GCC is reconfigured with
--enable-initfini-array (modern arrays instead of .ctors),
--with-newlib (satisfies libstdc++'s crossconfig for unknown hosts),
--disable-wchar_t and --disable-libstdcxx-pch; the montauk gcc patch
grows a hunk keeping os/generic ctype under --with-newlib (the
Montauk libc is not newlib).

libc additions harvested by the libstdc++ build: mbtowc/wctomb,
strxfrm, strtok/strtok_r, a real vfscanf/fscanf/scanf (character-
driven with widths and l/ll; also unblocks gprof later), fgetpos/
fsetpos/setbuf/fpos_t, modf plus the C99 float math variants
(acosf..tanhf, hypot/hypotf as wrappers), FP_* classification macros,
the full POSIX errno vocabulary, complete DT_* dirent types, and
mbstate_t.

The SDK ships the real libstdc++.a (was an empty stand-in), the C++
headers at 0:/sdk/include/c++, and cxx-test.elf (global ctor, string,
vector+sort, unique_ptr, throw/catch; exits 0 on 5/5). Ramdisk sits
at 1571 files, within the 2048 table.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-16 23:06:50 +02:00

62 lines
2.0 KiB
Diff

--- 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
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -27340,6 +27340,9 @@
# on a hosted environment.
if test "x${with_newlib}" = "xyes"; then
os_include_dir="os/newlib"
+ case "${host}" in
+ *-montauk*) os_include_dir="os/generic" ;; # Montauk libc is not newlib
+ esac
$as_echo "#define HAVE_HYPOT 1" >>confdefs.h