There are multiple ways to contribute to nature, including but not limited to submitting BUGs, sharing ideas, community discussions, coding contributions, documentation improvements, standardization, resource contributions, and donations.
🎉 The community version of nature is about to be released. You're invited to help build the standard library. The relevant standard libraries will be merged into the main nature repository.
Errors and Suggestions
If you wish to submit a bug report, your issue should include a title and a clear description of the problem. You should also provide as much relevant information as possible and a code example that demonstrates the issue. The purpose of a bug report is to make it easy for yourself and others to reproduce the error and develop a fix.
When submitting suggestions, try to clarify your ideas and preferably provide persuasive materials so that your suggestions can be better adopted. Suggestions for syntax, compiler design, coding standards, learning materials, etc., are all welcome.
You can submit your bug reports or suggestions via issues at nature-lang/nature.
For feature improvements and development contributions, please make sure to communicate through issues first. Once approved, a relevant tag will be added to the issue, and you can then proceed with code development without worrying about conflicts.
Ideas and issues are recommended to be discussed via GitHub issues to allow more people to focus and participate.
GitHub Discussion Community: https://github.com/nature-lang/nature/discussions
Source Code Compilation
├── VERSION # Version number, follows semantic versioning
├── cmake # cmake build-related files
├── cmd # cmd like nature build entry files
├── config # Compilation configuration
├── lib # Source files for compiling nature and libraries referenced when packaging nature
├── main.c # Entry point
├── runtime # runtime source code
├── src # Compiler source code
├── std # Standard library
├── tests # Test files
└── utils # Utility functions
Currently, the runtime only targets linux-amd64, so you only need to compile it once. After building, it will be written to the lib/linux-amd64/libruntime.a file. This directory will be installed to the specified location when compiling nature.
cmake -B build-runtime -S runtime -DCMAKE_TOOLCHAIN_FILE=$(pwd)/cmake/linux-amd64-toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build-runtime --target runtime
linux-amd64-toolchain.cmake uses musl-gcc for static compilation, and static compilation is recommended. If you want to compile for darwin/amd64, switch the toolchain to darwin-amd64-toolchain.cmake
# mkdir -p release && mkdir -p build-release
cmake -B build-release -DCMAKE_TOOLCHAIN_FILE=$(pwd)/cmake/linux-amd64-toolchain.cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Release -DCPACK_OUTPUT_FILE_PREFIX=$(pwd)/release
cmake --build build-release
cmake --build build-release --target test
# install (default installation to /usr/local/nature)
cmake --build build-release --target install
cmake --build build-release --target package
These are some of the resources I used while learning compiler theory and writing nature, hoping they can help you contribute. (Roughly organized in the order of learning)
- sicp (available in Python and JS versions), recommended to watch along with videos.
- Compiler Design (2nd Edition), selected chapters, recommended in English as the Chinese version is hard to understand.
- Modern Compiler Implementation in C, selected chapters, mainly the SSA part.
- crafting interpreters Highly recommended
- Writing a Compiler System from Scratch — Compilation, Assembly, and Linking, mainly read the assembly part.
- Linear Scan Register Allocation for the Java HotSpotTM Client Compiler, based on this paper.
- Linear Scan Register Allocation on SSA Form, SSA form linear scan register allocation.
- Writing a Memory Allocator Memory allocation and garbage collection course.
- golang/tcmalloc, referenced for memory allocation and garbage collection implementation, though my code reading skills are limited, so I read article analyses.
- bspaans/jit-compiler Referenced for the assembler part, specific instruction encoding referenced from Intel manual volume 2.
- Linkers and Loaders — Understanding Linkers and ELF File Structure.
- Tiny C Compiler Referenced for the linker part.
Nature's source code is developed based on ANSI C11 and musl libc.
- The source code aims for simplicity and readability, avoiding complex third-party libraries.
- Filenames/directory names/keywords use lowercase + underscore for word separation, the only exception being macro definitions, which use uppercase + underscore.
- Relevant feature improvements and bug fixes should provide ctest test cases, which are all placed in the