@@ -25,10 +25,11 @@ use std::time::Instant;
2525
2626fn main ( ) {
2727 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 ( ) ) ;
2829
2930 // Detect whether or not we're a build script depending on whether --target
3031 // 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" ) ;
3233 let version = args. iter ( ) . find ( |w| & * * w == "-vV" ) ;
3334
3435 let verbose = match env:: var ( "RUSTC_VERBOSE" ) {
@@ -59,8 +60,7 @@ fn main() {
5960 cmd. args ( & args) . env ( dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
6061
6162 // 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" ) ;
6464
6565 if let Some ( crate_name) = crate_name {
6666 if let Some ( target) = env:: var_os ( "RUSTC_TIME" ) {
@@ -106,6 +106,15 @@ fn main() {
106106 {
107107 cmd. arg ( "-C" ) . arg ( "panic=abort" ) ;
108108 }
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+ }
109118 } else {
110119 // FIXME(rust-lang/cargo#5754) we shouldn't be using special env vars
111120 // here, but rather Cargo should know what flags to pass rustc itself.
0 commit comments