Major Overhaul: Standalone Toolchain Bundling and Modernized LLVM Backend#314
Merged
LunaStev merged 5 commits intoMay 15, 2026
Conversation
This commit massively overhauls the release packaging process (`x.py package` and `x.py release`) and introduces embedded toolchain support across the compiler and build scripts. Wave can now bundle its own LLVM dependencies and linker tools to provide standalone compiler distributions. [Details] 1. LLVM Toolchain Bundling & Rpath Patching: - `x.py package` now aggregates necessary LLVM binaries (`llc`, `llvm-as`, `llvm-mc`, `ld.lld`, `ld64.lld`, `lld-link`) and runtime libraries (`libLLVM*.dylib`, `liblld*.so`, etc.) alongside the compiled `wavec` binary into a `dist/` directory. - Implemented dynamic runtime patching using `install_name_tool` (macOS) and `patchelf` (Linux) to rewrite binary RPATHs (e.g., `@executable_path/llvm/lib` or `$ORIGIN/llvm/lib`). This ensures packaged `wavec` and `lld` binaries can reliably load bundled dynamic LLVM libraries regardless of where they are extracted. - For macOS, `otool` is used to map specific internal dylib dependencies and properly rewire `libLLVM.dylib` references, followed by ad-hoc `codesign` to maintain execution permission. - Ensured Windows releases include the correct set of MinGW and LLVM DLLs. 2. Architecture Verification before Build: - Added pre-build validation in `x.py` to ensure the host LLVM dynamic library (e.g., `libLLVM.dylib`) actually supports the requested compilation architecture (`aarch64` vs `x86_64`) using `lipo`. 3. LLVM Backend & Execution Pipeline: - Modified the internal `wavec` compilation pipeline to dispatch IR to `llc`, `llvm-as`, and `llvm-mc` (using the bundled binaries) instead of `clang`. - The default linker is now dynamically selected based on the target OS: `ld64.lld` for macOS and `ld.lld` for others. - LLVM tools are resolved automatically from custom search paths, environment variables (`WAVE_LLVM_BIN`, `LLVM_SYS_211_PREFIX`), or alongside the `wavec` executable itself. - Re-mapped the `opt_flag` behavior to pass proper LLVM code-generation flags to `llc`. - Added support for generating Bitcode, Assembly, and Object files correctly via the new toolchain execution flow in `runner.rs`. 4. Terminal Colors Improvements: - Upgraded terminal color utility (`colorex.rs`) to gracefully degrade if colors are explicitly disabled via environment variables (`NO_COLOR`, `CLICOLOR=0`). - Added support for legacy Windows ANSI mode environments (`WT_SESSION`, `ANSICON`, `ConEmuANSI`). 5. Python Dependency Fallbacks: - `x.py` no longer strictly requires `toml`. It natively supports `tomllib` (built-in for Python 3.11+) and gracefully catches `tkinter` import errors with helpful advice. Signed-off-by: LunaStev <youngjae681@gmail.com>
Signed-off-by: LunaStev <luna@lunastev.org>
…launcher support - Added `ldd_shared_libs` and `copy_linux_runtime_deps` to resolve and bundle runtime shared library dependencies for Linux targets. - Introduced `create_linux_launcher` to generate executable launchers with automated environment configuration. - Updated `stage_release_package` to include binary launchers and handle Linux-specific runtime packaging. - Improved `patch_linux_binary` with fallback warnings for missing `patchelf`. Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
- Added `configure_bundled_llvm_tool_env` to set up environment paths for bundled LLVM tools. - Updated CLI lowering and linking commands to use tool-specific environment configuration. - Enhanced Linux packaging with stricter checks for ELF RUNPATH settings and runtime dependency resolution. - Removed deprecated Linux launchers in favor of embedded runtime settings. Signed-off-by: LunaStev <luna@lunastev.org>
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.
This PR introduces a massive overhaul of the Wave compiler's distribution and execution architecture. The primary goal is to transform
wavecinto a standalone compiler that bundles its own LLVM dependencies and linker tools, eliminating the need for users to have a specific LLVM version pre-installed on their system.Key Changes
1. Standalone Toolchain Bundling & RPATH Patching
The
x.py packagecommand has been redesigned to create a fully portable distribution:llc,llvm-as,llvm-mc,ld.lld,ld64.lld,lld-link) and their required dynamic libraries into the release package.patchelfto set$ORIGIN/llvm/lib, allowing the binary to find its libraries relative to its own location.install_name_toolandotoolto rewrite@executable_pathreferences. This is followed by an ad-hoc codesign to ensure the modified binaries remain executable on modern macOS..exeis standalone.2. Modernized Execution Pipeline
The compiler now controls the full compilation lifecycle using bundled tools instead of relying on a system-installed
clang:llvm-as(bitcode),llc(assembly), andllvm-mc(object code).ld64.lldfor macOS andld.lldfor Linux/other ELF systems.WAVE_LLVM_BIN), prefixes, or local paths relative to thewavecexecutable.3. Build System & Safety (
x.py)x.pynow useslipo(on macOS) to verify that the host's dynamic LLVM library supports the requested target architecture, preventing "missing symbol" errors mid-build.tomllib(Python 3.11+), removing the strict external dependency ontoml. The GUI builder now also handles missingtkintergracefully with helpful installation advice.4. UI/UX & Compatibility
colorexutility now respects standard environment variables likeNO_COLORandCLICOLOR=0.Rationale
By bundling the toolchain, we significantly lower the barrier to entry for Wave. Users no longer need to struggle with matching LLVM versions or setting complex
LD_LIBRARY_PATHvariables. The move fromclangto internalllc/lldcalls also gives the compiler finer control over the code generation and linking stages.Example Workflow
Packaging a standalone release:
python3 x.py release # Results in a portable 'dist/' directory containing wavec and its LLVM sub-tools.