File tree Expand file tree Collapse file tree 5 files changed +20
-1
lines changed
Expand file tree Collapse file tree 5 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -593,7 +593,10 @@ pub fn crate_name_hash(sess: &Session, crate_name: &str) -> String {
593593 // the crate id in the hash because lookups are only done by (name/vers),
594594 // not by path.
595595 let mut s = Sha256 :: new ( ) ;
596- s. input_str ( crate_id. short_name_with_version ( ) . as_slice ( ) ) ;
596+ s. input_str ( crate_name) ;
597+ for meta in sess. crate_metadata . borrow ( ) . iter ( ) {
598+ s. input_str ( meta. as_slice ( ) ) ;
599+ }
597600 truncated_hash_result ( & mut s) . as_slice ( ) . slice_to ( 8 ) . to_string ( )
598601}
599602
@@ -626,6 +629,9 @@ fn symbol_hash(tcx: &ty::ctxt,
626629 symbol_hasher. input_str ( link_meta. crate_name . as_slice ( ) ) ;
627630 symbol_hasher. input_str ( "-" ) ;
628631 symbol_hasher. input_str ( link_meta. crate_hash . as_str ( ) ) ;
632+ for meta in tcx. sess . crate_metadata . borrow ( ) . iter ( ) {
633+ symbol_hasher. input_str ( meta. as_slice ( ) ) ;
634+ }
629635 symbol_hasher. input_str ( "-" ) ;
630636 symbol_hasher. input_str ( encoder:: encoded_ty ( tcx, t) . as_slice ( ) ) ;
631637 // Prefix with 'h' so that it never blends into adjacent digits
Original file line number Diff line number Diff line change @@ -318,6 +318,8 @@ cgoptions!(
318318 "use an external assembler rather than LLVM's integrated one" ) ,
319319 relocation_model: String = ( "pic" . to_string( ) , parse_string,
320320 "choose the relocation model to use (llc -relocation-model for details)" ) ,
321+ metadata: Vec <String > = ( Vec :: new( ) , parse_list,
322+ "metadata to mangle symbol names with" ) ,
321323)
322324
323325pub fn build_codegen_options ( matches : & getopts:: Matches ) -> CodegenOptions
Original file line number Diff line number Diff line change @@ -186,6 +186,8 @@ pub fn phase_2_configure_and_expand(sess: &Session,
186186
187187 * sess. crate_types . borrow_mut ( ) =
188188 collect_crate_types ( sess, krate. attrs . as_slice ( ) ) ;
189+ * sess. crate_metadata . borrow_mut ( ) =
190+ collect_crate_metadata ( sess, krate. attrs . as_slice ( ) ) ;
189191
190192 time ( time_passes, "gated feature checking" , ( ) , |_|
191193 front:: feature_gate:: check_crate ( sess, & krate) ) ;
@@ -848,6 +850,11 @@ pub fn collect_crate_types(session: &Session,
848850 } ) . collect ( )
849851}
850852
853+ pub fn collect_crate_metadata ( session : & Session ,
854+ _attrs : & [ ast:: Attribute ] ) -> Vec < String > {
855+ session. opts . cg . metadata . clone ( )
856+ }
857+
851858pub struct OutputFilenames {
852859 pub out_directory : Path ,
853860 pub out_filestem : String ,
Original file line number Diff line number Diff line change @@ -311,6 +311,8 @@ fn print_crate_info(sess: &Session,
311311 }
312312 if crate_file_name {
313313 let crate_types = driver:: collect_crate_types ( sess, attrs. as_slice ( ) ) ;
314+ let metadata = driver:: collect_crate_metadata ( sess, attrs. as_slice ( ) ) ;
315+ * sess. crate_metadata . borrow_mut ( ) = metadata;
314316 for & style in crate_types. iter ( ) {
315317 let fname = link:: filename_for_input ( sess, style, id. as_slice ( ) ,
316318 & t_outputs. with_extension ( "" ) ) ;
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ pub struct Session {
4747 pub lints : RefCell < NodeMap < Vec < ( lint:: LintId , codemap:: Span , String ) > > > ,
4848 pub node_id : Cell < ast:: NodeId > ,
4949 pub crate_types : RefCell < Vec < config:: CrateType > > ,
50+ pub crate_metadata : RefCell < Vec < String > > ,
5051 pub features : front:: feature_gate:: Features ,
5152
5253 /// The maximum recursion limit for potentially infinitely recursive
@@ -243,6 +244,7 @@ pub fn build_session_(sopts: config::Options,
243244 lints : RefCell :: new ( NodeMap :: new ( ) ) ,
244245 node_id : Cell :: new ( 1 ) ,
245246 crate_types : RefCell :: new ( Vec :: new ( ) ) ,
247+ crate_metadata : RefCell :: new ( Vec :: new ( ) ) ,
246248 features : front:: feature_gate:: Features :: new ( ) ,
247249 recursion_limit : Cell :: new ( 64 ) ,
248250 } ;
You can’t perform that action at this time.
0 commit comments