@@ -327,6 +327,8 @@ impl PointerAuthConfig {
327327pub struct Session {
328328 pub target : Target ,
329329 pub host : Target ,
330+ pub wasm_proc_macro_tuple : TargetTuple ,
331+ pub wasm_proc_macro_target : Target ,
330332 pub opts : config:: Options ,
331333 pub target_tlib_path : SearchPath ,
332334 pub psess : ParseSess ,
@@ -395,6 +397,7 @@ pub struct Session {
395397
396398 target_filesearch : Arc < FileSearch > ,
397399 host_filesearch : Arc < FileSearch > ,
400+ wasm_proc_macro_filesearch : Option < Arc < FileSearch > > ,
398401
399402 /// The names of intrinsics that the current codegen backend replaces
400403 /// with its own implementations.
@@ -659,6 +662,9 @@ impl Session {
659662 pub fn host_filesearch ( & self ) -> & filesearch:: FileSearch {
660663 & self . host_filesearch
661664 }
665+ pub fn wasm_proc_macro_filesearch ( & self ) -> & filesearch:: FileSearch {
666+ self . wasm_proc_macro_filesearch . as_ref ( ) . expect ( "wasm_filesearch not set" )
667+ }
662668
663669 /// Returns a list of directories where target-specific tool binaries are located. Some fallback
664670 /// directories are also returned, for example if `--sysroot` is used but tools are missing
@@ -1290,6 +1296,19 @@ pub fn build_session(
12901296 dcx. handle ( ) . warn ( warning)
12911297 }
12921298
1299+ let wasm_proc_macro_tuple = TargetTuple :: from_tuple ( "wasm32-wasip2" ) ;
1300+ let ( wasm_proc_macro_target, target_warnings) = Target :: search (
1301+ & wasm_proc_macro_tuple,
1302+ sopts. sysroot . path ( ) ,
1303+ sopts. unstable_opts . unstable_options ,
1304+ )
1305+ . unwrap_or_else ( |e| {
1306+ dcx. handle ( ) . fatal ( format ! ( "Error loading wasm proc-macro target specification: {e}" ) )
1307+ } ) ;
1308+ for warning in target_warnings. warning_messages ( ) {
1309+ dcx. handle ( ) . warn ( warning)
1310+ }
1311+
12931312 let self_profiler = if let SwitchWithOptPath :: Enabled ( ref d) = sopts. unstable_opts . self_profile
12941313 {
12951314 let directory = if let Some ( directory) = d { directory } else { std:: path:: Path :: new ( "." ) } ;
@@ -1318,6 +1337,8 @@ pub fn build_session(
13181337 // FIXME use host sysroot?
13191338 let host_tlib_path = SearchPath :: from_sysroot_and_triple ( sopts. sysroot . path ( ) , host_triple) ;
13201339 let target_tlib_path = SearchPath :: from_sysroot_and_triple ( sopts. sysroot . path ( ) , target_triple) ;
1340+ let wasm_proc_macro_tlib_path =
1341+ SearchPath :: from_sysroot_and_triple ( sopts. sysroot . path ( ) , wasm_proc_macro_tuple. tuple ( ) ) ;
13211342
13221343 let prof = SelfProfilerRef :: new (
13231344 self_profiler,
@@ -1347,6 +1368,16 @@ pub fn build_session(
13471368 sopts. unstable_opts . implicit_sysroot_deps ,
13481369 ) )
13491370 } ;
1371+ let wasm_proc_macro_filesearch = if sopts. unstable_opts . wasm_proc_macros {
1372+ Some ( Arc :: new ( FileSearch :: new (
1373+ & sopts. search_paths ,
1374+ & wasm_proc_macro_tlib_path,
1375+ & wasm_proc_macro_target,
1376+ sopts. unstable_opts . implicit_sysroot_deps ,
1377+ ) ) )
1378+ } else {
1379+ None
1380+ } ;
13501381
13511382 let timings = TimingSectionHandler :: new ( sopts. json_timings ) ;
13521383
@@ -1356,6 +1387,8 @@ pub fn build_session(
13561387 let sess = Session {
13571388 target,
13581389 host,
1390+ wasm_proc_macro_tuple,
1391+ wasm_proc_macro_target,
13591392 opts : sopts,
13601393 target_tlib_path,
13611394 psess,
@@ -1379,6 +1412,7 @@ pub fn build_session(
13791412 file_depinfo : Default :: default ( ) ,
13801413 target_filesearch,
13811414 host_filesearch,
1415+ wasm_proc_macro_filesearch,
13821416 replaced_intrinsics : FxHashSet :: default ( ) , // filled by `run_compiler`
13831417 fallback_intrinsics : FxHashSet :: default ( ) , // filled by `run_compiler`
13841418 thin_lto_supported : true , // filled by `run_compiler`
0 commit comments