Port the #![windows_subsystem] attribute to the new attribute system · rust-lang/rust@2ab2090 (original) (raw)

`@@ -5,6 +5,7 @@ use std::path::{Path, PathBuf};

`

5

5

`use std::{env, io, iter, mem, str};

`

6

6

``

7

7

`use find_msvc_tools;

`

``

8

`+

use rustc_hir::attrs::WindowsSubsystemKind;

`

8

9

`use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};

`

9

10

`use rustc_metadata::{

`

10

11

` find_native_static_library, try_find_native_dynamic_library, try_find_native_static_library,

`

`@@ -345,7 +346,7 @@ pub(crate) trait Linker {

`

345

346

`crate_type: CrateType,

`

346

347

`symbols: &[(String, SymbolExportKind)],

`

347

348

`);

`

348

``

`-

fn subsystem(&mut self, subsystem: &str);

`

``

349

`+

fn windows_subsystem(&mut self, subsystem: WindowsSubsystemKind);

`

349

350

`fn linker_plugin_lto(&mut self);

`

350

351

`fn add_eh_frame_header(&mut self) {}

`

351

352

`fn add_no_exec(&mut self) {}

`

`@@ -884,8 +885,8 @@ impl<'a> Linker for GccLinker<'a> {

`

884

885

`}

`

885

886

`}

`

886

887

``

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()]);

`

889

890

`}

`

890

891

``

891

892

`fn reset_per_library_state(&mut self) {

`

`@@ -1159,9 +1160,8 @@ impl<'a> Linker for MsvcLinker<'a> {

`

1159

1160

`self.link_arg(&arg);

`

1160

1161

`}

`

1161

1162

``

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();

`

1165

1165

`self.link_arg(&format!("/SUBSYSTEM:{subsystem}"));

`

1166

1166

``

1167

1167

`// Windows has two subsystems we're interested in right now, the console

`

`@@ -1307,7 +1307,7 @@ impl<'a> Linker for EmLinker<'a> {

`

1307

1307

`self.cc_arg(arg);

`

1308

1308

`}

`

1309

1309

``

1310

``

`-

fn subsystem(&mut self, _subsystem: &str) {

`

``

1310

`+

fn windows_subsystem(&mut self, _subsystem: WindowsSubsystemKind) {

`

1311

1311

`// noop

`

1312

1312

`}

`

1313

1313

``

`@@ -1444,7 +1444,7 @@ impl<'a> Linker for WasmLd<'a> {

`

1444

1444

`}

`

1445

1445

`}

`

1446

1446

``

1447

``

`-

fn subsystem(&mut self, _subsystem: &str) {}

`

``

1447

`+

fn windows_subsystem(&mut self, _subsystem: WindowsSubsystemKind) {}

`

1448

1448

``

1449

1449

`fn linker_plugin_lto(&mut self) {

`

1450

1450

`match self.sess.opts.cg.linker_plugin_lto {

`

`@@ -1566,7 +1566,8 @@ impl<'a> Linker for L4Bender<'a> {

`

1566

1566

`self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented);

`

1567

1567

`}

`

1568

1568

``

1569

``

`-

fn subsystem(&mut self, subsystem: &str) {

`

``

1569

`+

fn windows_subsystem(&mut self, subsystem: WindowsSubsystemKind) {

`

``

1570

`+

let subsystem = subsystem.as_str();

`

1570

1571

`self.link_arg(&format!("--subsystem {subsystem}"));

`

1571

1572

`}

`

1572

1573

``

`@@ -1735,7 +1736,7 @@ impl<'a> Linker for AixLinker<'a> {

`

1735

1736

`self.link_arg(format!("-bE:{}", path.to_str().unwrap()));

`

1736

1737

`}

`

1737

1738

``

1738

``

`-

fn subsystem(&mut self, _subsystem: &str) {}

`

``

1739

`+

fn windows_subsystem(&mut self, _subsystem: WindowsSubsystemKind) {}

`

1739

1740

``

1740

1741

`fn reset_per_library_state(&mut self) {

`

1741

1742

`self.hint_dynamic();

`

`@@ -1969,7 +1970,7 @@ impl<'a> Linker for PtxLinker<'a> {

`

1969

1970

`) {

`

1970

1971

`}

`

1971

1972

``

1972

``

`-

fn subsystem(&mut self, _subsystem: &str) {}

`

``

1973

`+

fn windows_subsystem(&mut self, _subsystem: WindowsSubsystemKind) {}

`

1973

1974

``

1974

1975

`fn linker_plugin_lto(&mut self) {}

`

1975

1976

`}

`

`@@ -2050,7 +2051,7 @@ impl<'a> Linker for LlbcLinker<'a> {

`

2050

2051

`}

`

2051

2052

`}

`

2052

2053

``

2053

``

`-

fn subsystem(&mut self, _subsystem: &str) {}

`

``

2054

`+

fn windows_subsystem(&mut self, _subsystem: WindowsSubsystemKind) {}

`

2054

2055

``

2055

2056

`fn linker_plugin_lto(&mut self) {}

`

2056

2057

`}

`

`@@ -2134,7 +2135,7 @@ impl<'a> Linker for BpfLinker<'a> {

`

2134

2135

`}

`

2135

2136

`}

`

2136

2137

``

2137

``

`-

fn subsystem(&mut self, _subsystem: &str) {}

`

``

2138

`+

fn windows_subsystem(&mut self, _subsystem: WindowsSubsystemKind) {}

`

2138

2139

``

2139

2140

`fn linker_plugin_lto(&mut self) {}

`

2140

2141

`}

`