diff options
| author | bors <bors@rust-lang.org> | 2020-05-23 03:30:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-05-23 03:30:07 +0000 |
| commit | 7f940ef5d91b53e889f111f27e00849f2f5ae4a2 (patch) | |
| tree | 0ab268d2eb6d5d13266fcf53878919603439c62a /src/librustc_codegen_ssa/back/write.rs | |
| parent | 215f2d3294b08dbdcf8f7d40de21ef1e7eae0a2d (diff) | |
| parent | 307153e611433f9224224a4511b6ea4f362ffe28 (diff) | |
Auto merge of #72256 - ecstatic-morse:once-cell, r=Mark-Simulacrum
Use `once_cell` crate instead of custom data structure Internally, we use the [`Once`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/sync/struct.Once.html) type for shared data that is initialized exactly once and only read from afterwards. `Once` uses a `parking_lot::Mutex` when the parallel compiler is enabled and a `RefCell` when it is not. This PR switches to the [`once_cell`](https://crates.io/crates/once_cell) crate, which also uses a `parking_lot::Mutex` for its `sync` version (because we enable the `parking_lot` feature) but has zero overhead for its `unsync` one. This PR adds `once_cell` to the list of whitelisted dependencies. I think this is acceptable because it is already used in `rustc_driver`, is owned by a well-known community member (cc @matklad), and has a stable release. cc @rust-lang/compiler `once_cell` has a slightly more minimal API than `Once`, which allows for initialization to be either optimistic (evaluate the initializer and then synchronize) or pessimistic (synchronize and then evaluate the initializer). `once_cell`'s `get_or_init` is always pessimistic. The optimistic version is only used once in the current `master`. r? @Mark-Simulacrum
Diffstat (limited to 'src/librustc_codegen_ssa/back/write.rs')
| -rw-r--r-- | src/librustc_codegen_ssa/back/write.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index f9ee7d8c5de..9e03c283cfb 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -382,7 +382,7 @@ pub struct CompiledModules { fn need_bitcode_in_object(sess: &Session) -> bool { let requested_for_rlib = sess.opts.cg.embed_bitcode - && sess.crate_types.borrow().contains(&CrateType::Rlib) + && sess.crate_types().contains(&CrateType::Rlib) && sess.opts.output_types.contains_key(&OutputType::Exe); let forced_by_target = sess.target.target.options.forces_embed_bitcode; requested_for_rlib || forced_by_target @@ -991,7 +991,7 @@ fn start_executing_work<B: ExtraBackendMethods>( }; let cgcx = CodegenContext::<B> { backend: backend.clone(), - crate_types: sess.crate_types.borrow().clone(), + crate_types: sess.crate_types().to_vec(), each_linked_rlib_for_lto, lto: sess.lto(), no_landing_pads: sess.panic_strategy() == PanicStrategy::Abort, @@ -1812,7 +1812,7 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool { ); tcx.sess.target.target.options.is_like_msvc && - tcx.sess.crate_types.borrow().iter().any(|ct| *ct == CrateType::Rlib) && + tcx.sess.crate_types().iter().any(|ct| *ct == CrateType::Rlib) && // ThinLTO can't handle this workaround in all cases, so we don't // emit the `__imp_` symbols. Instead we make them unnecessary by disallowing // dynamic linking when linker plugin LTO is enabled. |
