Skip to content

Build won't complete for binary crate under rustc 1.56. #90180

Closed
@jcdyer

Description

@jcdyer

I've got a (closed source) crate that builds in under two minutes on rustc 1.55, and won't complete (top measured 67 minutes before I killed it) with rustc 1.56.

All the dependencies built fine. I captured the command to build the final binary with cargo build -v, and then ran that command under perf, and got the following output from perf report:

  13.56%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] <rustc_middle::traits::ObligationCauseCode as core::hash::Hash>::hash
   5.17%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] hashbrown::map::RawEntryBuilderMut<K,V,S,A>::from_hash
   4.55%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] rustc_middle::ty::context::TyCtxt::_intern_substs
   3.12%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] hashbrown::map::RawEntryBuilderMut<K,V,S,A>::from_hash
   2.31%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] rustc_trait_selection::traits::project::opt_normalize_projection_type
   1.76%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] hashbrown::map::HashMap<K,V,S,A>::insert
   1.70%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] rustc_trait_selection::traits::select::SelectionContext::impl_or_trait_obligations
   1.67%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] hashbrown::map::HashMap<K,V,S,A>::insert
   1.66%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] rustc_middle::ty::context::CtxtInterners::intern_ty
   1.55%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] hashbrown::raw::RawTable<T,A>::reserve_rehash
   1.49%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] hashbrown::map::HashMap<K,V,S,A>::insert
   1.38%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] rustc_trait_selection::traits::select::SelectionContext::match_impl
   1.31%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] <rustc_middle::ty::sty::TyKind as core::hash::Hash>::hash
   1.15%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] <rustc_infer::infer::freshen::TypeFreshener as rustc_middle::ty::fold::TypeFolder>::fold_ty
   1.03%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] rustc_query_system::cache::Cache<Key,Value>::get
   1.02%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] rustc_trait_selection::traits::project::assoc_ty_def
   0.98%  rustc    librustc_driver-d767902d1c6d74c6.so        [.] rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
   0.95%  rustc    rustc                                      [.] free
   0.87%  rustc    rustc                                      [.] malloc

By contrast, the perf report for 1.55.0 has no lines above 3.1%, most of which are in ld, and the top lines in rustc are

   1.40%  rustc            librustc_driver-2d8919e595cbef4e.so        [.] rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_green_and_read
   0.67%  rustc            librustc_driver-2d8919e595cbef4e.so        [.] rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
   0.51%  rustc            librustc_driver-2d8919e595cbef4e.so        [.] hashbrown::map::RawEntryBuilderMut<K,V,S,A>::from_hash

Code

Not shareable. Some possibly interesting things:

  • We use a build.rs file that generates some simple code (Creates a module with a few static FOO: &[u8] variables that gets include!()ed) and sets a couple environment variables.
  • The problem occurs regardless of whether we use edition = "2018" or edition = "2021".
  • We have two versions of the same dependency loaded in cargo.toml from two separate local paths:
    [dependencies]
    package_old = { package = "package", path = "package_old" }
    package = { path = "package" }
    They are brought in as git submodules. The copies of the crates have different versions in their Cargo.toml files ("0.2.3" and "0.3.0").

Version it worked on

It most recently worked on:1.55.0

Version with regression

rustc --version --verbose:

rustc 1.56.0 (09c42c458 2021-10-18)
binary: rustc
commit-hash: 09c42c45858d5f3aedfa670698275303a3d19afa
commit-date: 2021-10-18
host: x86_64-unknown-linux-gnu
release: 1.56.0
LLVM version: 13.0.0

@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions