@@ -25,10 +25,11 @@ use std::time::Instant;
25
25
26
26
fn main ( ) {
27
27
let args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
28
+ let arg = |name| args. windows ( 2 ) . find ( |args| args[ 0 ] == name) . and_then ( |args| args[ 1 ] . to_str ( ) ) ;
28
29
29
30
// Detect whether or not we're a build script depending on whether --target
30
31
// is passed (a bit janky...)
31
- let target = args . windows ( 2 ) . find ( |w| & * w [ 0 ] == "--target" ) . and_then ( |w| w [ 1 ] . to_str ( ) ) ;
32
+ let target = arg ( "--target" ) ;
32
33
let version = args. iter ( ) . find ( |w| & * * w == "-vV" ) ;
33
34
34
35
let verbose = match env:: var ( "RUSTC_VERBOSE" ) {
@@ -59,8 +60,7 @@ fn main() {
59
60
cmd. args ( & args) . env ( dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
60
61
61
62
// Get the name of the crate we're compiling, if any.
62
- let crate_name =
63
- args. windows ( 2 ) . find ( |args| args[ 0 ] == "--crate-name" ) . and_then ( |args| args[ 1 ] . to_str ( ) ) ;
63
+ let crate_name = arg ( "--crate-name" ) ;
64
64
65
65
if let Some ( crate_name) = crate_name {
66
66
if let Some ( target) = env:: var_os ( "RUSTC_TIME" ) {
@@ -106,6 +106,15 @@ fn main() {
106
106
{
107
107
cmd. arg ( "-C" ) . arg ( "panic=abort" ) ;
108
108
}
109
+
110
+ // `-Ztls-model=initial-exec` must not be applied to proc-macros, see
111
+ // issue https://github.com/rust-lang/rust/issues/100530
112
+ if env:: var ( "RUSTC_TLS_MODEL_INITIAL_EXEC" ) . is_ok ( )
113
+ && arg ( "--crate-type" ) != Some ( "proc-macro" )
114
+ && !matches ! ( crate_name, Some ( "proc_macro2" | "quote" | "syn" | "synstructure" ) )
115
+ {
116
+ cmd. arg ( "-Ztls-model=initial-exec" ) ;
117
+ }
109
118
} else {
110
119
// FIXME(rust-lang/cargo#5754) we shouldn't be using special env vars
111
120
// here, but rather Cargo should know what flags to pass rustc itself.
0 commit comments