Repository navigation
refactor: centralize host-platform cfg behind reld_core::platforms - #150
Merged
Merged
Conversation
…eld#137)
Host-OS selection was scattered through the workspace as #[cfg(unix)],
cfg!(windows), cfg_select! on target_os, and direct libc/std::os calls.
It now lives in exactly one place: the cfg_select! in
crates/reld-core/src/platforms/mod.rs picks one concrete tree
(platform_linux/macos/illumos/other_unix/win/wasi, with shared unix
building blocks in platform_unix), and everything else calls the neutral
facade reld_core::platforms::{fs, host, linker_plugin, path, process}.
crate::platform (wild's linker-format trait) is untouched.
The ban_platform_cfg_outside_boundary Dylint now enforces this with zero
baseline across every workspace crate and target: only the selector and
the concrete trees are exempt (the facade leaves are scanned), selectors
match on identifier boundaries, cfg_select! host arms are detected, and
std::os::fd/wasi are banned. The lint gains unit and UI tests, a tracked
.cargo/config.toml (dylint-link was never configured), and a CI job that
lints the workspace with default and no-default features.
Behavior is preserved per host and feature set:
- plugins gating is feature = "plugins" plus a runtime
linker_plugins::ENABLED; unsupported hosts return early exactly like the
old disabled stub, so linker_plugins.rs now also compiles on Windows.
- Output-writing policy is host-neutral over FilesystemKind; Android keeps
its Btrfs/vfat-only policy.
- Tests that were compiled out by host cfg now compile everywhere and skip
at runtime on host facts or capabilities.
- reld-testkit/reld-diff cannot reach reld-core, so they use std's neutral
constants and the C compiler's target triple (-dumpmachine) instead;
reld-bench keeps explicit Windows/Apple/Linux routes and errors on any
other target.
- PlatformKind::host() no longer hard-fails compilation on non
Linux/macOS/Windows hosts; reld-core now type-checks for FreeBSD,
illumos, Android and WASI.
Removes the now-unused unix libc dev-dependency of reld (and its baseline
entry).
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
15 tasks
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.
Closes #137.
Summary
crates/reld-core/src/platforms/mod.rsholds the onlycfg_select!on the host OS; it picks one concrete tree (platform_linux,platform_macos,platform_illumos,platform_other_unix,platform_win,platform_wasi, with shared unix code inplatform_unix). Every other file calls the neutral facadereld_core::platforms::{fs, host, linker_plugin, path, process}.ban_platform_cfg_outside_boundarynow exempts only the selector and the concrete trees (facade leaves are scanned), matches selectors on identifier boundaries, detects hostcfg_select!arms, and bansstd::os::fd/std::os::wasitoo. It covers every workspace crate and target: reld-core, reld bins, integration tests, reld-testkit, reld-diff.dylintCI job (lint fmt, lint tests, workspace lint with default and--no-default-features),dylints/README.md, and anAGENTS.mdrule. It also tracks the lint's.cargo/config.toml(linker=dylint-link), which the bootstrap had gitignored, so the UI tests could not run before.Design decisions
reld_core::platforms, notcrate::platform.crate::platformis wild upstream's linker-format trait (ELF vs Mach-O, 42 files). Renaming it would be churn and would make upstream syncs painful, and it has nothing to do with the host.target_arch/target_endianstay allowed. reld is a cross-target linker, so these select the linker target.all(feature = "plugins", unix)gates becamefeature = "plugins"plus a runtimelinker_plugins::ENABLED(=platforms::linker_plugin::SUPPORTED). On hosts without plugin support,LinkerPlugin::from_argsreturnsOk(None)up front, exactly like the old disabled stub. As a result,linker_plugins.rsnow compiles on Windows.EXE_SUFFIX,ExitStatus::default()) and ask the C compiler for its target (cc -dumpmachine). That is target detection, and it is correct under cross-compilation.reld-benchkeeps exactly three explicit routes (Windows/Apple/Linux) and errors on any other compiler target; the existing Python guard was updated to enforce that.HostOs,KILLS_PROCESS_TREES, GNU objdump present,HAS_TEMP_DIR).Intended behavior changes (everything else is preserved)
PlatformKind::host()used acfg_select!without a fallback, so reld-core did not compile on FreeBSD, illumos, Android or WASI. Those hosts now default to ELF, and reld-core type-checks and passes clippy for all four.a/pinstead ofa.out/p.out. The tools also require a compiler that answers-dumpmachine.libcdev-dependency ofreldis removed, along with its baseline entry (removal only).Validation (local, Linux host)
cargo fmt --checkandcargo clippy --workspace --all-targets -D warningspass with default features,--no-default-features, and plugins-only.reld/reld-core, all targets, via soldr: pass.--no-default-features.libc::into reld-core, reld-testkit and an integration test. The lint failed on each, and the probes were removed afterwards.ci/tests: 258 passed.ci/check_dependencies.pypasses, and the baseline matches the manifests exactly.lto-whole-archive-shared/defaultfails identically on unmodifiedmainin this environment (missing local tool), so CI's full toolchain is the authority for that one.🤖 Generated with Claude Code