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 <noreply@anthropic.com>
This commit is contained in:
@@ -401,8 +401,10 @@ ifneq ($(wildcard $(NATIVE_BIN)/as),)
|
||||
cp lib/libc/liblibc.a $(BINDIR)/sdk/lib/libc.a
|
||||
cp lib/libc/crt1.o lib/libc/crti.o lib/libc/crtn.o $(BINDIR)/sdk/lib/
|
||||
ar rcs $(BINDIR)/sdk/lib/libm.a
|
||||
ar rcs $(BINDIR)/sdk/lib/libstdc++.a
|
||||
cp ../toolchain/local/x86_64-montauk/lib/libstdc++.a $(BINDIR)/sdk/lib/libstdc++.a
|
||||
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
|
||||
else
|
||||
@echo "devkit: toolchain/native/ not built; skipping native dev tools"
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user