@@ -32,6 +32,7 @@ use std::path::{Path, PathBuf};
32
32
use std:: process:: { Output , Stdio , ExitStatus } ;
33
33
use std:: str;
34
34
use std:: env;
35
+ use std:: ffi:: OsString ;
35
36
36
37
pub use rustc_codegen_utils:: link:: * ;
37
38
@@ -158,6 +159,33 @@ pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathB
158
159
}
159
160
} ;
160
161
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
+
161
189
// The compiler's sysroot often has some bundled tools, so add it to the
162
190
// PATH for the child.
163
191
let mut new_path = sess. host_filesearch ( PathKind :: All )
@@ -1028,19 +1056,6 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
1028
1056
1029
1057
cmd. include_path ( & fix_windows_verbatim_for_gcc ( & lib_path) ) ;
1030
1058
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
-
1044
1059
for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. object . as_ref ( ) ) {
1045
1060
cmd. add_object ( obj) ;
1046
1061
}
0 commit comments