@@ -95,6 +95,23 @@ pub enum Lto {
95
95
Fat ,
96
96
}
97
97
98
+ #[ derive( Clone , PartialEq , Hash ) ]
99
+ pub enum CrossLangLto {
100
+ LinkerPlugin ( PathBuf ) ,
101
+ NoLink ,
102
+ Disabled
103
+ }
104
+
105
+ impl CrossLangLto {
106
+ pub fn embed_bitcode ( & self ) -> bool {
107
+ match * self {
108
+ CrossLangLto :: LinkerPlugin ( _) |
109
+ CrossLangLto :: NoLink => true ,
110
+ CrossLangLto :: Disabled => false ,
111
+ }
112
+ }
113
+ }
114
+
98
115
#[ derive( Clone , Copy , PartialEq , Hash ) ]
99
116
pub enum DebugInfoLevel {
100
117
NoDebugInfo ,
@@ -412,6 +429,7 @@ top_level_options!(
412
429
413
430
// Remap source path prefixes in all output (messages, object files, debug, etc)
414
431
remap_path_prefix: Vec <( PathBuf , PathBuf ) > [ UNTRACKED ] ,
432
+
415
433
edition: Edition [ TRACKED ] ,
416
434
}
417
435
) ;
@@ -777,11 +795,15 @@ macro_rules! options {
777
795
Some ( "`string` or `string=string`" ) ;
778
796
pub const parse_lto: Option <& ' static str > =
779
797
Some ( "one of `thin`, `fat`, or omitted" ) ;
798
+ pub const parse_cross_lang_lto: Option <& ' static str > =
799
+ Some ( "either a boolean (`yes`, `no`, `on`, `off`, etc), `no-link`, \
800
+ or the path to the linker plugin") ;
780
801
}
781
802
782
803
#[ allow( dead_code) ]
783
804
mod $mod_set {
784
- use super :: { $struct_name, Passes , SomePasses , AllPasses , Sanitizer , Lto } ;
805
+ use super :: { $struct_name, Passes , SomePasses , AllPasses , Sanitizer , Lto ,
806
+ CrossLangLto } ;
785
807
use rustc_target:: spec:: { LinkerFlavor , PanicStrategy , RelroLevel } ;
786
808
use std:: path:: PathBuf ;
787
809
@@ -986,6 +1008,26 @@ macro_rules! options {
986
1008
true
987
1009
}
988
1010
1011
+ fn parse_cross_lang_lto( slot: & mut CrossLangLto , v: Option <& str >) -> bool {
1012
+ if v. is_some( ) {
1013
+ let mut bool_arg = None ;
1014
+ if parse_opt_bool( & mut bool_arg, v) {
1015
+ * slot = if bool_arg. unwrap( ) {
1016
+ CrossLangLto :: NoLink
1017
+ } else {
1018
+ CrossLangLto :: Disabled
1019
+ } ;
1020
+ return true
1021
+ }
1022
+ }
1023
+
1024
+ * slot = match v {
1025
+ None |
1026
+ Some ( "no-link" ) => CrossLangLto :: NoLink ,
1027
+ Some ( path) => CrossLangLto :: LinkerPlugin ( PathBuf :: from( path) ) ,
1028
+ } ;
1029
+ true
1030
+ }
989
1031
}
990
1032
) }
991
1033
@@ -1295,7 +1337,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
1295
1337
"make the current crate share its generic instantiations" ) ,
1296
1338
chalk: bool = ( false , parse_bool, [ TRACKED ] ,
1297
1339
"enable the experimental Chalk-based trait solving engine" ) ,
1298
- cross_lang_lto: bool = ( false , parse_bool , [ TRACKED ] ,
1340
+ cross_lang_lto: CrossLangLto = ( CrossLangLto :: Disabled , parse_cross_lang_lto , [ TRACKED ] ,
1299
1341
"generate build artifacts that are compatible with linker-based LTO." ) ,
1300
1342
}
1301
1343
@@ -2327,7 +2369,7 @@ mod dep_tracking {
2327
2369
use std:: path:: PathBuf ;
2328
2370
use std:: collections:: hash_map:: DefaultHasher ;
2329
2371
use super :: { CrateType , DebugInfoLevel , ErrorOutputType , Lto , OptLevel , OutputTypes ,
2330
- Passes , Sanitizer } ;
2372
+ Passes , Sanitizer , CrossLangLto } ;
2331
2373
use syntax:: feature_gate:: UnstableFeatures ;
2332
2374
use rustc_target:: spec:: { PanicStrategy , RelroLevel , TargetTriple } ;
2333
2375
use syntax:: edition:: Edition ;
@@ -2391,6 +2433,7 @@ mod dep_tracking {
2391
2433
impl_dep_tracking_hash_via_hash ! ( Option <Sanitizer >) ;
2392
2434
impl_dep_tracking_hash_via_hash ! ( TargetTriple ) ;
2393
2435
impl_dep_tracking_hash_via_hash ! ( Edition ) ;
2436
+ impl_dep_tracking_hash_via_hash ! ( CrossLangLto ) ;
2394
2437
2395
2438
impl_dep_tracking_hash_for_sortable_vec_of ! ( String ) ;
2396
2439
impl_dep_tracking_hash_for_sortable_vec_of ! ( PathBuf ) ;
@@ -2455,7 +2498,7 @@ mod tests {
2455
2498
use lint;
2456
2499
use middle:: cstore;
2457
2500
use session:: config:: { build_configuration, build_session_options_and_crate_config} ;
2458
- use session:: config:: Lto ;
2501
+ use session:: config:: { Lto , CrossLangLto } ;
2459
2502
use session:: build_session;
2460
2503
use std:: collections:: { BTreeMap , BTreeSet } ;
2461
2504
use std:: iter:: FromIterator ;
@@ -3111,6 +3154,10 @@ mod tests {
3111
3154
opts = reference. clone ( ) ;
3112
3155
opts. debugging_opts . relro_level = Some ( RelroLevel :: Full ) ;
3113
3156
assert ! ( reference. dep_tracking_hash( ) != opts. dep_tracking_hash( ) ) ;
3157
+
3158
+ opts = reference. clone ( ) ;
3159
+ opts. debugging_opts . cross_lang_lto = CrossLangLto :: NoLink ;
3160
+ assert ! ( reference. dep_tracking_hash( ) != opts. dep_tracking_hash( ) ) ;
3114
3161
}
3115
3162
3116
3163
#[ test]
0 commit comments