@@ -32,6 +32,7 @@ use std::path::{Path, PathBuf};
3232use std:: process:: { Output , Stdio , ExitStatus } ;
3333use std:: str;
3434use std:: env;
35+ use std:: ffi:: OsString ;
3536
3637pub use rustc_codegen_utils:: link:: * ;
3738
@@ -158,6 +159,33 @@ pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathB
158159 }
159160 } ;
160161
162+ let t = & sess. target . target ;
163+ if t. linker_flavor == LinkerFlavor :: Msvc && t. target_vendor == "uwp" {
164+ if let Some ( ref tool) = msvc_tool {
165+ let original_path = tool. path ( ) ;
166+ if let Some ( ref root_lib_path) = original_path. ancestors ( ) . skip ( 4 ) . next ( ) {
167+ let arch = match t. arch . as_str ( ) {
168+ "x86_64" => Some ( "x64" . to_string ( ) ) ,
169+ "x86" => Some ( "x86" . to_string ( ) ) ,
170+ "aarch64" => Some ( "arm64" . to_string ( ) ) ,
171+ _ => None ,
172+ } ;
173+ if let Some ( ref a) = arch {
174+ let mut arg = OsString :: from ( "/LIBPATH:" ) ;
175+ arg. push ( format ! ( "{}\\ lib\\ {}\\ store" , root_lib_path. display( ) , a. to_string( ) ) ) ;
176+ cmd. arg ( & arg) ;
177+ }
178+ else {
179+ warn ! ( "arch is not supported" ) ;
180+ }
181+ } else {
182+ warn ! ( "MSVC root path lib location not found" ) ;
183+ }
184+ } else {
185+ warn ! ( "link.exe not found" ) ;
186+ }
187+ }
188+
161189 // The compiler's sysroot often has some bundled tools, so add it to the
162190 // PATH for the child.
163191 let mut new_path = sess. host_filesearch ( PathKind :: All )
@@ -1028,19 +1056,6 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
10281056
10291057 cmd. include_path ( & fix_windows_verbatim_for_gcc ( & lib_path) ) ;
10301058
1031- if t. linker_flavor == LinkerFlavor :: Msvc && t. target_vendor == "uwp" {
1032- let link_tool = windows_registry:: find_tool ( "x86_64-pc-windows-msvc" , "link.exe" )
1033- . expect ( "no path found for link.exe" ) ;
1034-
1035- let original_path = link_tool. path ( ) ;
1036- let root_lib_path = original_path. ancestors ( ) . skip ( 4 ) . next ( ) . unwrap ( ) ;
1037- if t. arch == "aarch64" . to_string ( ) {
1038- cmd. include_path ( & root_lib_path. join ( format ! ( "lib\\ arm64\\ store" ) ) ) ;
1039- } else {
1040- cmd. include_path ( & root_lib_path. join ( format ! ( "lib\\ {}\\ store" , t. arch) ) ) ;
1041- }
1042- }
1043-
10441059 for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. object . as_ref ( ) ) {
10451060 cmd. add_object ( obj) ;
10461061 }
0 commit comments