Harden target configuration validation - #333
Merged
Merged
Conversation
Centralize Wave target support in a feature-gated TargetSpec registry with exact triple matching, architecture metadata, hosted and freestanding classification, object formats, CPUs, features, and ABI overrides. Reject unsupported triples, target CPUs, unsigned or unknown features, duplicate and conflicting feature settings, and invalid RISC-V ABI combinations before check, build, object generation, or dry-run can reach LLVM. Keep usage failures machine-readable with exit code 2 and without leaking backend panics or internal compiler errors. Replace target substring heuristics in the CLI, runner, linker selection, target attributes, and LLVM backend with the shared registry and CodegenTarget mappings. Align advertised options with LLVM 21 by using rocket-rv64, permitting the generic RV64 CPU, and exposing fp-armv8 for AArch64. Add regression coverage for malformed targets, CPU and feature errors, LP64F and LP64D requirements, exact target lookup, JSON diagnostics, target metadata, every advertised target/CPU/feature combination, feature-specific LLVM builds, warning-free object generation, and ELF, Mach-O, and COFF object-format consistency.
LunaStev
marked this pull request as ready for review
August 9, 2026 02:12
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.
Summary
TargetSpecregistry with exact triple matchingWhy
Target knowledge was duplicated across the CLI, runner, linker, and LLVM backend. Several paths used substring matching, so malformed triples could be classified as supported and reach backend assertions. The advertised target option lists also contained values that LLVM 21 did not safely accept: RISC-V
rocketselected an RV32 CPU and AArch64fpwas ignored as an unknown feature.This change establishes one exact target contract and validates user-provided target settings at the CLI boundary. Invalid settings now fail as usage errors with exit code 2 instead of reaching LLVM, emitting warnings, or surfacing compiler-internal failures.
Notable behavior
build,check, object generation, and--dry-runvalidate the effective target first.generic,generic-rv64,rocket-rv64, orsifive-u74.fp-armv8feature name.Validation
cargo fmt --all -- --checkcargo test --locked --all-targets— 17 passedcargo clippy --locked --all-targets -- -D warningscargo build --locked --releasellvm-target-x86,llvm-target-aarch64, andllvm-target-riscvenabled independentlypython3 tools/run_tests.py— 96 passed, 0 failedwavec checkwavec check