Skip to content

Conversation

jserv
Copy link
Collaborator

@jserv jserv commented Sep 8, 2025

This commit resolves critical issues preventing shecc from compiling itself, enabling successful multi-stage bootstrapping.


Summary by cubic

Fixes self-hosting crashes and build failures so shecc can compile itself and complete multi-stage bootstrapping. Stabilizes all compiler passes when encountering function declarations without bodies.

  • Bug Fixes
    • Guard all passes to skip functions without basic blocks (SSA build/opt, liveness, DCE, reg-alloc, peephole, arch-lower, codegen, CFG/DOM dumps, IR dump).
    • Split comma-separated declarations into separate statements to avoid self-host parsing bugs (globals, locals, CLI args).
    • Correct SSA dump format string for sign_ext subscripts.

This commit resolves critical issues preventing shecc from compiling
itself, enabling successful multi-stage bootstrapping.
1. Format string error in src/ssa.c:1138 - changed %s to %d for integer
   subscript field
2. Added null checks for func->bbs throughout codebase to handle function
   declarations without bodies, preventing segfaults in SSA and optimization
   passes
3. Split global variable continuation declarations that shecc doesn't
   support (e.g., "int a, b;" must be "int a; int b;")
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 12 files

The RISC-V target was experiencing segmentation faults during stage2
compilation when stdin was redirected. The root cause was insufficient
buffer size for the SOURCE buffer when compiling large programs like
shecc itself.

The total size of all included source files for RISC-V was approaching
the 512KB limit (MAX_SOURCE), and with stdin redirection adding
overhead, this caused buffer overflow and segmentation faults.

Increased MAX_SOURCE from 524288 (512KB) to 1048576 (1MB) to provide
adequate buffer space for self-hosting compilation on all architectures.
@jserv jserv merged commit e95fccc into master Sep 8, 2025
12 checks passed
@jserv jserv deleted the hotfix branch September 8, 2025 02:44
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