Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use informational target machine for metadata #58605

Merged
merged 1 commit into from
Mar 29, 2019

Conversation

nagisa
Copy link
Member

@nagisa nagisa commented Feb 20, 2019

Since there is nothing to optimise there...

Should fix #58323 but haven’t tested locally.

r? @michaelwoerister

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 20, 2019
@michaelwoerister
Copy link
Member

michaelwoerister commented Feb 21, 2019

This does not seem to fix #58323.

Here's the backtrace I'm getting:
[mw@localhost ice-mono-item]$ RUST_BACKTRACE=1 cargo check
   Compiling proc-macro2 v0.4.27
   Compiling unicode-xid v0.1.0
   Compiling cc v1.0.29
   Compiling libc v0.2.48
   Compiling autocfg v0.1.2
   Compiling failure_derive v0.1.5
   Compiling cfg-if v0.1.6
   Compiling cortex-m v0.3.1
   Compiling rustc-demangle v0.1.13
    Checking vcell v0.1.0
    Checking aligned v0.1.2
    Checking bare-metal v0.1.3
   Compiling cortex-m v0.4.3
   Compiling cortex-m-rt v0.4.0
    Checking void v1.0.2
   Compiling either v1.5.0
    Checking r0 v0.2.2
    Checking nb v0.1.1
    Checking untagged-option v0.1.1
   Compiling typenum v1.10.0
   Compiling cortex-m-rtfm v0.3.4
   Compiling fpa v0.1.0
   Compiling byteorder v1.3.1
    Checking cast v0.2.2
   Compiling nrf51-ble-demo v0.1.0 (/home/mw/stuff/ice-mono-item)
    Checking rtfm-core v0.2.0
    Checking panic-halt v0.2.0
    Checking volatile-register v0.2.0
    Checking embedded-hal v0.2.2
    Checking embedded-hal v0.1.3
   Compiling backtrace v0.3.13
