Add RISC-V target with zero runtime capability#3
Open
konard wants to merge 4 commits intouselessgoddess:masterfrom
Open
Add RISC-V target with zero runtime capability#3konard wants to merge 4 commits intouselessgoddess:masterfrom
konard wants to merge 4 commits intouselessgoddess:masterfrom
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: uselessgoddess#2
Implements the following features as requested in issue uselessgoddess#2: 1. Add riscv32i-unknown-none-elf target triple - Supports compilation to bin, dylib, and staticlib output types - Uses bare metal environment (os = "none") - Configured for RISC-V 32-bit architecture with appropriate data layout - Supports zero-runtime environments suitable for embedded systems 2. Allow entry_fn to return None when no_main option is set - Added no_main compiler option (-Z no_main) - When enabled, the compiler doesn't require a main or start function - Enables compilation of libraries and runtime-less code 3. Add no_mangle attribute support for functions - Added no_mangle to symbol table - Modified compute_symbol_name to skip mangling when #[no_mangle] is present - Functions marked with #[no_mangle] preserve their original symbol names Implementation details: - Created compiler/middle/src/spec/base/none.rs for bare metal base configuration - Created compiler/middle/src/spec/targets/riscv32i_unknown_none_elf.rs target spec - Added no_main flag to CompilerOptions (Z flags) - Modified HirCtx::entry_fn to respect no_main flag - Updated symbol mangling logic in man/mod.rs - Added test files in experiments/ directory 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Updated all compiler crates to edition = "2024" - Removed stabilized let_chains from feature flags in lexer - Required for building with latest Rust nightly This change is necessary for the codebase to build with current nightly Rust versions, as let chains require Rust 2024 edition or explicit feature gate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit 46910ac.
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements RISC-V target support with zero runtime capability as requested in issue #2.
Features Implemented
✅ RISC-V 32-bit target triple (
riscv32i-unknown-none-elf)bin,dylib, andstaticliboutput types✅ Optional entry point via
-Z no_mainflagentry_fnreturnsNonemainor#[start]functions✅
#[no_mangle]attribute support#[no_mangle]preserve their original symbol namesImplementation Details
New Files
compiler/middle/src/spec/base/none.rs- Bare metal base configurationcompiler/middle/src/spec/targets/riscv32i_unknown_none_elf.rs- RISC-V target specificationexperiments/test_riscv_*.zxc- Test files demonstrating functionalityModified Files
compiler/middle/src/symbol.rs- Addedno_manglesymbolcompiler/middle/src/man/mod.rs- Skip mangling for#[no_mangle]functionscompiler/middle/src/hir/mod.rs- Respectno_mainflag inentry_fn()compiler/middle/src/sess/mod.rs- Added-Z no_maincompiler optioncompiler/middle/src/spec/mod.rs- Registered new RISC-V targetAdditional Changes
Usage Examples
Compile for RISC-V with no main function
Use
#[no_mangle]attributeTesting
Test files have been added to the
experiments/directory demonstrating:#[no_mangle]functions#[no_mangle]functions and amainentry pointRelated
Fixes #2
🤖 Generated with Claude Code