Define the RISC-V 64 target contract - #334
Merged
Merged
Conversation
Register riscv64-unknown-linux-gnu alongside the freestanding target and resolve effective CPU, ISA extensions, and LP64/LP64F/LP64D ABI settings before code generation. Apply the resolved ABI to LLVM target machines, expose the effective contract through target-spec and dry-run output, and preserve target CPU, features, ABI, and ISA metadata across LLVM IR and bitcode recompilation. Separate parser and LLVM architecture logic into x86_64, AArch64, and RISC-V modules. Canonicalize architecture aliases for target attributes and centralize per-architecture CPU lists, feature sets, register aliases, inline-assembly dialects, clobbers, register widths, and stack/control-flow analysis. Harden RISC-V inline assembly by rejecting zero, stack, global, and thread-pointer registers as value operands; supporting integer and floating-point ABI register aliases; accounting for all floating-point clobbers; recognizing non-returning jr, tail, ret, and jalr forms; requiring explicit stack and noreturn contracts; and reporting invalid assembly contracts as E3401 user diagnostics instead of internal compiler failures. Add C ABI export wrappers so Wave implementations keep native internal signatures while exported RISC-V functions use byval and sret lowering for large aggregates. Marshal direct, split, by-value, and structure-return values between wrapper and implementation paths and verify internal calls through exported aggregate functions. Make Linux cross-linking target-owned by selecting ABI-specific RISC-V loaders, preventing host CRT and generic library paths from leaking into cross builds, validating CRT ELF machine types, diagnosing incomplete sysroots, retaining CRT files for static links, requiring static archives in static mode, selecting rcrt1.o for static PIE, and avoiding dynamic loaders for static binaries. Add regression coverage for target option matrices, hosted and freestanding defaults, ELF ABI flags, IR and bitcode target preservation, RISC-V inline assembly contracts, C aggregate export lowering, cross-runtime isolation, static link plans, architecture target attributes, and WaveOS cross-codegen behavior. Add a Build Linux riscv64 GitHub Actions job that installs the RISC-V GNU sysroot and QEMU, runs the RISC-V contract tests, builds the release compiler, links an LP64D Linux executable, verifies its ELF machine, flags, and loader, and executes Hello World under qemu-riscv64 with a bounded timeout. Give every platform job a consistent OS and architecture name.
LunaStev
marked this pull request as ready for review
August 9, 2026 06:38
Detect Debian-style cross-runtime prefixes whose libc or libm linker scripts reference prefix-qualified absolute paths. Keep Wave's target runtime discovery rooted in the requested prefix while passing the filesystem root to ld.lld, preventing the linker from prepending /usr/riscv64-linux-gnu twice to libc.so dependencies. Add a synthetic RISC-V LP64D cross-prefix regression that provides target CRT objects and GNU linker scripts, verifies the effective linker sysroot, and confirms that target library search paths remain isolated to the cross runtime. Make CRT path assertions accept both Unix separators and JSON-escaped Windows separators so the Windows amd64 Rust test no longer rejects a valid RISC-V static link plan. Validated with cargo fmt, all Rust targets, default Clippy, and the RISC-V-only feature configuration with warnings denied.
Normalize path-fragment assertions against both literal paths and JSON-escaped Windows separators. Apply the shared matcher to the RISC-V runtime -L search-path assertion that failed on Windows despite the generated linker plan being correct. Add a direct regression for a JSON-encoded Windows library search path and retain the existing Unix and Windows CRT path coverage. Validated with cargo fmt, cargo test --locked --all-targets, and Clippy with warnings denied.
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
noreturnbehaviorTarget contract
rcrt1.o, while other link modes select the appropriate CRT and loader contractAudit fixes
libc.aandlibm.afor static runtime validationCI
Build Linux riscv64job on Ubuntu 24.04Validation
cargo fmt --all -- --checkcargo test --lockedcargo build --locked --release