error: internal compiler error: src/librustc_mir/monomorphize/collector.rs:745: Cannot create local mono-item for DefId(9/0:10 ~ r0[590c]::zero_bss[0])

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:70
             at src/libstd/sys_common/backtrace.rs:58
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
             at src/librustc/util/common.rs:39
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::begin_panic
             at /home/mw/1-rust/src/libstd/panicking.rs:412
   7: rustc_errors::Handler::bug
             at src/librustc_errors/lib.rs:620
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
             at src/librustc/util/bug.rs:36
   9: rustc::ty::context::tls::with_opt::{{closure}}
             at src/librustc/ty/context.rs:2111
  10: rustc::ty::context::tls::with_context_opt
             at src/librustc/ty/context.rs:2046
  11: rustc::ty::context::tls::with_opt
             at src/librustc/ty/context.rs:2111
  12: rustc::util::bug::opt_span_bug_fmt
             at src/librustc/util/bug.rs:32
  13: rustc::util::bug::bug_fmt
             at src/librustc/util/bug.rs:12
  14: rustc_mir::monomorphize::collector::should_monomorphize_locally
             at src/librustc_mir/monomorphize/collector.rs:745
  15: rustc_mir::monomorphize::collector::visit_instance_use
             at src/librustc_mir/monomorphize/collector.rs:681
  16: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
             at src/librustc_mir/monomorphize/collector.rs:0
  17: rustc::mir::visit::Visitor::visit_mir
             at /home/mw/1-rust/src/librustc/mir/visit.rs:444
             at /home/mw/1-rust/src/librustc/mir/visit.rs:109
             at /home/mw/1-rust/src/librustc/mir/visit.rs:343
             at /home/mw/1-rust/src/librustc/mir/visit.rs:82
             at /home/mw/1-rust/src/librustc/mir/visit.rs:295
             at /home/mw/1-rust/src/librustc/mir/visit.rs:76
  18: rustc_mir::monomorphize::collector::collect_items_rec
             at src/librustc_mir/monomorphize/collector.rs:1185
             at src/librustc_mir/monomorphize/collector.rs:395
  19: rustc_mir::monomorphize::collector::collect_items_rec
             at src/librustc_mir/monomorphize/collector.rs:405
  20: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
             at src/librustc_mir/monomorphize/collector.rs:303
             at /home/mw/1-rust/src/libcore/iter/traits/iterator.rs:604
             at /home/mw/1-rust/src/libcore/iter/traits/iterator.rs:1684
             at /home/mw/1-rust/src/libcore/iter/traits/iterator.rs:1572
             at /home/mw/1-rust/src/libcore/iter/traits/iterator.rs:1684
             at /home/mw/1-rust/src/libcore/iter/traits/iterator.rs:604
             at src/librustc_mir/monomorphize/collector.rs:301
  21: rustc::util::common::time
             at /home/mw/1-rust/src/librustc/util/common.rs:150
             at /home/mw/1-rust/src/librustc/util/common.rs:144
  22: rustc_mir::monomorphize::collector::collect_crate_mono_items
             at src/librustc_mir/monomorphize/collector.rs:300
  23: rustc::util::common::time
             at src/librustc_mir/monomorphize/partitioning.rs:927
             at /home/mw/1-rust/src/librustc/util/common.rs:150
             at /home/mw/1-rust/src/librustc/util/common.rs:144
  24: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
             at src/librustc_mir/monomorphize/partitioning.rs:926
  25: rustc::ty::query::__query_compute::collect_and_partition_mono_items
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:963
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:922
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::collect_and_partition_mono_items<'tcx>>::compute
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:955
  27: rustc::dep_graph::graph::DepGraph::with_task_impl
             at /home/mw/1-rust/src/librustc/dep_graph/graph.rs:334
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at /home/mw/1-rust/src/librustc/dep_graph/graph.rs:202
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:567
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:280
             at /home/mw/1-rust/src/librustc/ty/context.rs:1966
             at /home/mw/1-rust/src/librustc/ty/context.rs:1899
             at /home/mw/1-rust/src/librustc/ty/context.rs:1965
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:279
             at /home/mw/1-rust/src/librustc/ty/context.rs:2072
             at /home/mw/1-rust/src/librustc/ty/context.rs:2056
             at /home/mw/1-rust/src/librustc/ty/context.rs:2046
             at /home/mw/1-rust/src/librustc/ty/context.rs:2056
             at /home/mw/1-rust/src/librustc/ty/context.rs:2068
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:268
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:559
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:214
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:558
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:386
  29: core::ops::function::FnOnce::call_once
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:1040
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:1032
             at src/librustc_codegen_ssa/base.rs:919
             at /home/mw/1-rust/src/libcore/ops/function.rs:231
  30: rustc::ty::query::__query_compute::backend_optimization_level
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:963
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:922
  31: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::backend_optimization_level<'tcx>>::compute
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:955
  32: rustc::dep_graph::graph::DepGraph::with_task_impl
             at /home/mw/1-rust/src/librustc/dep_graph/graph.rs:334
  33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at /home/mw/1-rust/src/librustc/dep_graph/graph.rs:202
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:567
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:280
             at /home/mw/1-rust/src/librustc/ty/context.rs:1966
             at /home/mw/1-rust/src/librustc/ty/context.rs:1899
             at /home/mw/1-rust/src/librustc/ty/context.rs:1965
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:279
             at /home/mw/1-rust/src/librustc/ty/context.rs:2072
             at /home/mw/1-rust/src/librustc/ty/context.rs:2056
             at /home/mw/1-rust/src/librustc/ty/context.rs:2046
             at /home/mw/1-rust/src/librustc/ty/context.rs:2056
             at /home/mw/1-rust/src/librustc/ty/context.rs:2068
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:268
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:559
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:214
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:558
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:386
  34: rustc_codegen_ssa::back::write::start_async_codegen
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:1040
             at /home/mw/1-rust/src/librustc/ty/query/plumbing.rs:1032
             at /home/mw/1-rust/src/librustc_codegen_ssa/back/write.rs:1025
             at /home/mw/1-rust/src/librustc_codegen_ssa/back/write.rs:441
  35: rustc_codegen_ssa::base::codegen_crate
             at /home/mw/1-rust/src/librustc_codegen_ssa/base.rs:575
  36: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
             at src/librustc_codegen_llvm/lib.rs:301
  37: rustc::util::common::time
             at src/librustc_driver/driver.rs:1354
             at /home/mw/1-rust/src/librustc/util/common.rs:150
             at /home/mw/1-rust/src/librustc/util/common.rs:144
  38: rustc_driver::driver::phase_4_codegen
             at src/librustc_driver/driver.rs:1354
  39: rustc_driver::driver::compile_input::{{closure}}
             at src/librustc_driver/driver.rs:316
  40: <std::thread::local::LocalKey<T>>::with
             at src/librustc_driver/driver.rs:1337
             at /home/mw/1-rust/src/librustc/ty/context.rs:2000
             at /home/mw/1-rust/src/librustc/ty/context.rs:1966
             at /home/mw/1-rust/src/librustc/ty/context.rs:1899
             at /home/mw/1-rust/src/librustc/ty/context.rs:1965
             at /home/mw/1-rust/src/librustc/ty/context.rs:1999
             at /home/mw/1-rust/src/librustc/ty/context.rs:1954
             at /home/mw/1-rust/src/libstd/thread/local.rs:300
             at /home/mw/1-rust/src/libstd/thread/local.rs:246
             at /home/mw/1-rust/src/librustc/ty/context.rs:1946
             at /home/mw/1-rust/src/libstd/thread/local.rs:300
             at /home/mw/1-rust/src/libstd/thread/local.rs:246
  41: rustc::ty::context::TyCtxt::create_and_enter
             at /home/mw/1-rust/src/librustc/ty/context.rs:1938
             at /home/mw/1-rust/src/librustc/ty/context.rs:1977
             at /home/mw/1-rust/src/librustc/ty/context.rs:1290
  42: rustc_driver::driver::phase_3_run_analysis_passes
             at src/librustc_driver/driver.rs:1213
  43: rustc_driver::driver::compile_input
             at src/librustc_driver/driver.rs:272
  44: rustc_driver::run_compiler_with_pool
             at src/librustc_driver/lib.rs:523
  45: <scoped_tls::ScopedKey<T>>::set
             at src/librustc_driver/lib.rs:445
             at src/librustc_driver/driver.rs:65
             at /home/mw/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  46: rustc_driver::run_compiler
             at src/librustc_driver/driver.rs:64
             at src/librustc_driver/lib.rs:444
  47: <scoped_tls::ScopedKey<T>>::set
             at src/librustc_driver/lib.rs:1646
             at src/librustc_driver/lib.rs:167
             at /home/mw/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at /home/mw/1-rust/src/libsyntax/lib.rs:100
             at /home/mw/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
