Skip to content

fix: target-pointer-width must be an integer in target spec JSON#33

Merged
zouguangxian merged 3 commits intoLayerZero-Labs:mainfrom
sagar-a16z:ptr_width
Mar 6, 2026
Merged

fix: target-pointer-width must be an integer in target spec JSON#33
zouguangxian merged 3 commits intoLayerZero-Labs:mainfrom
sagar-a16z:ptr_width

Conversation

@sagar-a16z
Copy link
Collaborator

rustc 1.94 tightened JSON schema validation and rejects the string form.

    --- stderr                                                                                                                                                                                                                                                                
    error: error loading target specification: target-pointer-width: invalid type: string "64", expected u16 at line 9 column 30                                                                                                                                              
      |                                                                                                                                                                                                                                                                       
      = help: run `rustc --print target-list` for a list of built-in targets`    

@cursor
Copy link

cursor bot commented Mar 6, 2026

PR Summary

Medium Risk
Updates the pinned Rust toolchain and changes target spec generation based on rustc version, which can affect build outputs and CI environments if version detection fails or differs across toolchains.

Overview
Updates target spec generation to satisfy newer rustc JSON validation by rendering target-pointer-width as a JSON integer (and conditionally falling back to the old quoted string form for rustc < 1.91 via a rustc --version check).

Bumps the pinned toolchain to 1.94, and adjusts the RISC-V ARCH_OPS ret_from_fork export to cast the function to usize via *const () for compatibility with newer Rust casting rules.

Written by Cursor Bugbot for commit 288556a. This will update automatically on new commits. Configure here.

zouguangxian
zouguangxian previously approved these changes Mar 6, 2026
zouguangxian
zouguangxian previously approved these changes Mar 6, 2026
rustc 1.91 (rust-lang/rust#144443) changed target-pointer-width in
custom target JSON from a string to an integer. Bump the pinned
toolchain to 1.94 to pick up that requirement and fix the template.

zeroos-build now detects the active rustc minor version at runtime and
emits the value as a quoted string for toolchains older than 1.91,
keeping the tool portable.

Also fix a direct function-item-to-integer cast in zeroos-arch-riscv
that became a hard error under -D warnings once the
function_casts_as_integer lint (rust-lang/rust#141470, stable in 1.93)
was active.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

let pointer_width_json = match rustc_minor_version() {
Some(minor) if minor < 91 => format!("\"{}\"", arch_spec.pointer_width),
_ => arch_spec.pointer_width.to_string(),
};
Copy link

Choose a reason for hiding this comment

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

Version threshold for pointer-width format may be wrong

Low Severity

The code comment claims the target-pointer-width JSON type change happened in rustc 1.91, but the PR description states "rustc 1.94 tightened JSON schema validation and rejects the string form." The threshold minor < 91 may need to be minor < 94. If the change actually landed in 1.94, rustc versions 1.91–1.93 would receive the integer form when they still expect a string, producing invalid target JSON for anyone using those compiler versions.

Fix in Cursor Fix in Web

@zouguangxian zouguangxian merged commit 3b132ce into LayerZero-Labs:main Mar 6, 2026
18 checks passed
@sagar-a16z sagar-a16z deleted the ptr_width branch March 6, 2026 19:01
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.

2 participants