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]>
This commit is contained in:
@@ -9,8 +9,13 @@ extern "C" {
|
||||
|
||||
#define NAME_MAX 255
|
||||
#define DT_UNKNOWN 0
|
||||
#define DT_FIFO 1
|
||||
#define DT_CHR 2
|
||||
#define DT_DIR 4
|
||||
#define DT_BLK 6
|
||||
#define DT_REG 8
|
||||
#define DT_LNK 10
|
||||
#define DT_SOCK 12
|
||||
|
||||
struct dirent {
|
||||
unsigned char d_type;
|
||||
|
||||
@@ -49,8 +49,47 @@ extern int errno;
|
||||
#define ENOTEMPTY 39
|
||||
#define ELOOP 40
|
||||
#define EWOULDBLOCK EAGAIN
|
||||
#define ETXTBSY 26
|
||||
#define ENOMSG 42
|
||||
#define EIDRM 43
|
||||
#define ENOSTR 60
|
||||
#define ENODATA 61
|
||||
#define ETIME 62
|
||||
#define ENOSR 63
|
||||
#define ENOLINK 67
|
||||
#define EPROTO 71
|
||||
#define EMULTIHOP 72
|
||||
#define EBADMSG 74
|
||||
#define EOVERFLOW 75
|
||||
#define EILSEQ 84
|
||||
#define ENOTSOCK 88
|
||||
#define EDESTADDRREQ 89
|
||||
#define EMSGSIZE 90
|
||||
#define EPROTOTYPE 91
|
||||
#define ENOPROTOOPT 92
|
||||
#define EPROTONOSUPPORT 93
|
||||
#define EOPNOTSUPP 95 /* == ENOTSUP, Linux numbering */
|
||||
#define EAFNOSUPPORT 97
|
||||
#define EADDRINUSE 98
|
||||
#define EADDRNOTAVAIL 99
|
||||
#define ENETDOWN 100
|
||||
#define ENETUNREACH 101
|
||||
#define ENETRESET 102
|
||||
#define ECONNABORTED 103
|
||||
#define ECONNRESET 104
|
||||
#define ENOBUFS 105
|
||||
#define EISCONN 106
|
||||
#define ENOTCONN 107
|
||||
#define ETIMEDOUT 110
|
||||
#define ECONNREFUSED 111
|
||||
#define EHOSTUNREACH 113
|
||||
#define EALREADY 114
|
||||
#define EINPROGRESS 115
|
||||
#define ESTALE 116
|
||||
#define EDQUOT 122
|
||||
#define ECANCELED 125
|
||||
#define EOWNERDEAD 130
|
||||
#define ENOTRECOVERABLE 131
|
||||
#define ENOTSUP 95
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -11,8 +11,47 @@ extern "C" {
|
||||
#define INFINITY __builtin_inff()
|
||||
#define NAN __builtin_nanf("")
|
||||
|
||||
/* C99 floating-point classification. */
|
||||
#define FP_NAN 0
|
||||
#define FP_INFINITE 1
|
||||
#define FP_ZERO 2
|
||||
#define FP_SUBNORMAL 3
|
||||
#define FP_NORMAL 4
|
||||
|
||||
#define fpclassify(x) \
|
||||
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, \
|
||||
FP_ZERO, x)
|
||||
#define isnan(x) __builtin_isnan(x)
|
||||
#define isinf(x) __builtin_isinf(x)
|
||||
#define isfinite(x) __builtin_isfinite(x)
|
||||
#define isnormal(x) __builtin_isnormal(x)
|
||||
#define signbit(x) __builtin_signbit(x)
|
||||
|
||||
double fabs(double x);
|
||||
double frexp(double x, int *exp);
|
||||
|
||||
/* C89 modf and the C99 float variants assumed by hosted libstdc++
|
||||
(--with-newlib crossconfig). The float forms wrap the double
|
||||
implementations. */
|
||||
double modf(double x, double *iptr);
|
||||
float modff(float x, float *iptr);
|
||||
double hypot(double x, double y);
|
||||
float hypotf(float x, float y);
|
||||
float acosf(float x);
|
||||
float asinf(float x);
|
||||
float atanf(float x);
|
||||
float atan2f(float y, float x);
|
||||
float coshf(float x);
|
||||
float expf(float x);
|
||||
float fmodf(float x, float y);
|
||||
float frexpf(float x, int *exp);
|
||||
float ldexpf(float x, int exp);
|
||||
float logf(float x);
|
||||
float log10f(float x);
|
||||
float powf(float x, float y);
|
||||
float sinhf(float x);
|
||||
float tanf(float x);
|
||||
float tanhf(float x);
|
||||
double ldexp(double x, int n);
|
||||
long double ldexpl(long double x, int n);
|
||||
double floor(double x);
|
||||
|
||||
@@ -39,6 +39,15 @@ extern FILE *stderr;
|
||||
int putc(int c, FILE *stream);
|
||||
void rewind(FILE *stream);
|
||||
int getchar(void);
|
||||
typedef long fpos_t;
|
||||
|
||||
int fgetpos(FILE *stream, fpos_t *pos);
|
||||
int fsetpos(FILE *stream, const fpos_t *pos);
|
||||
void setbuf(FILE *stream, char *buf);
|
||||
int fscanf(FILE *stream, const char *fmt, ...);
|
||||
int scanf(const char *fmt, ...);
|
||||
int vfscanf(FILE *stream, const char *fmt, va_list ap);
|
||||
|
||||
int fileno(FILE *stream);
|
||||
FILE *fdopen(int fd, const char *mode);
|
||||
|
||||
|
||||
@@ -63,6 +63,8 @@ char *mktemp(char *template_);
|
||||
char *realpath(const char *path, char *resolved);
|
||||
size_t mbstowcs(wchar_t *dst, const char *src, size_t n);
|
||||
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);
|
||||
double strtod(const char *nptr, char **endptr);
|
||||
float strtof(const char *nptr, char **endptr);
|
||||
long double strtold(const char *nptr, char **endptr);
|
||||
|
||||
@@ -31,6 +31,9 @@ char *strpbrk(const char *s, const char *accept);
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
int strcoll(const char *s1, const char *s2);
|
||||
size_t strxfrm(char *dest, const char *src, size_t n);
|
||||
char *strtok(char *str, const char *delim);
|
||||
char *strtok_r(char *str, const char *delim, char **saveptr);
|
||||
char *strstr(const char *haystack, const char *needle);
|
||||
const char *strerror(int errnum);
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ extern "C" {
|
||||
|
||||
typedef unsigned int wint_t;
|
||||
|
||||
/* Opaque shift state for the (byte-oriented) C locale. */
|
||||
typedef struct {
|
||||
unsigned long __opaque;
|
||||
} mbstate_t;
|
||||
|
||||
#define WEOF ((wint_t)-1)
|
||||
|
||||
/* Byte-oriented C locale only: one byte, one character. */
|
||||
|
||||
Reference in New Issue
Block a user