#1 [backend_optimization_level] optimization level used by backend
end of query stack
error: aborting due to previous error


note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.34.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=s -C debuginfo=2 -C debug-assertions=on -C link-arg=-Tlink.x --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `cortex-m-rt`.
warning: build failed, waiting for other jobs to finish...
error: build failed

In particular it's this call that is causing the problem:

let (defids, _) = tcx.collect_and_partition_mono_items(cratenum);

The query is invoked here:

let ol = tcx.backend_optimization_level(LOCAL_CRATE);

@nagisa
Copy link
Member Author

nagisa commented Feb 21, 2019

@michaelwoerister can you check this again?

@michaelwoerister
Copy link
Member

Hm, still failing. It seems that this evaluates to true:
https://github.com/rust-lang/rust/pull/58605/files#diff-4a91d38f147ba278726bb7ec5deaf5eaR1025

@nagisa
Copy link
Member Author

nagisa commented Feb 22, 2019

This should now work.

@bors
Copy link
Contributor

bors commented Feb 25, 2019

☔ The latest upstream changes (presumably #58728) made this pull request unmergeable. Please resolve the merge conflicts.

@michaelwoerister
Copy link
Member

It does work :)

r=me after a rebase.

@nagisa
Copy link
Member Author

nagisa commented Feb 26, 2019

What the actual f happened here?

@nagisa
Copy link
Member Author

nagisa commented Feb 26, 2019

Damn is GitHub UI confusing.

@nagisa nagisa reopened this Feb 26, 2019
config::OptLevel::No
} else {
tcx.backend_optimization_level(LOCAL_CRATE)
};
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we're not putting this "don't optimize if no codegen" into the backend_optimization_level query itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally a fix would have happened all the way down inside collect_and_partition_mono_items (which would take care to not ICE when no codegen is happening), however that change is more involved than this and, given that I haven’t setup myself for reproduction, I wasn’t in a place to make such a change.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 27, 2019
@nagisa
Copy link
Member Author

nagisa commented Feb 27, 2019

@bors r=michaelwoerister

@bors
Copy link
Contributor

bors commented Feb 27, 2019

📌 Commit d89c2f6 has been approved by michaelwoerister

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 27, 2019
Centril added a commit to Centril/rust that referenced this pull request Feb 28, 2019
…oerister

Use informational target machine for metadata

Since there is nothing to optimise there...

Should fix rust-lang#58323 but haven’t tested locally.

r? @michaelwoerister
Centril added a commit to Centril/rust that referenced this pull request Feb 28, 2019
…oerister

Use informational target machine for metadata

Since there is nothing to optimise there...

Should fix rust-lang#58323 but haven’t tested locally.

r? @michaelwoerister
Centril added a commit to Centril/rust that referenced this pull request Feb 28, 2019
…oerister

Use informational target machine for metadata

Since there is nothing to optimise there...

Should fix rust-lang#58323 but haven’t tested locally.

r? @michaelwoerister
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Mar 1, 2019
…oerister

Use informational target machine for metadata

Since there is nothing to optimise there...

Should fix rust-lang#58323 but haven’t tested locally.

r? @michaelwoerister
@Centril
Copy link
Contributor

Centril commented Mar 29, 2019

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 29, 2019
@bors
Copy link
Contributor

bors commented Mar 29, 2019

