Skip to content

cargo build-dir-new-layout breaks feature detection #336

Closed

Description

@illicitonion

This feature detection code no longer works correctly on nightly as of rust-lang/rust@83709ee which pulls in rust-lang/cargo#17258 which changes the target directory layout. All features are now treated as disabled.

Activity

  1. epage commented on Aug 1, 2026

    @epage

    CARGO_CFG_FEATURE is exposed to build scripts but that would require every library using trybuild to have a build script and then forward that to trybuild.

    I've talked about the idea of bypassing the need for build scripts for reading --cfgs by having cfg_value!("...") / cfg_values!("feature") macros to pair with cfg!.

  2. epage commented on Aug 1, 2026

    @epage

    We did do a crater run but I assume that just caused things to be skipped, rather than fail.

  3. illicitonion commented on Aug 1, 2026

    @illicitonion
    Author

    I'm not sure how crater runs work - my guess is it only runs crates with default features? If so, I suspect it wouldn't pick up this kind of breakage very often, e.g. my crate which hit this only hit this issue when tests are being run with non-default features enabled (see CI config).

  4. ranger-ross commented on Aug 2, 2026

    @ranger-ross
    Contributor

    Went ahead and raised #338 with a near term fix. (updated the directory logic to also handle the new build-dir layout)

    Also documented this usecase in rust-lang/cargo#17287 in hopes that Cargo could eventually provide a stable way to do without many traversing the build-dir tree or relying on the fingerprint file.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions