@@ -5,6 +5,7 @@ use std::path::{Path, PathBuf};
55use std:: { env, io, iter, mem, str} ;
66
77use find_msvc_tools;
8+ use rustc_hir:: attrs:: WindowsSubsystemKind ;
89use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
910use rustc_metadata:: {
1011 find_native_static_library, try_find_native_dynamic_library, try_find_native_static_library,
@@ -345,7 +346,7 @@ pub(crate) trait Linker {
345346 crate_type : CrateType ,
346347 symbols : & [ ( String , SymbolExportKind ) ] ,
347348 ) ;
348- fn subsystem ( & mut self , subsystem : & str ) ;
349+ fn windows_subsystem ( & mut self , subsystem : WindowsSubsystemKind ) ;
349350 fn linker_plugin_lto ( & mut self ) ;
350351 fn add_eh_frame_header ( & mut self ) { }
351352 fn add_no_exec ( & mut self ) { }
@@ -884,8 +885,8 @@ impl<'a> Linker for GccLinker<'a> {
884885 }
885886 }
886887
887- fn subsystem ( & mut self , subsystem : & str ) {
888- self . link_args ( & [ "--subsystem" , subsystem] ) ;
888+ fn windows_subsystem ( & mut self , subsystem : WindowsSubsystemKind ) {
889+ self . link_args ( & [ "--subsystem" , subsystem. as_str ( ) ] ) ;
889890 }
890891
891892 fn reset_per_library_state ( & mut self ) {
@@ -1159,9 +1160,8 @@ impl<'a> Linker for MsvcLinker<'a> {
11591160 self . link_arg ( & arg) ;
11601161 }
11611162
1162- fn subsystem ( & mut self , subsystem : & str ) {
1163- // Note that previous passes of the compiler validated this subsystem,
1164- // so we just blindly pass it to the linker.
1163+ fn windows_subsystem ( & mut self , subsystem : WindowsSubsystemKind ) {
1164+ let subsystem = subsystem. as_str ( ) ;
11651165 self . link_arg ( & format ! ( "/SUBSYSTEM:{subsystem}" ) ) ;
11661166
11671167 // Windows has two subsystems we're interested in right now, the console
@@ -1307,7 +1307,7 @@ impl<'a> Linker for EmLinker<'a> {
13071307 self . cc_arg ( arg) ;
13081308 }
13091309
1310- fn subsystem ( & mut self , _subsystem : & str ) {
1310+ fn windows_subsystem ( & mut self , _subsystem : WindowsSubsystemKind ) {
13111311 // noop
13121312 }
13131313
@@ -1444,7 +1444,7 @@ impl<'a> Linker for WasmLd<'a> {
14441444 }
14451445 }
14461446
1447- fn subsystem ( & mut self , _subsystem : & str ) { }
1447+ fn windows_subsystem ( & mut self , _subsystem : WindowsSubsystemKind ) { }
14481448
14491449 fn linker_plugin_lto ( & mut self ) {
14501450 match self . sess . opts . cg . linker_plugin_lto {
@@ -1566,7 +1566,8 @@ impl<'a> Linker for L4Bender<'a> {
15661566 self . sess . dcx ( ) . emit_warn ( errors:: L4BenderExportingSymbolsUnimplemented ) ;
15671567 }
15681568
1569- fn subsystem ( & mut self , subsystem : & str ) {
1569+ fn windows_subsystem ( & mut self , subsystem : WindowsSubsystemKind ) {
1570+ let subsystem = subsystem. as_str ( ) ;
15701571 self . link_arg ( & format ! ( "--subsystem {subsystem}" ) ) ;
15711572 }
15721573
@@ -1735,7 +1736,7 @@ impl<'a> Linker for AixLinker<'a> {
17351736 self . link_arg ( format ! ( "-bE:{}" , path. to_str( ) . unwrap( ) ) ) ;
17361737 }
17371738
1738- fn subsystem ( & mut self , _subsystem : & str ) { }
1739+ fn windows_subsystem ( & mut self , _subsystem : WindowsSubsystemKind ) { }
17391740
17401741 fn reset_per_library_state ( & mut self ) {
17411742 self . hint_dynamic ( ) ;
@@ -1969,7 +1970,7 @@ impl<'a> Linker for PtxLinker<'a> {
19691970 ) {
19701971 }
19711972
1972- fn subsystem ( & mut self , _subsystem : & str ) { }
1973+ fn windows_subsystem ( & mut self , _subsystem : WindowsSubsystemKind ) { }
19731974
19741975 fn linker_plugin_lto ( & mut self ) { }
19751976}
@@ -2050,7 +2051,7 @@ impl<'a> Linker for LlbcLinker<'a> {
20502051 }
20512052 }
20522053
2053- fn subsystem ( & mut self , _subsystem : & str ) { }
2054+ fn windows_subsystem ( & mut self , _subsystem : WindowsSubsystemKind ) { }
20542055
20552056 fn linker_plugin_lto ( & mut self ) { }
20562057}
@@ -2134,7 +2135,7 @@ impl<'a> Linker for BpfLinker<'a> {
21342135 }
21352136 }
21362137
2137- fn subsystem ( & mut self , _subsystem : & str ) { }
2138+ fn windows_subsystem ( & mut self , _subsystem : WindowsSubsystemKind ) { }
21382139
21392140 fn linker_plugin_lto ( & mut self ) { }
21402141}
0 commit comments