⌛ Testing commit 8d4afbe with merge 4fec737...

bors added a commit that referenced this pull request Mar 29, 2019
Use informational target machine for metadata

Since there is nothing to optimise there...

Should fix #58323 but haven’t tested locally.

r? @michaelwoerister
@fortanix-bot
Copy link

Build failed for target x86_64-fortanix-unknown-sgx - status

cc @jethrogb

@bors
Copy link
Contributor

bors commented Mar 29, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: michaelwoerister
Pushing 4fec737 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 29, 2019
@bors bors merged commit 8d4afbe into rust-lang:master Mar 29, 2019
@pietroalbini
Copy link
Member

pietroalbini commented Apr 12, 2019

This wasn't backported to beta, so the regression made its way to stable. @rust-lang/compiler nominating for stable backport.

@rustbot modify labels: stable-nominated T-compiler

@rustbot rustbot added stable-nominated Nominated for backporting to the compiler in the stable channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 12, 2019
@pnkfelix
Copy link
Member

We discussed this in the T-compiler meeting today. @nagisa says they would prefer we not take on the risk of backporting this to the stable channel; given the state of the code they started with and the dificulty in converging on the version that landed, they are not sure the patch is rock solid.

Declining backport to stable branch.

@pnkfelix pnkfelix removed the stable-nominated Nominated for backporting to the compiler in the stable channel. label Apr 18, 2019
@jamesmunns
Copy link
Member

I understand this is likely difficult to backport, however I find the decision unfortunate, as it effectively breaks the ability to run cargo clippy and more notably cargo check for embedded targets with opt-level='s', which is fairly common in the ecosystem. These targets have been considered stable since the 1.32 release of rust, so this is a definite regression of a stable target. This is likely to remain for at least the next 6 weeks.

Are peripheral tools such as cargo-check and cargo-clippy included in the general Rust stability guarantee? And will these changes definitely land in 1.35, or did they not make it to beta in time for this cycle?

In the future, we may want to expand the number of items tested in the thumb-* tests contained in https://github.com/rust-lang/rust/tree/master/src/test/run-make to prevent these regressions in the future.

@pietroalbini
Copy link
Member

And will these changes definitely land in 1.35, or did they not make it to beta in time for this cycle?

The changes should already be on beta, can you test?

@jonas-schievink
Copy link
Contributor

Yes, this is fixed on the current beta.

fmckeogh added a commit to fmckeogh/bluefly that referenced this pull request Apr 19, 2019
@jonas-schievink
Copy link
Contributor

FWIW I backported this locally without issue (the touched files are only changed rarely), but since there's no information on how to build the thumb libcore I couldn't properly test it. We could also do a crater run with this on stable, I imagine?

@therealprof
Copy link
Contributor

Yes, works for me in beta.

@estebank
Copy link
Contributor

I do not know the process, but would it be possible to do a point release for a single target?

@jonas-schievink
Copy link
Contributor

@estebank not really, since the thumb libcore's are distributed as separate rustup components. They plug into the regular stable toolchain that is already installed - you don't need a new rustc to target them.

@pnkfelix
Copy link
Member

The questions above posted by @jamesmunns seem like they need to be addressed by ... the @rust-lang/dev-tools team? Or @rust-lang/core ?

  • (Except I will note, at least according to my memory and interpretation of the zulip log, that the decline-to-backport decision was not made based on the supposed difficulty of such a backport. The objection was that the author of the patch wasn't sufficiently confident in the correctness of the change! That is orthogonal, in my opinion, to the question of whether a backport itself is easy to deploy or not.)

@Centril
Copy link
Contributor

Centril commented May 16, 2019

Re. cargo check, it seems to me that it is part of the regular compiler so that can be decided by t-compiler? And cargo clippy seems to be a matter for whoever is in charge of Clippy.

@therealprof
Copy link
Contributor

Just for the record: It's not a cargo clippy problem, it was just initially observed by running clippy.

@pietroalbini
Copy link
Member

These targets have been considered stable since the 1.32 release of rust, so this is a definite regression of a stable target.

Sort of, those targets are tier 2, so they're guaranteed to build but not guaranteed to work.

@jamesmunns
Copy link
Member

There was a discussion at the 2018 all hands about making the thumb targets tier 1, however this was not done as @alexchrichton mentioned that the concept of tiers was going away, or was being retooled.

If not, I'd like to reintroduce the discussion of making the thumb targets an official tier one target, as it already has some of the ground work laid to claim this

@Manishearth
Copy link
Member

You want @rust-lang/cargo

Clippy here just uses cargo check under the hood.

I do think that we shouldn't break cargo check for embedded users as much as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Cannot create local mono-item" ICE building cortex-m code on nightly