Skip to content

dv: add --rust-target for CPU target selection - #48

Closed
lifetruthuu wants to merge 1 commit into
asterinas:mainfrom
DID-Lab-SZU:rust-target-option
Closed

lifetruthuu wants to merge 1 commit into
asterinas:mainfrom
DID-Lab-SZU:rust-target-option

Conversation

@lifetruthuu

@lifetruthuu lifetruthuu commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

dv: add --rust-target for CPU target selection

--targets selects packages; the CPU architecture was hard-coded to
x86_64-unknown-none in VERIFICATION_RUST_TARGET. This adds a
--rust-target <TRIPLE> option and threads it through every place the constant
was used, so a later architecture can be verified without changing dv again.

Changes

  • verus.rs: replace the constant with DEFAULT_RUST_TARGET (x86) and a
    parse_rust_target validator. Introduce SUPPORTED_RUST_TARGETS (accepted)
    and VALIDATED_RUST_TARGETS (x86 only). Experimental targets are accepted
    with a warning that the build is expected to fail.
  • verus.rs: pass the triple to cargo-verus (--target), dependency
    resolution, and the cached dependency file. The cache is named
    {package}.{triple}.{release|debug}.deps.toml, so externs for one target or
    profile are never reused for another.
  • doc.rs: use the triple for rustdoc --target and for locating artifacts
    under the triple-prefixed directories.
  • count.rs: use the triple to find cargo-verus dep-info. count --module now
    selects the #[path] declaration whose cfg(target_arch) matches the target;
    previously it always picked the first declaration, the x86 arch module.
  • main.rs: --rust-target on verify, focus, build, doc, and count,
    defaulting to x86. Unsupported triples are rejected at parse time.

Behavior is unchanged for the default target: every command without the flag
builds and verifies exactly as before.

Compatibility

  • No change to the existing --targets / --target (doc package) meanings.
  • --disasm still reads library_path(), which ignores the triple. The flag
    is currently unused (disassemble() has no caller), so this is not reachable.
    Tracked for when disassembly is wired up.

Verification

  • cargo test --lib --bin rust-dv: 11 + 6 passed. Four new tests cover the
    default target, rejection of an unsupported triple, cargo --target
    propagation, and count --module target selection. The count test was
    checked by mutation: disabling the cfg match makes it fail.
  • rustfmt --check on the changed files: clean.
  • rust-dv count --module arch::irq --rust-target <triple> on the real ostd
    tree resolves x86, riscv, and loongarch to their own irq.rs.
  • rust-dv build --rust-target riscv64imac-unknown-none-elf and the
    loongarch64 triple parse and reach the ostd build. Both fail inside ostd
    because of architecture code that is out of scope for this PR; they are
    reported as experimental.

Known test issues, both present on the base commit and unrelated to this PR:

  • cargo test --test helper_tests: test_get_dependency fails with
    No targets found (it runs from the dv directory, which has no vostd
    workspace). Not fixed here.
  • test_new_package writes verification/test-package and inserts a
    workspace = ... line at the top of dv/Cargo.toml. Run it only in a clean
    checkout, or revert those two changes afterwards. It was skipped for the
    verification above.

Related issues: none.

`--targets` selects packages; the CPU architecture was hard-coded to
`x86_64-unknown-none` in `VERIFICATION_RUST_TARGET`. Add a `--rust-target`
option and thread it through every place the constant was used, so a later
architecture can be verified without changing dv again.

- verus.rs: DEFAULT_RUST_TARGET, parse_rust_target, SUPPORTED_RUST_TARGETS
  (accepted) and VALIDATED_RUST_TARGETS (x86 only). Experimental targets are
  accepted with a warning.
- verus.rs: pass the triple to cargo-verus, dependency resolution, and the
  cached dependency file, named {package}.{triple}.{release|debug}.deps.toml.
- doc.rs: use the triple for rustdoc --target and artifact lookup.
- count.rs: count --module selects the #[path] whose cfg(target_arch) matches
  the target instead of always the first (x86) declaration.
- main.rs: --rust-target on verify, focus, build, doc, and count, defaulting
  to x86. Unsupported triples are rejected at parse time.

Behavior is unchanged for the default target.
@Marsman1996
Marsman1996 self-requested a review October 20, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant