Skip to content

Commit 5d4a25d

Browse files
committed
Rollup merge of rust-lang#53465 - bjorn3:remove_link_meta_struct, r=varkor
Remove LinkMeta struct Fixes rust-lang#53291
2 parents c980ba7 + d52047f commit 5d4a25d

File tree

10 files changed

+25
-53
lines changed

10 files changed

+25
-53
lines changed

src/librustc/middle/cstore.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ pub use self::NativeLibraryKind::*;
4242

4343
// lonely orphan structs and enums looking for a better home
4444

45-
#[derive(Clone, Debug, Copy)]
46-
pub struct LinkMeta {
47-
pub crate_hash: Svh,
48-
}
49-
5045
/// Where a crate came from on the local filesystem. One of these three options
5146
/// must be non-None.
5247
#[derive(PartialEq, Clone, Debug)]
@@ -233,8 +228,7 @@ pub trait CrateStore {
233228

234229
// utility functions
235230
fn encode_metadata<'a, 'tcx>(&self,
236-
tcx: TyCtxt<'a, 'tcx, 'tcx>,
237-
link_meta: &LinkMeta)
231+
tcx: TyCtxt<'a, 'tcx, 'tcx>)
238232
-> EncodedMetadata;
239233
fn metadata_encoding_version(&self) -> &[u8];
240234
}

src/librustc/ty/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use lint::{self, Lint};
2626
use ich::{StableHashingContext, NodeIdHashingMode};
2727
use infer::canonical::{CanonicalVarInfo, CanonicalVarInfos};
2828
use infer::outlives::free_region_map::FreeRegionMap;
29-
use middle::cstore::{CrateStoreDyn, LinkMeta};
29+
use middle::cstore::CrateStoreDyn;
3030
use middle::cstore::EncodedMetadata;
3131
use middle::lang_items;
3232
use middle::resolve_lifetime::{self, ObjectLifetimeDefault};
@@ -1490,10 +1490,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14901490
}
14911491

14921492
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
1493-
pub fn encode_metadata(self, link_meta: &LinkMeta)
1493+
pub fn encode_metadata(self)
14941494
-> EncodedMetadata
14951495
{
1496-
self.cstore.encode_metadata(self, link_meta)
1496+
self.cstore.encode_metadata(self)
14971497
}
14981498
}
14991499

src/librustc_codegen_llvm/back/link.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ use std::str;
4747
use syntax::attr;
4848

4949
pub use rustc_codegen_utils::link::{find_crate_name, filename_for_input, default_output_for_target,
50-
invalid_output_for_target, build_link_meta, out_filename,
51-
check_file_is_writeable};
50+
invalid_output_for_target, out_filename, check_file_is_writeable};
5251

5352
// The third parameter is for env vars, used on windows to set up the
5453
// path for MSVC to find its DLLs, and gcc to find its bundled

src/librustc_codegen_llvm/back/write.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use base;
1919
use consts;
2020
use rustc_incremental::{copy_cgu_workproducts_to_incr_comp_cache_dir, in_incr_comp_dir};
2121
use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind};
22-
use rustc::middle::cstore::{LinkMeta, EncodedMetadata};
22+
use rustc::middle::cstore::EncodedMetadata;
2323
use rustc::session::config::{self, OutputFilenames, OutputType, Passes, Sanitizer, Lto};
2424
use rustc::session::Session;
2525
use rustc::util::nodemap::FxHashMap;
@@ -32,6 +32,7 @@ use rustc::ty::TyCtxt;
3232
use rustc::util::common::{time_ext, time_depth, set_time_depth, print_time_passes_entry};
3333
use rustc_fs_util::{path2cstr, link_or_copy};
3434
use rustc_data_structures::small_c_str::SmallCStr;
35+
use rustc_data_structures::svh::Svh;
3536
use errors::{self, Handler, Level, DiagnosticBuilder, FatalError, DiagnosticId};
3637
use errors::emitter::{Emitter};
3738
use syntax::attr;
@@ -912,13 +913,13 @@ fn need_crate_bitcode_for_rlib(sess: &Session) -> bool {
912913

913914
pub fn start_async_codegen(tcx: TyCtxt,
914915
time_graph: Option<TimeGraph>,
915-
link: LinkMeta,
916916
metadata: EncodedMetadata,
917917
coordinator_receive: Receiver<Box<dyn Any + Send>>,
918918
total_cgus: usize)
919919
-> OngoingCodegen {
920920
let sess = tcx.sess;
921921
let crate_name = tcx.crate_name(LOCAL_CRATE);
922+
let crate_hash = tcx.crate_hash(LOCAL_CRATE);
922923
let no_builtins = attr::contains_name(&tcx.hir.krate().attrs, "no_builtins");
923924
let subsystem = attr::first_attr_value_str_by_name(&tcx.hir.krate().attrs,
924925
"windows_subsystem");
@@ -1037,7 +1038,7 @@ pub fn start_async_codegen(tcx: TyCtxt,
10371038

10381039
OngoingCodegen {
10391040
crate_name,
1040-
link,
1041+
crate_hash,
10411042
metadata,
10421043
windows_subsystem,
10431044
linker_info,
@@ -2270,7 +2271,7 @@ impl SharedEmitterMain {
22702271

22712272
pub struct OngoingCodegen {
22722273
crate_name: Symbol,
2273-
link: LinkMeta,
2274+
crate_hash: Svh,
22742275
metadata: EncodedMetadata,
22752276
windows_subsystem: Option<String>,
22762277
linker_info: LinkerInfo,
@@ -2321,7 +2322,7 @@ impl OngoingCodegen {
23212322

23222323
(CodegenResults {
23232324
crate_name: self.crate_name,
2324-
link: self.link,
2325+
crate_hash: self.crate_hash,
23252326
metadata: self.metadata,
23262327
windows_subsystem: self.windows_subsystem,
23272328
linker_info: self.linker_info,

src/librustc_codegen_llvm/base.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use super::ModuleCodegen;
2929
use super::ModuleKind;
3030

3131
use abi;
32-
use back::link;
3332
use back::write::{self, OngoingCodegen};
3433
use llvm::{self, TypeKind, get_param};
3534
use metadata;
@@ -42,7 +41,7 @@ use rustc::ty::{self, Ty, TyCtxt};
4241
use rustc::ty::layout::{self, Align, TyLayout, LayoutOf};
4342
use rustc::ty::query::Providers;
4443
use rustc::dep_graph::{DepNode, DepConstructor};
45-
use rustc::middle::cstore::{self, LinkMeta, LinkagePreference};
44+
use rustc::middle::cstore::{self, LinkagePreference};
4645
use rustc::middle::exported_symbols;
4746
use rustc::util::common::{time, print_time_passes_entry};
4847
use rustc::util::profiling::ProfileCategory;
@@ -608,8 +607,7 @@ fn maybe_create_entry_wrapper(cx: &CodegenCx) {
608607
}
609608

610609
fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
611-
llvm_module: &ModuleLlvm,
612-
link_meta: &LinkMeta)
610+
llvm_module: &ModuleLlvm)
613611
-> EncodedMetadata {
614612
use std::io::Write;
615613
use flate2::Compression;
@@ -641,7 +639,7 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
641639
return EncodedMetadata::new();
642640
}
643641

644-
let metadata = tcx.encode_metadata(link_meta);
642+
let metadata = tcx.encode_metadata();
645643
if kind == MetadataKind::Uncompressed {
646644
return metadata;
647645
}
@@ -719,8 +717,6 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
719717
tcx.sess.fatal("this compiler's LLVM does not support PGO");
720718
}
721719

722-
let crate_hash = tcx.crate_hash(LOCAL_CRATE);
723-
let link_meta = link::build_link_meta(crate_hash);
724720
let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);
725721

726722
// Codegen the metadata.
@@ -732,7 +728,7 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
732728
.to_string();
733729
let metadata_llvm_module = ModuleLlvm::new(tcx.sess, &metadata_cgu_name);
734730
let metadata = time(tcx.sess, "write metadata", || {
735-
write_metadata(tcx, &metadata_llvm_module, &link_meta)
731+
write_metadata(tcx, &metadata_llvm_module)
736732
});
737733
tcx.sess.profiler(|p| p.end_activity(ProfileCategory::Codegen));
738734

@@ -754,7 +750,6 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
754750
let ongoing_codegen = write::start_async_codegen(
755751
tcx,
756752
time_graph.clone(),
757-
link_meta,
758753
metadata,
759754
rx,
760755
1);
@@ -789,7 +784,6 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
789784
let ongoing_codegen = write::start_async_codegen(
790785
tcx,
791786
time_graph.clone(),
792-
link_meta,
793787
metadata,
794788
rx,
795789
codegen_units.len());

src/librustc_codegen_llvm/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ use rustc::util::nodemap::{FxHashSet, FxHashMap};
8888
use rustc::util::profiling::ProfileCategory;
8989
use rustc_mir::monomorphize;
9090
use rustc_codegen_utils::codegen_backend::CodegenBackend;
91+
use rustc_data_structures::svh::Svh;
9192

9293
mod diagnostics;
9394

@@ -251,7 +252,7 @@ impl CodegenBackend for LlvmCodegenBackend {
251252

252253
// Now that we won't touch anything in the incremental compilation directory
253254
// any more, we can finalize it (which involves renaming it)
254-
rustc_incremental::finalize_session_directory(sess, ongoing_codegen.link.crate_hash);
255+
rustc_incremental::finalize_session_directory(sess, ongoing_codegen.crate_hash);
255256

256257
Ok(())
257258
}
@@ -389,7 +390,7 @@ struct CodegenResults {
389390
modules: Vec<CompiledModule>,
390391
allocator_module: Option<CompiledModule>,
391392
metadata_module: CompiledModule,
392-
link: rustc::middle::cstore::LinkMeta,
393+
crate_hash: Svh,
393394
metadata: rustc::middle::cstore::EncodedMetadata,
394395
windows_subsystem: Option<String>,
395396
linker_info: back::linker::LinkerInfo,

src/librustc_codegen_utils/codegen_backend.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use rustc::dep_graph::DepGraph;
4444
use rustc_target::spec::Target;
4545
use rustc_data_structures::fx::FxHashMap;
4646
use rustc_mir::monomorphize::collector;
47-
use link::{build_link_meta, out_filename};
47+
use link::out_filename;
4848

4949
pub use rustc_data_structures::sync::MetadataRef;
5050

@@ -180,8 +180,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
180180
}
181181
tcx.sess.abort_if_errors();
182182

183-
let link_meta = build_link_meta(tcx.crate_hash(LOCAL_CRATE));
184-
let metadata = tcx.encode_metadata(&link_meta);
183+
let metadata = tcx.encode_metadata();
185184

186185
box OngoingCodegen {
187186
metadata: metadata,

src/librustc_codegen_utils/link.rs

-10
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
use rustc::session::config::{self, OutputFilenames, Input, OutputType};
1212
use rustc::session::Session;
13-
use rustc::middle::cstore::LinkMeta;
14-
use rustc_data_structures::svh::Svh;
1513
use std::path::{Path, PathBuf};
1614
use syntax::{ast, attr};
1715
use syntax_pos::Span;
@@ -50,14 +48,6 @@ fn is_writeable(p: &Path) -> bool {
5048
}
5149
}
5250

53-
pub fn build_link_meta(crate_hash: Svh) -> LinkMeta {
54-
let r = LinkMeta {
55-
crate_hash,
56-
};
57-
info!("{:?}", r);
58-
return r;
59-
}
60-
6151
pub fn find_crate_name(sess: Option<&Session>,
6252
attrs: &[ast::Attribute],
6353
input: &Input) -> String {

src/librustc_metadata/cstore_impl.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use schema;
1717

1818
use rustc::ty::query::QueryConfig;
1919
use rustc::middle::cstore::{CrateStore, DepKind,
20-
LinkMeta,
2120
EncodedMetadata, NativeLibraryKind};
2221
use rustc::middle::exported_symbols::ExportedSymbol;
2322
use rustc::middle::stability::DeprecationEntry;
@@ -567,11 +566,10 @@ impl CrateStore for cstore::CStore {
567566
}
568567

569568
fn encode_metadata<'a, 'tcx>(&self,
570-
tcx: TyCtxt<'a, 'tcx, 'tcx>,
571-
link_meta: &LinkMeta)
569+
tcx: TyCtxt<'a, 'tcx, 'tcx>)
572570
-> EncodedMetadata
573571
{
574-
encoder::encode_metadata(tcx, link_meta)
572+
encoder::encode_metadata(tcx)
575573
}
576574

577575
fn metadata_encoding_version(&self) -> &[u8]

src/librustc_metadata/encoder.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use index_builder::{FromId, IndexBuilder, Untracked};
1313
use isolated_encoder::IsolatedEncoder;
1414
use schema::*;
1515

16-
use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary,
16+
use rustc::middle::cstore::{LinkagePreference, NativeLibrary,
1717
EncodedMetadata, ForeignModule};
1818
use rustc::hir::def::CtorKind;
1919
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LocalDefId, LOCAL_CRATE};
@@ -52,7 +52,6 @@ use rustc::hir::intravisit;
5252
pub struct EncodeContext<'a, 'tcx: 'a> {
5353
opaque: opaque::Encoder,
5454
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
55-
link_meta: &'a LinkMeta,
5655

5756
lazy_state: LazyState,
5857
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
@@ -482,7 +481,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
482481
let index_bytes = self.position() - i;
483482

484483
let attrs = tcx.hir.krate_attrs();
485-
let link_meta = self.link_meta;
486484
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateType::ProcMacro);
487485
let has_default_lib_allocator = attr::contains_name(&attrs, "default_lib_allocator");
488486
let has_global_allocator = *tcx.sess.has_global_allocator.get();
@@ -491,7 +489,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
491489
name: tcx.crate_name(LOCAL_CRATE),
492490
extra_filename: tcx.sess.opts.cg.extra_filename.clone(),
493491
triple: tcx.sess.opts.target_triple.clone(),
494-
hash: link_meta.crate_hash,
492+
hash: tcx.crate_hash(LOCAL_CRATE),
495493
disambiguator: tcx.sess.local_crate_disambiguator(),
496494
panic_strategy: tcx.sess.panic_strategy(),
497495
edition: hygiene::default_edition(),
@@ -1824,8 +1822,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> {
18241822
// will allow us to slice the metadata to the precise length that we just
18251823
// generated regardless of trailing bytes that end up in it.
18261824

1827-
pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1828-
link_meta: &LinkMeta)
1825+
pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
18291826
-> EncodedMetadata
18301827
{
18311828
let mut encoder = opaque::Encoder::new(vec![]);
@@ -1838,7 +1835,6 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
18381835
let mut ecx = EncodeContext {
18391836
opaque: encoder,
18401837
tcx,
1841-
link_meta,
18421838
lazy_state: LazyState::NoNode,
18431839
type_shorthands: Default::default(),
18441840
predicate_shorthands: Default::default(),

0 commit comments

Comments
 (0)