Skip to content

rustc built for custom targets requires -Zunstable-options on every invocation #155963

Open

Description

@DeepeshWR

When building rustc with support for custom targets, the compiler requires the -Zunstable-options flag not only during the build process but also on every subsequent invocation of the resulting rustc binary.

For e.g., rustc -vV -Zunstable-options
This behavior introduces additional complexity for cross-compilation toolchains (e.g., Yocto Project), where custom targets are distributed as part of the toolchain. End users of such toolchains are required to consistently pass -Zunstable-options, even for basic commands, which reduces usability.

To mitigate this, we are forced to introduce a wrapper script around rustc to automatically inject the -Zunstable-options flag. However, this is not an ideal or maintainable solution.

Can the requirement to pass -Zunstable-options be limited to the build phase and once a rustc binary is built for a custom target, invoking it should not require this flag for standard operations?

Activity

  1. added
    C-bug
    on Apr 29, 2026
  2. added
    needs-triage
    on Apr 29, 2026
  3. DeepeshWR commented on Apr 29, 2026

    @DeepeshWR
    ContributorAuthor
  4. bjorn3 commented on Apr 29, 2026

    @bjorn3
    Member

    Are you using json target specs? If so you might want to patch rustc to add a builtin target instead. See for example how LibreELEC did it: LibreELEC/LibreELEC.tv#11205

  5. DeepeshWR commented on May 8, 2026

    @DeepeshWR
    ContributorAuthor

    Thanks @bjorn3

    As you pointed out, we can work around this issue through target registration, but there is a scalability limitation with that approach.

    Even for the x86-64 architecture alone, we already maintain four different target combinations:

    x86-64_oe-linux-gnu
    x86-64_oesdk-linux-gnu
    x86-64_oe-linux-musl
    x86-64_oesdk-linux-musl
    

    The same process would then need to be repeated across at least five additional architectures (arm, arm64, riscv64...)

    In addition, Yocto is designed to support highly customized Linux distributions, where users commonly define their own target naming conventions. As a result, this approach would effectively require end users themselves to register and maintain their custom targets. For example:

    x86-64_wrs-linux-gnu
    aarch64_wrs-linux-gnu
    

    These may further vary depending on their distribution.

    As a result, the number of possible targets is effectively unbounded. Because of this, relying on target registration does not appear to be a scalable or practical solution for us.

    We also explored using a wrapper function to automatically pass -Zunstable-options when invoking rustc as a workaround. However, this approach has several limitations within our project's sdk environment, making it unsuitable for adoption.

    Given these constraints, would it be possible to limit the -Zunstable-options requirement specifically to cases where rustc is invoked to build for a custom target JSON file, rather than requiring it for all invocations?
    For example:

    ./rustc --target custom-target.json -Zunstable-options # Here the -Zunstable-options required
    ./rustc -vV # Here the -Zunstable-options not required
    

    @davidtwco

    Any suggestions on this approach?

  6. added a commit that references this issue on May 18, 2026
  7. added a commit that references this issue on Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions