Refactor: Separate Compilation and Linking Phases #251
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 refactors the build pipeline by splitting the monolithic compilation process into distinct Compile-to-Object and Link-Object phases. This modular approach aligns with standard compiler toolchains (like GCC/Clang), enabling better build system integration and paving the way for multi-file project support.
Key Changes
1. Compilation Phase (
compile_ir_to_object)compile_ir_to_machine_codetocompile_ir_to_object..oobject files instead of final executables.stdinusing the-x irflag.-cflag to ensure only compilation occurs.target/{stem}.o.2. Linking Phase (
link_objects)link_objectsfunction to handle the final binary generation.-L) and library names (-l).libcandlibmby default.3. Pipeline Update (
runner.rs).o).Benefits
.llfiles.Example Workflow
graph LR A[Wave Source] -->|Frontend| B[LLVM IR] B -->|Compile| C[Object File] C -->|Link| D[Executable] E[Libraries] --> D