Skip to content

Add x86_64-unknown-vibix.json target spec and xtask integration#860

Merged
dburkart merged 2 commits intomainfrom
m850-target-spec
May 5, 2026
Merged

Add x86_64-unknown-vibix.json target spec and xtask integration#860
dburkart merged 2 commits intomainfrom
m850-target-spec

Conversation

@dburkart
Copy link
Copy Markdown
Owner

@dburkart dburkart commented May 5, 2026

Summary

  • Create x86_64-unknown-vibix.json custom target spec per RFC 0009, enabling cargo +nightly -Z build-std cross-compilation for vibix userspace
  • Add [target.x86_64-unknown-vibix] rustflags section in .cargo/config.toml
  • Add cargo xtask validate-target subcommand that parses and validates the target spec against RFC-mandated fields/values
  • Wire VIBIX_USERSPACE_TARGET constant in xtask for downstream build commands

Test plan

  • cargo xtask build — kernel build unaffected, passes cleanly
  • cargo xtask validate-target — parses JSON, confirms all required fields present and correct

Closes #850

🤖 Generated with Claude Code

Create the custom target spec for vibix userspace as defined in RFC 0009,
enabling std Rust programs to be cross-compiled with `cargo +nightly -Z
build-std --target x86_64-unknown-vibix.json`. Key properties: os=vibix,
static linking via rust-lld, initial-exec TLS, panic=abort, no redzone.

Integrate the spec into the build system:
- .cargo/config.toml: add [target.x86_64-unknown-vibix] rustflags section
- xtask: add VIBIX_USERSPACE_TARGET constant for downstream use
- xtask: add `validate-target` subcommand that parses the JSON and checks
  all required fields/values match the RFC specification

Closes #850

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99c612c7-b32f-4ba7-add6-03f1ef330657

📥 Commits

Reviewing files that changed from the base of the PR and between 752e61e and 0d793f1.

📒 Files selected for processing (1)
  • xtask/src/main.rs
✅ Files skipped from review due to trivial changes (1)
  • xtask/src/main.rs

📝 Walkthrough

Walkthrough

Adds a new Rust target spec x86_64-unknown-vibix (JSON + .cargo config) and a new xtask CLI validate-target subcommand that parses and validates the target JSON fields.

Changes

Vibix Target Specification and Validation

Layer / File(s) Summary
Target Specification
x86_64-unknown-vibix.json
New LLVM/Rust target spec for x86_64-unknown-vibix: triple, data layout, endianness, pointer/C widths, panic-strategy: "abort", disable-redzone: true, features: "+sse,+sse2", has-thread-local, tls-model: "initial-exec", relocation-model: "static", position-independent-executables: false, linker-flavor: "gnu-lld", linker: "rust-lld", pre-link-args including -nostdlib/-static, and crt-objects-fallback: false.
Build Configuration
.cargo/config.toml
Adds [target.x86_64-unknown-vibix] block with rustflags = ["-C relocation-model=static", "-C no-redzone=yes", "-C force-frame-pointers=yes"] for userspace builds.
Validation Tool — deps
xtask/Cargo.toml
Adds serde_json = "1" dependency for JSON parsing in xtask.
Validation Tool — implementation
xtask/src/main.rs
Adds VIBIX_USERSPACE_TARGET constant; new validate-target subcommand and validate_vibix_target() which reads x86_64-unknown-vibix.json, requires the root JSON be an object, checks presence and exact expected values for multiple string fields (most), ensures has-thread-local / disable-redzone are true and position-independent-executables is false, aggregates validation errors, and prints a success mark on pass.
CLI wiring / help
xtask/src/main.rs
Registers validate-target in the CLI dispatch and updates usage banner.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • #852: The new target spec and xtask validation directly support end-to-end std-on-vibix testing for userspace builds.
  • #858: The x86_64-unknown-vibix target and cargo config enable building pjdfstest and other userspace tests for the vibix target.

Possibly related PRs

  • dburkart/vibix#689: Modifies xtask/src/main.rs with new xtask subcommands; related CLI-area changes.
  • dburkart/vibix#847: RFC and docs for Rust std on vibix; this PR implements the target spec referenced there.
  • dburkart/vibix#611: Adds xtask subcommands and updates dispatcher logic, touching the same xtask CLI surface.

