Be more lenient about stack memory

The new stack size is 256kb in order to compromise with llama.cpp's
aggressive use of stack memory, which can't be easily patched. This
change disables the dynamic alloca() and VLA warnings for now, plus
frame sizes for individual functions may be <=50% of the stack size

This only applies to code in the cosmo monorepo. Open source builds
should already be using an 8mb stack by default, like everyone else
This commit is contained in:
Justine Tunney 2023-04-27 10:43:42 -07:00
parent fec139f423
commit f42089d5c6
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 4 additions and 6 deletions

View file

@ -756,10 +756,10 @@ typedef struct {
#if __GNUC__ >= 6
#pragma GCC diagnostic error "-Wnonnull-compare"
#if defined(COSMO) && !defined(MODE_DBG) && !defined(STACK_FRAME_UNLIMITED)
#pragma GCC diagnostic error "-Wframe-larger-than=16384"
#pragma GCC diagnostic error "-Wframe-larger-than=131072"
#if __GNUC__ >= 9
#pragma GCC diagnostic error "-Walloca-larger-than=1024"
#pragma GCC diagnostic error "-Wvla-larger-than=1024"
// #pragma GCC diagnostic error "-Walloca-larger-than=1024"
// #pragma GCC diagnostic error "-Wvla-larger-than=1024"
#endif /* GCC 9+ */
#endif /* STACK_FRAME_UNLIMITED */
#elif __GNUC__ >= 9

View file

@ -67,10 +67,8 @@
#endif
/* TODO(jart): Remove this in favor of GetStackSize() */
#if defined(COSMO) && (defined(MODE_DBG) || defined(__SANITIZE_ADDRESS__))
#ifdef COSMO
#define STACKSIZE 262144 /* 256kb stack */
#elif defined(COSMO)
#define STACKSIZE 131072 /* 128kb stack */
#else
#define STACKSIZE 8388608 /* 8mb stack */
#endif