RFC-037: Industrial Distribution Scheme — Compiler/Toolchain Packaging Based on cargo-dist
This RFC complements RFC-014b: Build System and Binary Distribution. RFC-014b defines how the YaoXiang package manager builds and distributes third-party packages; this RFC defines how the YaoXiang compiler/toolchain itself is packaged and distributed.
Summary
Use cargo-dist (a binary distribution tool from the Rust ecosystem) to orchestrate cross-platform builds, while custom scripts own the release package structure. There are two core commitments: release packages physically include the standard library source directory (users can read it directly, just like Python's Lib/), and the Z3 shared library, dynamically linked on every platform, is distributed with the package. The command model separates the front door from the engine: the common command yx is a small front door with built-in version management (the counterpart to rustup/Go GOTOOLCHAIN), while the engine yaoxiang-rs is the existing monolithic yaoxiang renamed. This avoids the ecosystem fragmentation seen when Python/Node later resort to separate tools such as nvm/pdm. Installation uses two tiers: standard channels aligned with Go/Zig, where the release package is the product and installation means extracting it and updating PATH; and zero-effort channels that install with a single command (Linux apt / curl | sh, Windows irm | iex / Inno exe wizard). This resolves the missing libz3.dll, the invisible standard library, and the duplicated maintenance of CI scripts.
Motivation
Why do we need this feature?
Users who download YaoXiang should be able to use it out of the box without any additional steps; the standard library should be directly readable by users rather than hidden inside a binary as a black box.
Current Problems
Problem 1: Windows users cannot run the download
The current Release only uploads yaoxiang.exe, but libz3.dll is not bundled. Users who double-click the executable on Windows receive the following error:
The code execution cannot proceed because libz3.dll was not found.This is a blocking bug—users cannot even get past the first step.
Problem 2: Release artifacts consist of only a single exe file, and the standard library is invisible to users
The current state has three separate disconnections:
- Release artifacts contain only the bare binary, and the standard library is not shipped with the release.
- The LSP interface file lookup chain is almost entirely disconnected: calls to
find_std_interface_filedo not pass the project directory (only the global~/.yaoxiang/std/is checked, and no process populates it);package initwrites to.yaoxiang/std, which is not part of the lookup chain. - The standard library source (
.yxlayer) and interface view (native layer) are completely opaque to users.
The industrial approach is to let users open the standard library directory directly and read its source, just like Python's Lib/—physically including the std directory in the release package is a hard requirement of this design (already adjudicated).
Problem 3: Hand-written CI scripts require duplicated maintenance
We currently maintain several build pipelines:
| File | Responsibility | Lines |
|---|---|---|
_build-platforms.yml | Cross-platform builds | ~255 lines |
release.yml | Version releases | ~189 lines |
nightly.yml | Daily builds | ~173 lines |
scripts/build/setup.iss | Inno Setup installer | ~250 lines |
| Total | ~870 lines |
Most of these steps are repetitive (install Rust → cache → build → rename → upload), and each platform requires another copy.
Problem 4: The Inno Setup version number is hard-coded
MyAppVersion is hard-coded to 0.7.0 in setup.iss and replaced with sed during builds. This will eventually fail.
Problem 5: The boundary with RFC-014b is unclear
RFC-014b defines the "build and distribution mechanism for YaoXiang packages" (that is, the [build] and [binaries] configuration in yaoxiang.toml), but it does not cover how the YaoXiang compiler itself should be released. This RFC fills that gap.
Proposal
Core Design
cargo-dist is responsible only for the build orchestration layer; the package structure and installers are entirely custom-owned. The responsibilities are divided as follows:
cargo-dist 职责(构建编排层):
├── 跨平台编译(5 个 target)
└── 生成压缩包与 checksum
(原生安装器与 npm wrapper 弃用——其扁平二进制假设与 bin/+lib/ 结构冲突)
build.rs 继续负责:
└── Z3 下载/链接(全平台动态 + rpath)
YaoXiang 自有脚本:
├── package-dist.sh — 重组包结构(bin/ + lib/)、附带共享库、
│ 填充 std 目录(仓库预生成接口视图 + .yx 层源码)、重算 checksum
└── Inno Setup — Windows 安装向导(既有资产;铺设完整目录结构)
命令模型(前门/引擎分离):
├── yx — 前门(新小 crate):版本解析 + 派发;保留动词仅 toolchain/self,其余透传
└── yaoxiang-rs — 引擎(现 yaoxiang 单体改名):编译/运行/包管理/fmt/lsp 子命令
安装方式(双层):
├── 标准渠道(Go/Zig 模式): 发行包即产品,解压 + PATH
└── 傻瓜渠道(Rust 模式): 一行命令安装 + 版本管理(内建于 yx 前门)
├── Linux: apt(自建 deb 仓库,系统级平装)/ curl … | sh(一键装整包)
├── Windows: irm … | iex(一键装整包)/ Inno Setup 向导(既有资产,系统级平装)
└── macOS: curl … | sh(brew 留待 homebrew-core 社区)Release Directory Structure (Adjudicated: Physically Include the Standard Library Source)
Users must be able to read the standard library directly, just like Python's Lib/; including the std directory in the release package is a hard requirement, not a packaging detail. The same applies to Z3: as an external system, directory-based shared library distribution is its natural form. Stuffing the .so into the executable and placing it outside for dynamic linking are equivalent with respect to the requirement that both must ship with the release package, while the latter also preserves replaceability.
After cargo-dist builds each platform, package-dist.sh reorganizes its release package as follows:
yaoxiang-{version}-{target}.tar.gz / .zip (portable and ready to use: extract, then run directly from bin/)
├── bin/
│ ├── yx # Front door (or yx.exe)
│ ├── yaoxiang-rs # Engine (or yaoxiang-rs.exe)
│ └── libz3.so / libz3.dylib / libz3.dll
├── lib/
│ └── yaoxiang/
│ └── std/ # Directly readable by users (Python Lib/ model)
│ ├── io.yx # Native module: interface view pre-generated from the repository
│ ├── math.yx
│ ├── test.yx # .yx layer: actual source copied verbatim from the repository
│ └── ...
├── README.md
└── LICENSEInstallation means extracting to any directory and adding bin/ to PATH (following Go's /usr/local/go/bin model; extracting to ~/.yaoxiang/ is a common choice). On Windows, the Inno Setup wizard performs the same operation (under Program Files by default). With a portable extraction, the yx front door has no ~/.yaoxiang state, so it falls back to the adjacent yaoxiang-rs, consistent with managed-installation behavior; the engine's rpath and exe-relative std lookup do not change because the front door exists.
Platform Support
| Platform | Target triple | Description |
|---|---|---|
| Linux x86_64 | x86_64-unknown-linux-gnu | Primary platform |
| Linux ARM64 | aarch64-unknown-linux-gnu | Cross-compiled in CI |
| macOS x86_64 | x86_64-apple-darwin | Intel Mac |
| macOS ARM64 | aarch64-apple-darwin | Apple Silicon |
| Windows x86_64 | x86_64-pc-windows-msvc | Primary platform |
There are five targets in total. Windows ARM64 is not supported for now because Z3 does not officially provide prebuilt ARM64 packages.
Z3 Distribution Strategy
Dynamic linking on all platforms (reviewed and retained):
| Platform | Change | Artifact |
|---|---|---|
| Linux | Previously static → dynamic | libz3.so |
| macOS | Previously static → dynamic | libz3.dylib |
| Windows | No change | libz3.dll |
| wasm32 | No change (static linking) | Embedded .a |
Rationale:
- Consistency—all three platforms behave uniformly, with no platform-specific exceptions.
- This is an external library, so it should be distributed as a shared library. Python (
python3.dll+DLLs/lib*.dll) and Node (node+lib/) both work this way. - Users can upgrade Z3 without waiting for a compiler release—replacing the
.so/.dylib/.dllis sufficient. - Smaller binaries—Z3 is not small, and static linking bloats the executable by several MB.
Dynamic linking requires one necessary companion: the dynamic linker on Linux/macOS does not search the binary's directory by default, so rpath must be injected; otherwise, "extract and run" does not work. Windows searches the exe's directory by default and needs no special handling. The corresponding build.rs changes are:
// Unify dynamic linking + rpath
fn link_z3(z3_dir: &Path) {
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
// Z3 release package layouts differ; probe both lib/ and bin/
println!("cargo:rustc-link-search=native={}", lib_dir.display());
// RFC-037: Dynamic linking on all platforms. The shared library is distributed in the release package's bin/ directory, allowing users to replace it wholesale to upgrade Z3
if target_os == "windows" {
// The MSVC import library is named libz3.lib
println!("cargo:rustc-link-lib=libz3");
} else {
println!("cargo:rustc-link-lib=z3");
// The dynamic loader does not search the binary's directory by default; rpath must be injected for "extract and run" to work
// (The exe and libz3 are in the same bin/ directory in the release package; Windows searches the exe's directory by default, so no handling is needed)
match target_os.as_str() {
"linux" => println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN"),
"macos" => println!("cargo:rustc-link-arg=-Wl,-rpath,@loader_path"),
_ => {}
}
let cxx = if target_os == "macos" {
"c++".to_string()
} else {
env::var("CXXSTDLIB").unwrap_or_else(|_| "stdc++".into())
};
println!("cargo:rustc-link-lib={}", cxx);
}
}"Static linking on all platforms" is not a goal. This does not eliminate special cases; it eliminates a legitimate case in the wrong way. A shared library is the normal way to distribute an external library.
Installer Support
The following compares the distribution methods used by mainstream language toolchains, based on research from September 2026:
| Language | Official Distribution Artifact | Official Installation Method | Installer Maintainer |
|---|---|---|---|
| Go | go/{bin,src,pkg} tarball | Official documentation: "download → extract → PATH" | None (brew/apt are community-maintained) |
| Zig | zig/{bin,lib/std} tarball | Same; no official installation script | None (homebrew-core community) |
| Node | {bin,lib,include} tarball | tar + official pkg/msi | Team-maintained |
| Rust | Multi-component tarball | rustup | Team-maintained |
| Crystal | {bin,src,embedded} tarball | deb/rpm/tar | Team + brew community |
| Deno/Bun | Single-binary zip | Official curl script | Team-maintained (the script is tiny) |
| Gleam | cargo-dist single binary | Script generated by cargo-dist | cargo-dist |
Three patterns emerge:
- No multi-file toolchain uses a third-party generator for its installer. cargo-dist's installer only fits single-binary use cases; Gleam can use it precisely because it is a single Rust binary with no external dependencies.
- The simplest model is Go/Zig's "release package is the product": the official installation instructions are extract + PATH, with zero installer code. It is normal for release packages to include readable std source (Go's
src/, Zig'slib/std/, and Crystal'ssrc/). - Tools that want one-command curl installation (Deno/Bun/rustup) all use custom scripts that barely evolve. Brew formulae are consistently maintained by the community in homebrew-core; language teams do not establish their own taps (the Crystal team explicitly states that the formulae are community-maintained).
YaoXiang adopts a two-tier model:
| Channel | Tier | Status | Description |
|---|---|---|---|
| zip / tar.gz | Standard | ✅ | Ready to use after extraction (rpath + shared library in the same directory); extract + PATH is the official guide |
yx (front door, built-in version management) | Zero-effort | ✅ | Counterpart to rustup/Go GOTOOLCHAIN: multi-version install/switch/update + project pinning |
curl ... | sh (install.sh) | Zero-effort | ✅ | Linux / macOS: download and reorganize the package into versions/, install bin/yx at the installation root, and write the default version |
irm ... | iex (install.ps1) | Zero-effort | ✅ | Windows: same logic |
apt install yaoxiang | Zero-effort | ✅ | .deb (amd64/arm64) + static apt repository on GitHub Pages; system-wide flat installation, with apt upgrade tracking versions |
| Inno Setup exe | Zero-effort | ✅ | Windows wizard (existing asset), system-wide flat installation, laying out the complete bin/+lib/ structure |
winget / .rpm / homebrew-core / npm | — | ⏸ | Optional follow-up: both winget and brew-core are community-maintained; rpm is structurally equivalent to deb |
| MSI / cargo-dist native installer / custom brew tap | — | ❌ | See "Alternatives" |
The zero-effort channels follow Rust, with version management built into the front door. Rust is decomposed into "bootstrap script (sh.rustup.rs) → rustup → toolchain packages"; rustup handled multiple versions, switching, and updates from the outset. The official Python/Node installers did not provide this layer, so their ecosystems later grew separate pyenv/nvm/pdm solutions. YaoXiang adopts front-door/engine separation, structurally analogous to Go's go front door + GOTOOLCHAIN and rustup's proxy dispatch. The common command is yx, and the engine is yaoxiang-rs—
~/.yaoxiang/
├── bin/yx # Front door: small binary, version resolution + dispatch (project pin > default > adjacent engine)
├── settings.toml # Default version, mirror sources
└── versions/ # Versions are a first-class concept; <ver>/ is the extraction root of that release package
└── 0.7.14/
├── bin/
│ ├── yaoxiang-rs # Engine: compile/run/package management/fmt/lsp subcommands
│ └── libz3.so
└── lib/yaoxiang/std/- The installation root
~/.yaoxiang/follows industry conventions (pyenv~/.pyenv, nvm~/.nvm, deno~/.deno, bun~/.bun, and volta~/.voltaall use a single root; rustup's dual~/.cargo+~/.rustuproots are historical baggage from cargo predating rustup, so we do not imitate them).~/.yaoxiangis also already the codebase's existing namespace (the global std fallback slot). TheYAOXIANG_HOMEenvironment variable can override it (following the precedents of RUSTUP_HOME / DENO_INSTALL), serving CI and container environments; on Windows, it is%USERPROFILE%\.yaoxiang. - The version directory is the release package's extraction root:
versions/<ver>/is structurally identical to a portable extraction or a deb installation tree. Installing a version means extracting a release package, so all three channels have zero structural divergence. - The command surface (the counterpart to rustup) provides
yx toolchain install / default / update / list / uninstall, includingyx self update; all other verbs are passed through to the engine unchanged. - Version locking is a structural guarantee: tools such as fmt evolve alongside the syntax and cannot understand newer syntax on their own. Version resolution is completed once before the front door dispatches, and the entire group is switched together, so there is no possible "new engine paired with old fmt" combination. If fmt/LSP are split into independent binaries in the future, they will also live in the same versioned
bin/directory. - Project-level pinning uses
yx-toolchain.toml(following the precedent of rust-toolchain.toml and matching the command name). It is not placed inyaoxiang.toml, because a package manifest should not impose a toolchain version on library users. - The bootstrap entry point (
curl | sh/irm | iex) installs the latest stable complete package in one operation: extract it intoversions/, installbin/yxat the installation root, and write the default version tosettings.toml. This is the equivalent convergence of rustup's "bootstrap installs the manager" decomposition—the front door and engine ship in the same package, so no two-step installation is required. - Mirror sources are configurable through settings.toml, continuing to account for the network conditions experienced by users in China, in the same way as Z3 downloads.
- Version management does not break the self-contained invariant: each version is a complete release tree whose rpath and exe-relative std lookup are internally consistent, while the front door only dispatches and does not alter the structure.
.deb and Inno are system-wide flat installation channels (a single version under root / Program Files, tracked by apt upgrade / the Control Panel), serving servers, CI, and complete beginners. They coexist with the version manager through PATH ordering (with the precedent of apt's rustc coexisting with rustup). All channels share the same artifact tree.
The .deb layout reuses the same directory tree: /usr/lib/yaoxiang/ contains the complete release tree (bin/{yx,yaoxiang-rs,libz3.so} + lib/yaoxiang/std/), and /usr/bin/yx is a symbolic link to /usr/lib/yaoxiang/bin/yx. $ORIGIN is calculated from the resolved real path, so the symlink still resolves to the adjacent libz3.so, matching the portable package structure. The full brand name remains in the package and product names (apt install yaoxiang, Inno product name YaoXiang), while the command surface is consistently yx, just as with Go: package name golang-go, command go. The apt repository is hosted statically on GitHub Pages (Packages/Release/InRelease metadata with GPG signatures, published by the release CI). Official Debian/Ubuntu inclusion may be pursued in the long term, but its long cycle and version lag make it a non-primary path.
Standard Library Directory
All content under lib/yaoxiang/std/ comes from static files in the repository. Packaging is a pure copy, with no runtime generation entry point:
| Layer | Source | Nature |
|---|---|---|
| Native modules (io/math/…) | Repository src/std/interfaces/*.yx pre-generated interface views | Interface signature views (implementations are in the binary) |
.yx layer modules (test/… and growing) | Repository src/std/*.yx copied verbatim | Actual source |
The pre-generated views are derived from StdModule::exports() (generate_all_interfaces() in src/std/gen_interfaces.rs). There is no runtime generation subcommand (decision of 2026-09-10: once packaging is established, a subcommand is redundant interface surface). Synchronization uses the same "commit generated artifacts + enforce with a test gate" model as the code tables in RFC-013: test_committed_interface_files_match_generation compares the pre-generated files byte-for-byte with the current generation, and any drift fails the gate. To update them, use the bless entry point cargo test update_committed_interface_files -- --ignored. The generation logic depends on the crate-internal StdModule implementation and cannot be moved into build.rs, so the gate belongs in tests rather than at build time.
Runtime lookup chain—find_std_interface_file gains an exe-relative lookup level:
- Project
.yaoxiang/vendor/std/<name>.yx(project override, current behavior) - The exe's directory,
../lib/yaoxiang/std/<name>.yx(new): portable extractions, managed installations (versions/<ver>/), and deb flat installations all resolve through the same path ~/.yaoxiang/std/<name>.yx(global fallback, retained as a manual override location)
The current chain is almost entirely disconnected: LSP calls do not pass the project directory, and .yaoxiang/std written by package init is not part of the chain. This RFC reconnects it and standardizes package init output to .yaoxiang/vendor/std, consistent with the package manager's vendor directory.
Compilation authority does not change: the .yx layer continues to use include_str! embedding, preserving RFC-036's invariant that the std version is strictly bound to the binary. The distribution directory is a readable view + LSP parsing source, not a compilation input; manual edits to .yx files in the distribution directory are not used by the compiler (whether to offer Python-style "edit Lib/ and it takes effect" semantics is an open question).
Wasm Build
Keep it independent; do not migrate it into cargo-dist.
cargo-dist handles "shipping the compiler to users," whereas wasm is "embedding an online playground in the documentation website"—two completely different deliverables.
| Aspect | Approach |
|---|---|
| Build tool | Continue using wasm-pack build |
| CI workflow | Keep _build-wasm.yml as an independent job |
| Trigger timing | The same tag push, as a parallel independent job |
| Publication target | docs/public/wasm/ → GitHub Pages |
npm Publication
| Package | Content | Status |
|---|---|---|
@yaoxiang/cli | Wrapper that downloads release packages | Deferred: cargo-dist's npm wrapper is likewise based on the flat-artifact assumption and is deprecated along with the installers. If an npm channel is needed, write a custom wrapper that downloads and extracts the reorganized package using the same logic as manual extraction |
@yaoxiang/playground | Wasm library (JS + .wasm) | Optional; currently published only under docs |
The two do not conflict, and neither do their names.
Integration with the Existing Release Process
The current release.yml works as follows: push main → check-version (allow only if the v{version} tag does not exist) → four parallel paths for build / build-wasm / security / test → release job (create and push a tag + generate a body containing @mentions with generate-commit-list.ts + upload artifacts).
The cargo-dist-generated pipeline is tag-driven, includes announce/publish, and lacks fmt/clippy/test/audit gates. Its release-notes format also cannot carry a merge-commit changelog. Replacing the existing pipeline wholesale would break the established release ritual (PR → all CI checks green → bump → merge commit as the changelog).
The integration principle is: keep the current triggers and gates, delegate builds to cargo dist build, and keep publishing as it is.
- Move check-version / security / test and tag creation into the
gate/security/test/tagjobs indist-release.yml, retaining the push main trigger (a tag-driven approach is infeasible: a tag pushed by a workflow usingGITHUB_TOKENdoes not trigger other workflows. The oldrelease.ymlcould therefore only publish flat binaries and has already been deleted along with_build-platforms.yml, leaving this file as the single release point). - Build only after the tag has been created: the
planjob uses dist to calculate the runner/system dependency matrix →cargo dist build(five targets) →package-dist.shreorganizes each target → Inno Setup job (consumes the reorganized Windows package to build the wizard and injects the version with/DMyAppVersion=, without compiling again) →_build-wasm.yml(parallel job). - The publish job uses
generate-commit-list.tsto generate the body (reusing the current script) → uploads the reorganized packages +.sha256+.deb+ wasm + Setup exe → creates a Release withaction-gh-release; an independentpublish-aptjob publishes the GitHub Pages apt repository metadata (it automatically skips whensecrets.APT_GPG_KEYis not configured, without affecting the other channels). - For re-releases or rebuilds,
workflow_dispatchspecifies an existing tag (thegateskips the tag-creation step accordingly).
Nightly Releases
cargo-dist has no native nightly support (axodotdev#1143, which remains an open feature request).
Retain the existing cron + tag overwrite approach, but replace the build portion of _build-platforms.yml with cargo dist build. It is essentially a Cargo command and can be invoked directly in nightly.yml. Do not reuse the workflow (the proposed uses: ./release.yml is infeasible: the reused workflow requires a workflow_call trigger, while the cargo-dist workflow is tag-driven and couples building with publishing):
# nightly.yml (after migration)
on:
schedule:
- cron: '17 22 * * *'
jobs:
build: # cargo dist build + package-dist.sh (same as the official release)
publish: # Preserve the current behavior: create/move the nightly tag → overwrite the GitHub Pre-releasecargo-dist Configuration (Implemented in dist-workspace.toml)
[workspace]
members = ["cargo:.", "cargo:tools/yx"]
# Config for 'dist'
# Pin the dist version (Cargo.toml SemVer syntax)
cargo-dist-version = "0.32.0"
ci = "github"
# All installers are custom; cargo-dist only handles the build + archives + checksums
installers = []
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
# The generated workflow has been intentionally modified (package-dist.sh reorganization + custom publishing section, RFC-037),
# so it does not refuse to build due to drift from the generate template
allow-dirty = ["ci"]
# GitHub retired macOS 14 on 2026-11-02; explicitly use a supported Apple Silicon image.
[dist.github-custom-runners]
aarch64-apple-darwin = "macos-15"This is the actual configuration vendored in the repository (generated by cargo dist init and revised as needed). cargo-dist-version is pinned to 0.32.0, and the generated workflow is vendored into the repository for review rather than fetched at runtime. The build profile injected by init into the root Cargo.toml's [profile.dist] inherits from release and uses lto=thin. Both binaries are written to target/<triple>/dist/ for the reorganization script to consume.
package-dist.sh (Implemented)
The repository's scripts/release/package-dist.sh is authoritative. Its key points are:
- The two binaries are taken directly from the
cargo dist buildoutput directory,target/<triple>/dist/(profile=dist). cargo-dist's own flat single-binary archives are not deliverables; the reorganized package with the same name directly overwrites them intarget/distrib/. - The Z3 shared library is likewise taken from the build output directory. build.rs has already selected and copied the appropriate platform-specific shared library during linking (
copy_shared_lib), providing a single source. The packaging script neither knows nor needs to know the Z3 version or platform directory naming. The Z3 license text ships alongside the library and is included by the packaging step (MIT distribution obligations). On macOS, the packaging phase normalizes the dylib's install_name to@rpathand ad-hoc re-signs the binary. - The std directory is copied purely:
src/std/interfaces/*.yx(pre-generated interface views) +src/std/*.yx(actual.yxlayer source). - README/LICENSE are included; packages are recreated (Windows zip / tar.gz for all other platforms; when Git Bash has no zip, the fallback chain is zip → System32 bsdtar → PowerShell), and
.sha256is recalculated. - On Linux, when
dpkg-debis available,build-deb.shis invoked to produce a.deb(the/usr/lib/yaoxiangflat-installation tree + the/usr/bin/yxsymbolic link).
Retirement of the Hand-Written CI
After migration, the following files are adjusted:
| File | Lines | Disposition |
|---|---|---|
.github/workflows/_build-platforms.yml | 254 | Delete; replaced by the cargo-dist build matrix |
.github/workflows/release.yml | 189 | Delete; gates and tag creation are merged into dist-release.yml, creating a single release point |
.github/workflows/nightly.yml | 173 | Replace the build section with cargo dist build; retain publishing logic |
scripts/build/setup.iss | ~250 | Retain and promote to an official release artifact (Windows wizard) |
| Total removed | ~600 lines |
The following are retained:
ci.yml(routine fmt + clippy + test + MSRV; not part of the release process)_build-wasm.yml(independent build pipeline, integrated into dist-release.yml as a parallel job)_build-z3-wasm.yml(wasm-specific Z3)docs-deploy.yml(documentation deployment)
Acceptance Criteria
"Out of the box" is testable. Completion of the migration is not determined by "the old and new artifacts are identical," but by all of the following passing:
- On a clean machine (no Rust / no Z3 / no
~/.yaoxiang), extract the compressed package for any platform and successfully executebin/yaoxiang-rs --versiondirectly—without settingLD_LIBRARY_PATH(rpath is effective). - Every
lib/yaoxiang/std/*.yxfile in the extracted directory is readable: native modules are signature interface views, and.yxlayer files are actual source. - Start the LSP in a sample project under the extracted directory; std member completion and go-to-definition work (exe-relative lookup is effective).
- After extracting to
/usr/local(or~/.yaoxiang) and adding it to PATH according to the official guide,yx --versionsucceeds from any directory. - After
apt install yaoxiang(from the self-hosted repository), the tool runs andapt upgradetracks versions; the engine's$ORIGINunder the/usr/bin/yxsymbolic link (resolved from the real path) findsbin/libz3.so. - After running
curl ... | shandirm ... | iexin a clean environment,yxruns and PATH is configured. yx toolchain install <ver>/default/updatework: multiple versions coexist, theyx-toolchain.tomlproject pin takes precedence over the default version, and the front door dispatches to the correct version (rpath and std lookup are coherent within the version tree, with no "new engine paired with old fmt" combination).- After a portable extraction,
yxfalls back to the adjacentyaoxiang-rs, with behavior consistent with managed installation. - After installation through Inno Setup, the directory structure is complete, PATH is effective, and the tool can be uninstalled.
- Release assets are complete: reorganized packages for five platforms +
.sha256files consistent with the actual contents. - The Release body is the output of
generate-commit-list.ts(with a complete merge-commit changelog). - Nightly artifacts are Pre-releases and do not affect the latest stable tag.
Trade-offs
Advantages
- Out of the box—portable extractions work immediately (rpath + shared library in the same directory), and installers lay out the complete directory structure.
- Readable standard library—users can read std directly, just like Python's
Lib/(the hard requirement is met). - Lower maintenance cost—~600 lines of hand-written build YAML are replaced by cargo-dist + ~80 lines of custom scripts.
- Cross-platform consistency—dynamic linking on all platforms + shared library in the same directory, with no exceptions.
- Two-tier installation—standard channels require no new code (Go/Zig model); zero-effort channels follow Rust, with four entry points—apt / curl / iex / exe—sharing the same artifact structure.
- Built-in version management—the
yxfront door corresponds to rustup/Go GOTOOLCHAIN, avoiding the ecosystem fragmentation seen when Python/Node later resort to pyenv/nvm/pdm; tool version locking is a structural guarantee rather than a convention.
Disadvantages and Risks
- Zero-effort channel maintenance surface—install.sh / install.ps1 (one-command scripts that barely evolve) +
.deband apt repository metadata publication (automated by the release CI) + theyxfront-door crate. - Engine rename affects many areas—renaming
yaoxiang→yaoxiang-rsrequires a one-time migration of CI artifact names, Inno Setup, tests, and documentation (completed in Phase Five). - Learning curve—the team must learn cargo-dist configuration.
- cargo-dist upstream risk—development stalled at Axo in mid-2025, but the original author revived the project in September of that year and continues releasing versions (0.29 → 0.32+). Pinning with
dist-versionand vendoring generated artifacts into the repository for review mitigate this risk. - cargo-dist has no native nightly support—the nightly publishing portion still needs to be hand-written.
Relationship with RFC-014b
| RFC-014b | RFC-037 | |
|---|---|---|
| Scope | Building and distributing third-party packages | Packaging and distributing the compiler itself |
| Tools | yaoxiang build / yaoxiang publish | cargo-dist + custom scripts |
| Artifacts | Third-party package FFI libraries | Compiler + standard library + toolchain |
| Mutual exclusivity | No, complementary | No, complementary |
Alternatives
| Alternative | Why It Was Not Chosen |
|---|---|
| Continue hand-writing CI | We have already hand-written ~870 lines, with repetitive work and an easy chance of missing a DLL |
| Write our own packaging tool | There is no need to reinvent the wheel; cargo-dist is already mature |
| Use only tar.gz without installers | The only official channel is extract + PATH; Inno serves only the Windows wizard convention (retained by decision for users in China) |
| Docker distribution | Compilers and language toolchains require native binaries and are not a container use case |
| Create a custom Homebrew tap | Taps are consistently community-maintained (homebrew-core), so creating one is a premature requirement; the zero-effort macOS entry point is a curl script |
Standalone yaoxiangup manager binary | rustup provides a direct precedent and this is feasible; however, it introduces a second user-facing verb and raises the symmetrical question of whether the package manager/fmt should also be independent. Front-door/engine separation resolves both (rejected in the 2026-09-09 discussion) |
| Support only self-updates, not multiple versions | Single-version self-update cannot satisfy projects that need different pinned versions. Python/Node lack official version management, forcing their ecosystems to grow pyenv/nvm/pdm; built-in management has therefore been adjudicated (2026-09-09) |
| Statically link Z3 on all platforms | Rejected by decision: directory-based shared library distribution is the natural form for an external system. Stuffing it into the executable and placing it outside are equivalent with respect to shipping it with the package, while the latter also preserves replaceability |
| Retire Inno Setup | Rejected by decision: retain it as the Windows wizard (an additional channel) |
| cargo-dist native installers | The flat-binary assumption conflicts with the bin/+lib/ structure, producing installations with missing libraries |
| Maintain WiX/MSI ourselves | After giving up cargo-dist's generator, the cost is higher than the value already covered by Inno |
Implementation Strategy
Phase One: Language-Side Changes (P0)
build.rs: unify dynamic linking across platforms + add the rpath link-arg; expandcopy_dll()intocopy_shared_lib()(so/dylib/dll)- Pre-generate the native interface views in the repository (
src/std/interfaces/), with a test gate enforcing synchronization withStdModule::exports()(the gen-std subcommand has been cancelled by decision) - Add an exe-relative lookup branch to
find_std_interface_file; standardize thepackage initoutput path to.yaoxiang/vendor/std
Phase Two: cargo-dist Integration (P0)
- Run
cargo dist initto generate the initial configuration (installers = [], pinned dist-version) - Write
package-dist.sh(reorganization +.yxsource copying + checksum recalculation) - Have
dist-release.ymlcarry everything: push main trigger → gate version check → gates (audit / fmt / clippy / test) → create tag → dist build → reorganization → parallel wasm → custom publish + apt; deleterelease.ymland_build-platforms.yml - Run the old and new pipelines in parallel and verify each acceptance criterion
Phase Three: Retire the Old CI (P1)
- Delete
_build-platforms.ymlandrelease.ymltogether (single release point:dist-release.yml) - Replace the build section of
nightly.ymlwithcargo dist build - Integrate
setup.isswith the new artifact structure (promote Inno to an official release artifact; inject the version from Cargo.toml and eliminate sed replacement)
Phase Four: Zero-Effort Channels (P2)
install.sh/install.ps1(detect platform → download the latest reorganized package → extract intoversions/→ installbin/yxat the installation root → write the default version tosettings.toml→ prompt for/write PATH; land in the same round as Phase Five to achieve the final form in one step).debpackaging (reuse the same directory tree aspackage-dist.sh+/usr/binsymbolic link) + static apt repository on GitHub Pages (GPG-signed metadata, published by the release CI)
Phase Five: The yx Front Door and Engine Rename (P2)
- Rename the existing monolith to
yaoxiang-rs(review all CI artifact names, Inno Setup, tests, and documentation in a one-time migration) - Add the new small front-door crate
yx(workspace member): version resolution, release artifact downloading, tar/zip extraction, settings.toml, and dispatch (only the toolchain/self verbs are reserved; all others are passed through, with hand-written dispatch rather than clap to guarantee verbatim argument forwarding). The version index comes from the GitHub Releases latest API (with mirror sources constructed using a ghproxy-style prefix). Theyxcommand name has been checked for collisions (no commonly used command with that name exists in mainstream distributions/Homebrew; only a small niche tool uses yx as an alias). yx toolchain install/default/update/list/uninstall+yx-toolchain.tomlproject pinning + mirror sources +yx self update- Bootstrap scripts:
curl | sh/irm | iex→ download the reorganized package and install the front door and default stable version in one operation (land in the same round as Phase Four as the final form)
Phase Six: Optional Follow-Up (None Are Blocking)
- Submit to winget (pointing to the Inno exe; community-maintained, following the homebrew-core model)
.rpm(for dnf users, structurally equivalent to.deb)- Homebrew: community-submitted after reaching the homebrew-core admission threshold
- npm
@yaoxiang/cliwith a custom wrapper (the name is currently unregistered)
Open Questions
Unresolved
- Should the
.yxlayer provide Python-style semantics in which manual edits to the distribution directory are used for compilation? The default is no—compilation authority remains the RFC-036 embedding, with the std version strictly bound to the binary, and the distribution directory serves as a readable view + LSP parsing source. If this is opened in the future, the version-binding invariant must be reconsidered.
Closed
The following questions were resolved during design discussions:
Is static linking of Z3 feasible on Windows?→ No static linking; dynamic linking on all platforms (reviewed and retained on 2026-09-09)What should the gen-std-interfaces subcommand be named?→ No subcommand (decision of 2026-09-10: once normal packaging is established, the subcommand surface is redundant; native interface views are now pre-generated undersrc/std/interfaces/+ synchronized by a test gate, making packaging a pure copy)Should Inno Setup be retained?→ Retain it as the Windows wizard (an additional channel)Should the release package physically include the standard library source?→ It must (user readability aligned with Python'sLib/; decision of 2026-09-09)cargo-dist native installers (shell/powershell/homebrew/msi/npm)?→ All deprecated; installers are custom-owned (the flat assumption conflicts with the bin/+lib/ structure)Installer strategy?→ Two tiers (final decision of 2026-09-09): standard channels = release package is the product (Go/Zig model, extract + PATH); zero-effort channels follow Rust with one-command installation—Linuxapt(self-hosted deb repository) /curl | sh, Windowsirm | iex/ Inno exe. Not included: MSI, cargo-dist native installers, or a custom brew tap.Should a version manager be included?→ Yes, it is part of the installer system (decision of 2026-09-09, overturning the boundary with the "separate future RFC" proposed earlier that day): the motivation is the ecosystem fragmentation caused by Python/Node lacking official version management and subsequently requiring pyenv/nvm/pdm.Version manager shape: standalone binary or subcommand?→ Front-door/engine separation (final decision of 2026-09-09, converging over three rounds from A→C to the naming reversal): the common commandyxis the front door (a small binary with built-in toolchain/self verbs), and the engineyaoxiang-rsis the existing monolithicyaoxiangrenamed. The directory structure isversions/<ver>/: versions are a first-class concept, and a version directory is the release package's extraction root. Tools are locked to the version as a whole (an old fmt does not understand new syntax; the previously proposed innertoolchains/was cancelled as redundant). Precedents include Go'sgofront door + GOTOOLCHAIN and rustup's proxy dispatch.Conditional execution of cargo-dist extra-artifacts?→ Handle it in thepackage-dist.shscript using shell case branchesStandard library interface version compatibility?→ Released together with the compiler version, in the same archive