Poem

🐰 I found a JSON nook today,
fields aligned in tidy play,
rustflags snug, the linker hums,
xtask checks, the green tick comes,
vibix userspace hops away. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially implements issue #850 but omits two key requirements: integrating into xtask build pipeline (build-userspace command) and updating ext2_image.rs. Complete the remaining tasks: add 'cargo xtask build-userspace' command and update ext2_image.rs to install userspace binaries into the ext2 rootfs image.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary changes: adding a custom target spec file and xtask integration.
Description check ✅ Passed The description clearly explains the changes, references the RFC, mentions the specific files modified, and provides a test plan.
Out of Scope Changes check ✅ Passed All changes are directly related to the custom target spec implementation and xtask integration as specified in issue #850.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch m850-target-spec

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
xtask/src/main.rs (2)

3499-3509: 💤 Low value

Consider validating static-position-independent-executables.

The target spec includes static-position-independent-executables: false, but this field isn't validated. If it's mandated by RFC 0009, consider adding it to the boolean-must-be-false check.

Proposed addition
     // Boolean fields that must be false.
-    for key in ["position-independent-executables"] {
+    for key in ["position-independent-executables", "static-position-independent-executables"] {
         match obj.get(key) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@xtask/src/main.rs` around lines 3499 - 3509, The boolean-field validation
currently iterates over ["position-independent-executables"] and ensures each
obj.get(key) is present and false; add "static-position-independent-executables"
to that list so the same logic (obj.get(key) match, errors.push(...) on missing,
and errors.push(...) if val.as_bool() != Some(false)) applies to the
static-position-independent-executables field as required by RFC 0009.

3474-3481: 💤 Low value

Type mismatch produces a misleading error message.

If a field has the wrong JSON type (e.g., boolean instead of string), as_str().unwrap_or("") returns "", producing an error like expected "x86_64", got "" rather than indicating a type mismatch. This is minor since the spec is internally authored.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@xtask/src/main.rs` around lines 3474 - 3481, The comparison currently uses
let actual = val.as_str().unwrap_or("") which hides type mismatches (producing
an empty string) — change the block around expected_val/val to explicitly check
for a string: if let Some(actual) = val.as_str() { compare actual == expected
and push the existing errors.push message } else { push a clear type-mismatch
error via errors.push that reports either the actual JSON value
(format!("{val}")) or its type (e.g., using val.is_* checks or format!("{:?}",
val)) so callers see "expected string, got boolean" (reference symbols:
expected_val, val, actual, errors.push).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@xtask/src/main.rs`:
- Around line 3499-3509: The boolean-field validation currently iterates over
["position-independent-executables"] and ensures each obj.get(key) is present
and false; add "static-position-independent-executables" to that list so the
same logic (obj.get(key) match, errors.push(...) on missing, and
errors.push(...) if val.as_bool() != Some(false)) applies to the
static-position-independent-executables field as required by RFC 0009.
- Around line 3474-3481: The comparison currently uses let actual =
val.as_str().unwrap_or("") which hides type mismatches (producing an empty
string) — change the block around expected_val/val to explicitly check for a
string: if let Some(actual) = val.as_str() { compare actual == expected and push
the existing errors.push message } else { push a clear type-mismatch error via
errors.push that reports either the actual JSON value (format!("{val}")) or its
type (e.g., using val.is_* checks or format!("{:?}", val)) so callers see
"expected string, got boolean" (reference symbols: expected_val, val, actual,
errors.push).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5a2bc7fe-d0f1-4fbb-aa5f-683a86554b6a

📥 Commits

Reviewing files that changed from the base of the PR and between fc1f2b9 and 752e61e.

📒 Files selected for processing (4)
  • .cargo/config.toml
  • x86_64-unknown-vibix.json
  • xtask/Cargo.toml
  • xtask/src/main.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dburkart dburkart merged commit c315291 into main May 5, 2026
15 checks passed
@dburkart dburkart deleted the m850-target-spec branch May 5, 2026 05:31
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.

Create x86_64-unknown-vibix.json target spec and integrate with xtask

2 participants