-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Labels
Description
Motivation
Currently, the moon build system uses debug and release options, which function as presets or profiles, each bundling a set of underlying flags. However, there is no granular control over optimization levels, such as those seen in other language toolchains (e.g., -O0, -O1, -O2, -O3, -Os, -Oz in C/C++, Rust, Swift, etc.). This limits power users and advanced build scenarios who want to tune builds for size, speed, or debugging fidelity.
Detailed Description
Investigate how other programming language compilers/build systems expose optimization control and profiles:
Survey Summary
- C/C++ (GCC/Clang): Supports flags like
-O0(none),-O1,-O2,-O3(increasing optimization),-Os(optimize for size),-Oz(aggressive size optimization), and-Og(debugging with some optimizations). - Rust (Cargo): Profiles include
devandrelease, which compose flags likeopt-level(0–3,s,z),debug,lto, etc., and allow further refinement inCargo.toml([profile.*] tables). - Swift (swiftc): Similar optimization flags:
-O,-Ounchecked, no optimization (debug), and profile concept via Xcode schemes. - Zig: Uses build profiles (ReleaseSafe, ReleaseFast, ReleaseSmall, Debug), each mapped to underlying options, and also exposes individualized flags.
Recommended Approach for Moon
- Refactor
debug/releaseas profiles, not exclusive build modes. - Introduce explicit optimization level flags (e.g.,
-O0,-O1,-O2,-O3,-Os,-Oz), mirroring conventions from C/Rust. - Allow users to compose their own profiles with sets of flags, possibly in a config file (akin to
[profile.*]in Cargo). - Document how default profiles (
debug,release) map to specific flag sets and how custom ones can be constructed. - Ensure integration with current build graph and artifact naming logic.
- Update documentation and dev references.
Benefits
- Improved user control over build output (speed, size, debug info)
- More familiar developer experience for those from C/C++/Rust/Swift backgrounds
- Extensibility for future flags/profiles
Related Issues
N/A (initial proposal)
Checklist
- I have added all necessary details to make it easy for the maintainers to understand my request.