Skip to content

Add -Z unstable-options to rustc invocation to make --target work#21757

Open
FabianWolff wants to merge 1 commit intorust-lang:masterfrom
FabianWolff:rustc_z_unstable_options
Open

Add -Z unstable-options to rustc invocation to make --target work#21757
FabianWolff wants to merge 1 commit intorust-lang:masterfrom
FabianWolff:rustc_z_unstable_options

Conversation

@FabianWolff
Copy link

Currently when using a custom target JSON without Cargo, there is the following problem:

2026-03-04T13:41:29.078675707Z  WARN failed to get rustc cfgs e=unable to fetch cfgs via `"/.../rustc" "--print" "cfg" "-O" "--target" "/.../custom_target.json"`

Caused by:
    "/.../rustc" "--print" "cfg" "-O" "--target" "/.../custom_target.json" failed, exit status: 1
    stderr:
    error: error loading target specification: custom targets are unstable and require `-Zunstable-options`
      |
      = help: run `rustc --print target-list` for a list of built-in targets

Just a few lines above, we already set -Z unstable-options in the Cargo branch:

cmd.args(["rustc", "-Z", "unstable-options"]).args(RUSTC_ARGS);

We should do the same when calling rustc directly.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 5, 2026

let mut cmd = sysroot.tool(Tool::Rustc, current_dir, extra_env);
cmd.args(RUSTC_ARGS);
cmd.args(["-Z", "unstable-options"]).args(RUSTC_ARGS);
Copy link
Member

Choose a reason for hiding this comment

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

That will break the command for all stable toolchains

Copy link
Member

Choose a reason for hiding this comment

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

We could heuristically check if the target ends with .json, emit this option + adding RUSTC_BOOTSTRAP=1 to the environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants