mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-01 17:16:08 -06:00
Adds a second build system, which is the point of the previous phases: CargoBuildSystem builds Cargo.toml projects for Rust, alongside a cargo pseudo-language for the manifest and a TOML Monaco mode. Monaco ships an ini language, but TOML's array-of-tables headers, arrays and inline tables all come out wrong under it, and a Cargo.toml is full of them. cargo comes from the selected compiler's own toolchain -- the sibling of that compiler's rustc -- not a global property: a 1.80 cargo driving a 1.91 rustc disagree about lockfile and edition features. Rust compilers that ship no cargo (gccrs, mrustc, the BPF gcc: 16 of the 120 configured ones) are refused with a clear message, which is why getUnsupportedReason is now async -- it has to stat for the binary. The compiler is injected as RUSTC, user options go through RUSTFLAGS, and CARGO_HOME points inside the sandbox so nothing cargo writes outlives the compilation. Two things needed a new seam. cargo names its output after the manifest rather than putting it where we asked, so finaliseArtifact (new hook, no-op for CMake) copies what it built to the path the rest of the compilation was told to expect, with customOutputFilename choosing between artifacts when a project builds several. And the paths cargo reports are the ones it saw -- the sandbox bind-mounts the project as /app, without a sandbox it is the real temp directory -- so utils.maskRootdir reduces both to a path relative to the project root, which is then rebased onto the real one. Output uses --message-format=json-render-diagnostics: cargo renders diagnostics to stderr, which is what the user reads, and leaves stdout as artifact records for us, which the driver parses and then blanks so the JSON never reaches the output pane. Also fixes the frontend still posting every project build to /build/cmake regardless of what the tree had selected -- phase 2 added the dropdown but never threaded the choice into the request. submitCMake is now submitBuild(buildSystem, request), and the queued next request carries its build system with it. Dependencies are not supported: build nodes have no network, so the build runs --offline and an external crate fails immediately with cargo's own message rather than hanging. That covers #8988 (several modules in one tree) but not #3763; vendoring a registry is infrastructure work and deserves its own phase. Verified in the browser and by API against real toolchains: a three-file Rust tree builds, disassembles to output::square::square, and executes printing 49. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>