GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(linker): on-demand pinned reld when selected (SOLDR_LINKER, Cargo.toml [*.metadata.soldr].linker, .cargo/config.toml), fetched by soldr prepare · Issue #3276 · forge-ci/soldr

feat(linker): on-demand pinned reld when selected (SOLDR_LINKER, Cargo.toml [*.metadata.soldr].linker, .cargo/config.toml), fetched by soldr prepare #3276

New issue
Copy link
New issue
Copy link
Closed
#3357
#3356
Closed
feat(linker): on-demand pinned reld when selected (SOLDR_LINKER, Cargo.toml [*.metadata.soldr].linker, .cargo/config.toml), fetched by soldr prepare#3276
#3357
#3356
Copy link

Description

@zackees
zackees
opened on Sep 17, 2026
Issue body actions

Goal

When the user selects the reld linker, soldr downloads a pinned, sha256-verified reld on demand instead of requiring reld to already be on PATH.

Blocked on: forge-ci/reld#148 (reld has no binary releases yet; [workspace.package].version is 0.0.0).

Current behavior (soldr#3262 / #3266)

crates/soldr-cli/src/linker.rs:

  • SOLDR_LINKER=reld injects reld unconditionally (clang --ld-path=reld on Linux, -C linker=reld on Windows/macOS). If reld isn't on PATH, the build fails at link time with invalid linker name in argument '--ld-path=reld', which is confusing.
  • fast / unset (the default) probes reld_on_path() (linker.rs:778) and falls back silently to the previous per-platform linker when it's missing.

Nobody has reld on PATH unless they built it themselves, so explicit reld is effectively broken for normal users.

Proposed design

Why download on demand instead of building reld into the soldr binary or relying on setup-soldr: Cargo/clang need a real reld executable on disk, so an embedded copy would still have to be unpacked (a download with extra steps, carried by every install). Embedding would also tie reld's releases to soldr's. And a setup-soldr-only install would make CI and local machines resolve different linkers for the same SOLDR_LINKER value.

1. crates/soldr-fetch/src/fetch/reld.rs — ensure_reld(paths) -> Result<PathBuf>

Copy the zig.rs shape (ensure_zig):

  1. SOLDR_RELD_BIN env var → absolute path to a reld binary (dev override; also how reld developers test local builds).
  2. Managed pinned install ~/.soldr/bin/reld-<MANAGED_RELD_VERSION>/ with a .complete stamp → return it.
  3. Otherwise download reld-v<ver>-<triple>.{tar.gz,zip} from github.com/zackees/reld/releases, verify it through trust::verify_download (so SOLDR_CHECKSUMS_FILE pins and SOLDR_TRUST_MODE=strict apply, and a trust: verified|unverified line is printed), extract with archive.rs, and write the stamp. Retry/backoff like zig.
  • MANAGED_RELD_VERSION is a pub const, bumped by PR like MANAGED_ZIG_VERSION.
  • Ship reld's SHA256SUMS for the pinned version as a built-in pin so the default fetch is verified, not just recorded.
  • Host asset selection: on Linux prefer the static x86_64-unknown-linux-musl asset so a glibc mismatch can't break it.

2. Front door wiring (crates/soldr-cli/src/cargo_front_door/target.rs)

  • Resolve the reld path once, before cargo is spawned. Never fetch from inside a link invocation, where parallel link steps would race to download it.
  • Inject the absolute path: --ld-path=<abs>/reld on Linux, CARGO_TARGET_<TRIPLE>_LINKER=<abs>/reld[.exe] elsewhere. With an absolute path the injection no longer depends on PATH order or the build script's environment.
  • Explicit SOLDR_LINKER=reld (env or linker = "reld" in ~/.soldr/config.toml): fetch failure is a hard error naming the URL, version, and SOLDR_RELD_BIN as the escape hatch.
  • Same for soldr build, the soldr wheel / PEP 517 path, and any other surface that goes through linker::resolve_for_target.

3. Cache identity

linker_candidate_identity (linker.rs:~505) runs <candidate> --version. It must run it on the resolved absolute path; today it runs the bare name reld, which would miss or mis-identify a managed install. A reld version bump must invalidate the PEP 517 fallback cache.

4. Declaring reld in the project (Cargo.toml / .cargo/config.toml)

Cargo.toml has no standard linker field. Cargo's standard linker settings live in .cargo/config.toml ([target.<triple>] linker / rustflags) and CARGO_TARGET_<TRIPLE>_LINKER. soldr should support both the standard form and a soldr field in Cargo.toml.

a. Standard Cargo config: detect reld and provide it.

  • [target.<triple>] linker = "reld" (bare name, or reld.exe): soldr fetches the managed reld and sets CARGO_TARGET_<TRIPLE>_LINKER=<abs path>. That's the same selection with a pinned binary, and Cargo's env-over-config rule keeps it equivalent. On Linux, a direct linker = "reld" links with no CRT (see the comment on LinkerChoice::Reld in linker.rs), so soldr should route it through the clang driver the same way SOLDR_LINKER=reld does. soldr must not overwrite a user-declared absolute path to reld; it only provides a binary for the bare name.
  • rustflags containing -C link-arg=--ld-path=reld or -C linker=reld: soldr cannot safely rewrite those, so it fetches the managed reld and prepends its directory to the cargo child's PATH.
  • Scope: exact-triple [target.<triple>] tables in the project .cargo/config.toml and $CARGO_HOME/config.toml, reusing and generalizing linker::project_target_config_value (today it only reads the project root). [target.'cfg(...)'] tables are best-effort; the metadata field below is the recommended form.

b. New soldr field in Cargo.toml:

[workspace.metadata.soldr]   # or [package.metadata.soldr]
linker = "reld"              # same values as SOLDR_LINKER
  • Add linker: Option<String> to SoldrMetadata (crates/soldr-cli/src/cargo_metadata_soldr.rs:66), with the existing workspace → package fallback. Unknown values are a hard error, like SOLDR_LINKER.
  • Precedence, from most to least specific: SOLDR_LINKER env → project [target.<triple>] linker/rustflags in Cargo config (the existing "target-scoped beats soldr convenience" rule, cargo_front_door/target.rs ~L139) → Cargo.toml [*.metadata.soldr].linker → ~/.soldr/config.toml linker → default. The project field beats the user-global config, matching Cargo's own "closer config wins" rule.
  • A project-declared reld counts as explicit: if the fetch fails, the build fails.

One resolver, linker::resolve_project_choice(...) or similar, must feed the cargo front door, soldr build, the PEP 517 path, and prepare. They must not drift apart (the soldr#2945 lesson). Today apply_pep517_override and cargo_front_door/target.rs already disagree about project target config; see soldr#3277.

5. soldr prepare / soldr toolchain prepare|ensure fetch reld

  • When the resolver from §4 says reld for the project (env, Cargo.toml metadata, Cargo config, or user config), soldr prepare fetches the managed reld (crates/soldr-cli/src/prepare_cmd.rs), just as it already provisions Zig. Add a RestoreEntry for ~/.soldr/bin/reld-<ver>/ in expected_state_paths (next to the Zig entry at ~L454) so --restore reports it as present or missing.
  • Same for soldr toolchain prepare and soldr toolchain ensure (toolchain.rs run_prepare_inner, ~L809). Add an additive field to the schema_version: 1 --json payload (e.g. "linker": {"choice": "reld", "path": "...", "version": "..."}).
  • reld is a host tool: one host binary links every target, since Windows/macOS targets go through its lld bridge. soldr prepare --target all fetches it once, not once per target.
  • setup-soldr needs no reld-specific logic. It already runs soldr prepare, so it gets reld for free and caches ~/.soldr/bin/reld-*.
  • If the project doesn't select reld, prepare does nothing new and makes no network call.

6. Dogfood in this repo

Once reld#148 ships and this issue lands, add linker = "reld" to soldr's own [workspace.metadata.soldr] in the root Cargo.toml, and:

  • CI guard: soldr prepare in this checkout fetches reld (assert the stamp path and the --json field).
  • CI guard: the build log shows reld selected and --cfg tokio_unstable still present on rustc lines. soldr#3277 must be fixed first, or this repo loses its own [build] rustflags.

7. reld_on_path() probe

Delete it for the explicit-reld path. See the judgment call below for the default path.

Tests (RED → GREEN)

  • Unit: asset-name/URL selection per host triple (incl. musl preference on Linux, .zip on Windows).
  • Unit: resolve_for_target with an injected resolver returns an injection using the absolute path, for Linux (--ld-path=) and Windows/macOS (-C linker=).
  • Unit: explicit reld + resolver error → hard error mentioning SOLDR_RELD_BIN; no silent fallback.
  • Unit: SOLDR_RELD_BIN wins over the managed install; pin mismatch is a hard error (via trust).
  • Unit: precedence table — env > .cargo/config.toml [target.<t>] > Cargo.toml [*.metadata.soldr].linker > ~/.soldr/config.toml > default; package metadata falls back to workspace; invalid value errors.
  • Unit: prepare with a fixture project declaring linker = "reld" records a reld RestoreEntry and calls the (stubbed) resolver exactly once for --target all; a project without it makes no resolver call.
  • Integration (Linux, local HTTP fixture — no live GitHub in tests): soldr cargo build with SOLDR_LINKER=reld and an empty PATH fetches, stamps, reuses on the second run, and links.
  • Guard: linker_candidate_identity changes when the managed reld version changes.

Docs

  • docs/API.md SOLDR_LINKER row: explicit reld downloads a pinned reld on demand; document SOLDR_RELD_BIN.
  • docs/TRUST_BOUNDARIES.md: add reld to the runtime fetch list.

Acceptance criteria

  • On a fresh machine with no reld on PATH, SOLDR_LINKER=reld soldr cargo build downloads, verifies, and links successfully on Linux x64, Windows MSVC x64, and macOS arm64.
  • The second build performs no network access for reld.
  • SOLDR_TRUST_MODE=strict passes using the built-in pins.
  • Explicit reld never falls back to another linker silently.
  • [workspace.metadata.soldr] linker = "reld" in Cargo.toml selects reld with no env var; [target.<host>] linker = "reld" in .cargo/config.toml is satisfied by the managed binary.
  • soldr prepare (and soldr toolchain prepare/ensure) in a project that selects reld downloads it, reports it in --json, and does nothing extra when reld isn't selected.
  • Front door, soldr build, PEP 517, and prepare resolve the linker through one shared function (a unit test asserts they agree for each declaration source).
  • soldr's own Cargo.toml declares linker = "reld", and CI proves both the fetch and that --cfg tokio_unstable survives (after bug(linker): default linker injection (#3266) silently drops [build] rustflags — soldr's own --cfg tokio_unstable is lost on Linux #3277).

Judgment calls (edit if you disagree)

  • Scope follows the request "if the user specifies reld, download it." "Specifies" means any explicit source: SOLDR_LINKER, ~/.soldr/config.toml, Cargo.toml [*.metadata.soldr].linker, or a bare reld in .cargo/config.toml. The default (fast/unset) keeps today's behavior: use reld only if it's already on PATH, otherwise the previous linker, with no network access on a default build. Open question for a follow-up: once the managed fetch is proven, should the default also fetch? Keeping the PATH probe there means the default almost never resolves to reld, and whether it does differs from machine to machine (the soldr#2945 problem).

  • Managed install over PATH for explicit reld, unlike zig, which prefers PATH. A random reld on PATH has an unknown version and would make link output depend on the machine. SOLDR_RELD_BIN is the explicit override.

  • Not a known_tools entry: reld is a linker injected into cargo's environment, not a tool the user runs, so it gets a dedicated module like zig. Could move into the soldr-toolchain catalogue later if that becomes the standard home for linkers/SDKs.

  • On Windows/macOS, reld bridges to lld-link / ld64.lld from the Rust toolchain's rust-lld, so no extra download is needed. That depends on reld#148 documenting how the bridge is located.

  • Metadata field name is linker, with the same value set as SOLDR_LINKER, rather than a reld-specific key like reld = true, so mold / rust-lld can be declared per-project the same way.

  • The project field beats ~/.soldr/config.toml, following Cargo's closer-config-wins rule; the env var still wins overall.

  • Bare-name detection in .cargo/config.toml instead of requiring users to switch to the metadata field: users who already wrote the standard Cargo setting shouldn't have to learn a soldr-specific one.

Related: soldr#3262, #3266, #3275, #3277 (rustflags clobber, which must be fixed before dogfooding).

Activity

  1. zackees
    changed the title [-]feat(linker): download a pinned, sha256-verified reld on demand when SOLDR_LINKER=reld[/-] [+]feat(linker): on-demand pinned reld when selected (SOLDR_LINKER, Cargo.toml [*.metadata.soldr].linker, .cargo/config.toml), fetched by soldr prepare[/+] on Sep 17, 2026
  2. zackees commented on Sep 17, 2026

    @zackees
    zackees
    on Sep 17, 2026
    CollaboratorAuthor
    More actions

    Unblocked. forge-ci/reld#148 is closed: reld v0.1.0 is published with the asset contract this issue assumed — reld-v0.1.0-<triple>.tar.gz / .zip for all 7 targets (linux gnu x64+arm64, linux musl x64, windows-msvc x64+arm64, macos x64+arm64) plus SHA256SUMS.

    So §1 (crates/soldr-fetch/src/fetch/reld.rs, modeled on zig.rs) can start now, with MANAGED_RELD_VERSION = "0.1.0" and the release's SHA256SUMS as the built-in pins.

    Note §6 (dogfooding linker = "reld" in soldr's own Cargo.toml) still needs #3277 first, or this repo silently loses its [build] rustflags.

  3. zackees
    added a parent issue on Sep 25, 2026
    • meta: burndown — small, design-free fixes across the 32 open issues (bugs first) #3278
  4. zackees
    added a commit that references this issue on Sep 25, 2026

    feat(linker): on-demand pinned reld resolution (#3276) (#3354)

    936ac39
  5. zackees
    closed this as completedin #3356on Sep 25, 2026
  6. zackees commented on Sep 25, 2026

    @zackees
    zackees
    on Sep 25, 2026
    CollaboratorAuthor
    More actions

    Reopening: #3356 landed most of this, but one acceptance criterion is still open. §6 dogfooding ([workspace.metadata.soldr] linker = "reld" in soldr's own Cargo.toml, plus a CI guard that checks the fetch and that --cfg tokio_unstable survives) was deliberately left out. A local repro still shows clang: error: invalid linker name in argument '--ld-path=reld' on build-script host links, so the #3277 symptom persists even though #3277 is closed. "Closes" in #3356 overstated it.

  7. zackees
    reopened this on Sep 25, 2026
  8. zackees commented on Sep 25, 2026

    @zackees
    zackees
    on Sep 25, 2026
    CollaboratorAuthor
    More actions

    Correction on evidence: the ci-full Windows MSVC x64 and macOS arm64 lanes passed on #3356 but do not run with SOLDR_LINKER=reld, so the fresh-machine download/verify/link criterion is proven only on Linux x64 (local HTTP fixture test). Still open: (1) a CI lane exercising SOLDR_LINKER=reld on Windows MSVC and macOS arm64, (2) §6 dogfooding, blocked by the build-script --ld-path=reld bug (#3277 symptom).

  9. zackees
    added a commit that references this issue on Sep 25, 2026

    feat(linker): dogfood reld on soldr's own build + CI proof (#3276 §6) (…

    c1963e9
  10. zackees
    closed this as completedin #3357on Sep 25, 2026
  11. zackees commented on Sep 25, 2026

    @zackees
    zackees
    on Sep 25, 2026
    CollaboratorAuthor
    More actions

    PR #3357 merged, addressing the two remaining §6 gaps this issue was reopened for.

    §6 dogfooding — done, verified. linker = "reld" is now declared in soldr's own Cargo.toml [workspace.metadata.soldr]. Investigated the reported clang: error: invalid linker name in argument '--ld-path=reld' and could not reproduce it against current main (post-#3356) — inject_resolved_reld / materialize_linker_driver_shim already resolve the bare reld to an absolute path before it reaches clang. Added .github/scripts/reld_dogfood_proof.py, which re-links soldr-cli under -v in CI and asserts (a) the resolved linker is an absolute, existing path, never bare reld, and (b) --cfg tokio_unstable (this repo's own [build] rustflags) survives being combined with the reld linker injection. That job (reld-dogfood-proof-linux) passed for real in #3357's own CI run: https://github.com/zackees/soldr/actions/runs/36101466713/job/107973072001

    Live acceptance on Windows MSVC x64 and macOS arm64 — attempted, mixed result, not a soldr-code gap. Added reld-live-fetch-windows-x64 / reld-live-fetch-macos-arm64 jobs that build a scratch crate with SOLDR_LINKER=reld (real network fetch, no override) on native runners:

    • macOS arm64: reproducibly fails, and it's a genuine reld bug, not soldr's: reld's ld64.lld bridge dynamically loads @rpath/libLLVM.dylib, which a standard rustup stable-aarch64-apple-darwin toolchain does not ship. Filed upstream: reld v0.1.0 ld64.lld bridge fails on macOS arm64: libLLVM.dylib not loaded (dyld, signal 6) reld#206. Confirmed identical on two separate CI runs (not flaky).
    • Windows x64: inconclusive. One run showed a clean cargo success (Compiling / [MISS] / Finished) but the expected linked .exe wasn't present immediately after — looked like a possible artifact-staging race between the daemon cache and the final target path. Pushed a tolerant retry as a plausible fix but did not get to re-verify it in CI before merging (time-boxed); if it recurs, the job's log is self-contained evidence to pick back up from.

    Both live-fetch jobs are intentionally informational (not part of full-coverage's required needs:), so they don't block merges — they exist so someone chasing this issue always has fresh, real evidence instead of a stale claim of "not yet run."

    Given the mixed result, PR #3357 used "Refs #3276" rather than "Closes #3276". I'll leave this issue open until forge-ci/reld#206 is resolved and the Windows lane is re-confirmed green, unless a maintainer wants to close it as "dogfooding done, live-acceptance tracked separately."

  12. zackees commented on Sep 25, 2026

    @zackees
    zackees
    on Sep 25, 2026
    CollaboratorAuthor
    More actions

    Follow-up evidence after #3364 (closes #3359) and forge-ci/reld#207 (reld v0.2.1, closes forge-ci/reld#206). All acceptance criteria now have evidence; the issue was already closed, this records it.

    Criterion Evidence
    Fresh machine, no reld on PATH: download + verify + link on Linux x64, Windows MSVC x64, macOS arm64 Linux x64: reld dogfood proof (linux x64) job. Windows x64: job 108024869967 (manifest-verified reld v0.2.1 ... sha256=9f8a1c34..., reld: engine=lld-link (bridge), invocation record reld_live_probe.exe, binary ran). macOS arm64: job 108024772816 (manifest-verified reld v0.2.1 ... sha256=c5941c26..., reld: engine=ld64.lld (bridge), invocation record reld_live_probe-<hash>, binary ran). Both are ci-full runs on the #3364 head.
    Second build does no network access for reld ensure_reld_from_downloads_verifies_and_reuses_without_a_second_fetch (crates/soldr-fetch/src/fetch/reld.rs, local HTTP fixture)
    SOLDR_TRUST_MODE=strict passes with built-in pins Same test runs under SOLDR_TRUST_MODE=strict. The pins now come from the reld v0.2.1 SHA256SUMS.
    Explicit reld never falls back silently ensure_selected_reld_explicit_failure_is_hard_error and reld_fetch_error (the error names SOLDR_RELD_BIN)
    [workspace.metadata.soldr] linker = "reld" / [target.<host>] linker = "reld" cargo_toml_metadata_linker_reld_resolves_absolute_path_end_to_end, project_target_linker_is_read_from_cargo_config, soldr_workspace_metadata_dogfood
    prepare / toolchain prepare/ensure fetch reld, report it in --json, do nothing extra when reld is not selected ensure_selected_reld_fetches_once_when_selected, ensure_selected_reld_skips_fetch_when_not_selected, and the linker field assertions in toolchain_ensure.rs tests
    One shared resolver linker::resolve_project_choice* is used by the front door, PEP 517, and prepare, and is enforced by crates/soldr-cli/tests/guards/linker_shared_resolver_lint.rs
    soldr dogfoods linker = "reld"; CI proves the fetch and that --cfg tokio_unstable survives root Cargo.toml [workspace.metadata.soldr] linker = "reld", plus reld-dogfood-proof-linux (.github/scripts/reld_dogfood_proof.py)

    Root causes fixed on the way:

    • macOS: rust 1.98's Apple rust-lld/rust-objcopy need <toolchain>/lib on the loader path, which rustup proxies normally supply. This is fixed in reld (bridge) and in soldr (caller toolchain lib on DYLD_FALLBACK_LIBRARY_PATH).
    • macOS: rustc's default darwin-cc flavor handed reld clang-driver argv. reld is now driven through clang --ld-path.
    • Windows: reld linked fine, but the probe looked in target/debug while soldr builds with --target <host>. The probe now asks Cargo for the executable path and requires reld's own invocation record.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.