Skip to content

build probes confused by cargo always setting TARGET, even for build scripts of host dependencies #11138

Closed as not planned
@RalfJung

Description

@RalfJung

I just spent a about an hour debugging a build failure in the rustc workspace that boils down to this issue:

  • the anyhow build script uses a build probe to determine if it can use std::backtracke::Backtrace.
  • if the TARGET env var is set, it runs the build probe with --target passed to rustc, meaning this is conceptually a target build (this is the right thing to do, it is needed to make build probes work in cross-compilation settings when anyhow is used by the target code)
  • however, since anyhow is a dependency of a build dependency, we actually need to know if the build probe would succeed on the host

In the case of bootstrap, the target sysroot has the backtrace feature stable but the host (beta) sysroot does not. So this means that anyhow enables the backtrace feature and later fails to use the backtrace feature.

I think it is a cargo bug that the TARGET env var is set for a build script that does not run on the target. Cargo should unset that env var for host build script builds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions