Skip to content

Add option to allocate global variables and heap on stack#194

Merged
laurenthuberdeau merged 9 commits intomainfrom
laurent/globals-on-stack
May 12, 2025
Merged

Add option to allocate global variables and heap on stack#194
laurenthuberdeau merged 9 commits intomainfrom
laurent/globals-on-stack

Conversation

@laurenthuberdeau
Copy link
Copy Markdown
Collaborator

Context

#152 moved the global variables to a mmap region, but some systems don't support that system call. With pnut-exe's one-pass mode, the code buffer doesn't get too large when compiling TCC, so statically allocated buffers (and other global variables) can be placed on the stack.

See fosslinux/live-bootstrap#524 (comment) for more context.

Concern

While the code buffer can be relatively small, other statically allocated buffers take up a lot of space. In particular, the string pool and heap buffers since they are never collected and grow proportional to the input program size. To compile TCC it may be required to increase the stack size limit even in one-pass mode.

@laurenthuberdeau laurenthuberdeau merged commit 954679c into main May 12, 2025
46 checks passed
@laurenthuberdeau laurenthuberdeau deleted the laurent/globals-on-stack branch May 12, 2025 16:49
laurenthuberdeau added a commit that referenced this pull request Jun 24, 2025
…tack"

This reverts commit 954679c, reversing
changes made to 1632f1b.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant