diff --git a/compiler/rustc_target/src/spec/base/cygwin.rs b/compiler/rustc_target/src/spec/base/cygwin.rs index ec47f07833eb..2d29060c47a3 100644 --- a/compiler/rustc_target/src/spec/base/cygwin.rs +++ b/compiler/rustc_target/src/spec/base/cygwin.rs @@ -1,16 +1,8 @@ use std::borrow::Cow; -use crate::spec::{ - Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, Target, TargetOptions, cvs, -}; +use crate::spec::{Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions, cvs}; -#[derive(Clone, Copy)] -pub(crate) enum CygwinVariant { - Cygwin, - MSYS2, -} - -fn opts(env: CygwinVariant) -> TargetOptions { +pub(crate) fn opts() -> TargetOptions { let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[ // FIXME: Disable ASLR for now to fix relocation error "--disable-dynamicbase", @@ -23,12 +15,7 @@ fn opts(env: CygwinVariant) -> TargetOptions { "-Wl,--disable-dynamicbase", "-Wl,--enable-auto-image-base", ]); - // cygwin runtime lib - let clib = match env { - CygwinVariant::Cygwin => "-lcygwin", - CygwinVariant::MSYS2 => "-lmsys-2.0", - }; - let cygwin_libs = &[clib, "-lgcc", clib, "-luser32", "-lkernel32", "-lgcc_s"]; + let cygwin_libs = &["-lcygwin", "-lgcc", "-lcygwin", "-luser32", "-lkernel32", "-lgcc_s"]; let mut late_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), cygwin_libs); crate::spec::add_link_args( @@ -36,14 +23,9 @@ fn opts(env: CygwinVariant) -> TargetOptions { LinkerFlavor::Gnu(Cc::Yes, Lld::No), cygwin_libs, ); - let target_env = match env { - CygwinVariant::Cygwin => "", - CygwinVariant::MSYS2 => "msys2", - }; TargetOptions { os: "cygwin".into(), vendor: "pc".into(), - env: target_env.into(), // FIXME(#13846) this should be enabled for cygwin function_sections: false, linker: Some("gcc".into()), @@ -67,42 +49,3 @@ fn opts(env: CygwinVariant) -> TargetOptions { ..Default::default() } } - -pub(crate) fn x86_64_target(env: CygwinVariant) -> Target { - let mut base = opts(env); - base.cpu = "x86-64".into(); - // FIXME: Disable ASLR for now to fix relocation error - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[ - "-m", - "i386pep", - "--disable-high-entropy-va", - ]); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[ - "-m64", - "-Wl,--disable-high-entropy-va", - ]); - base.max_atomic_width = Some(64); - let linker = match env { - CygwinVariant::Cygwin => "x86_64-pc-cygwin-gcc", - CygwinVariant::MSYS2 => "x86_64-pc-msys-gcc", - }; - let description = match env { - CygwinVariant::Cygwin => "64-bit x86 Cygwin", - CygwinVariant::MSYS2 => "64-bit x86 MSYS2", - }; - base.linker = Some(linker.into()); - Target { - llvm_target: "x86_64-pc-cygwin".into(), - pointer_width: 64, - data_layout: - "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), - options: base, - metadata: crate::spec::TargetMetadata { - description: Some(description.into()), - tier: Some(3), - host_tools: Some(false), - std: Some(true), - }, - } -} diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index b41beb724efe..5d81859a2bcd 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1979,7 +1979,6 @@ supported_targets! { ("riscv64gc-unknown-nuttx-elf", riscv64gc_unknown_nuttx_elf), ("x86_64-pc-cygwin", x86_64_pc_cygwin), - ("x86_64-pc-cygwin-msys2", x86_64_pc_cygwin_msys2), } /// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]> diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs index 262b4d53b739..a5bedd07e6be 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs @@ -1,5 +1,32 @@ -use crate::spec::{Target, base}; +use crate::spec::{Cc, LinkerFlavor, Lld, Target, base}; pub(crate) fn target() -> Target { - base::cygwin::x86_64_target(base::cygwin::CygwinVariant::Cygwin) + let mut base = base::cygwin::opts(); + base.cpu = "x86-64".into(); + // FIXME: Disable ASLR for now to fix relocation error + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[ + "-m", + "i386pep", + "--disable-high-entropy-va", + ]); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[ + "-m64", + "-Wl,--disable-high-entropy-va", + ]); + base.max_atomic_width = Some(64); + base.linker = Some("x86_64-pc-cygwin-gcc".into()); + Target { + llvm_target: "x86_64-pc-cygwin".into(), + pointer_width: 64, + data_layout: + "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), + arch: "x86_64".into(), + options: base, + metadata: crate::spec::TargetMetadata { + description: Some("64-bit x86 Cygwin".into()), + tier: Some(3), + host_tools: Some(false), + std: Some(true), + }, + } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin_msys2.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin_msys2.rs deleted file mode 100644 index 5ae972734a44..000000000000 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin_msys2.rs +++ /dev/null @@ -1,5 +0,0 @@ -use crate::spec::{Target, base}; - -pub(crate) fn target() -> Target { - base::cygwin::x86_64_target(base::cygwin::CygwinVariant::MSYS2) -} diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 8e93a4e40daf..07646354dcae 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -98,7 +98,6 @@ - [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md) - [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md) - [x86_64-pc-cygwin](platform-support/x86_64-pc-cygwin.md) - - [x86_64-pc-cygwin-msys2](platform-support/x86_64-pc-cygwin.md) - [x86_64-pc-solaris](platform-support/solaris.md) - [x86_64-unknown-linux-none.md](platform-support/x86_64-unknown-linux-none.md) - [x86_64-unknown-none](platform-support/x86_64-unknown-none.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index fb6bb166b59b..ab44a582b2af 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -396,7 +396,6 @@ target | std | host | notes [`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ✓ | | x86 64-bit tvOS [`x86_64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | x86 64-bit Apple WatchOS simulator [`x86_64-pc-cygwin`](platform-support/x86_64-pc-cygwin.md) | ? | | 64-bit x86 Cygwin | -[`x86_64-pc-cygwin-msys2`](platform-support/x86_64-pc-cygwin.md) | ? | | 64-bit x86 MSYS2 | [`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS | [`x86_64-unikraft-linux-musl`](platform-support/unikraft-linux-musl.md) | ✓ | | 64-bit Unikraft with musl 1.2.3 `x86_64-unknown-dragonfly` | ✓ | ✓ | 64-bit DragonFlyBSD diff --git a/src/doc/rustc/src/platform-support/x86_64-pc-cygwin.md b/src/doc/rustc/src/platform-support/x86_64-pc-cygwin.md index 7b94efc25bea..a8fc4f181d8a 100644 --- a/src/doc/rustc/src/platform-support/x86_64-pc-cygwin.md +++ b/src/doc/rustc/src/platform-support/x86_64-pc-cygwin.md @@ -2,8 +2,8 @@ **Tier: 3** -Windows targets supporting Cygwin and MSYS2. -The `*-cygwin-*` targets are **not** intended as native targets for applications, +Windows targets supporting Cygwin. +The `*-cygwin` targets are **not** intended as native target for applications, a developer writing Windows applications should use the `*-pc-windows-*` targets instead, which are *native* Windows. Cygwin is only intended as an emulation layer for Unix-only programs which do not support the native Windows targets. @@ -14,19 +14,14 @@ Cygwin is only intended as an emulation layer for Unix-only programs which do no ## Requirements -This target is cross compiled. Different `target_env` needs different linker: -- `x86_64-pc-cygwin`: `x86_64-pc-cygwin-gcc` -- `x86_64-pc-cygwin-msys2`: `x86_64-pc-msys-gcc` +This target is cross compiled. It needs `x86_64-pc-cygwin-gcc` as linker. -The difference between two targets are small. -The `target_os` of these targets are `cygwin`, and they are `unix`. - -To gain high performance, users are recommended to use *more* native targets, e.g., `x86_64-pc-windows-*`. +The `target_os` of the target is `cygwin`, and it is `unix`. ## Building the target -For cross-compilation you want LLVM with [llvm/llvm-project#121439](https://github.com/llvm/llvm-project/pull/121439) applied to fix the LLVM codegen on importing external global variables from DLLs. -No native builds on Cygwin or MSYS2 now. It should be possible theoretically though, but might need a lot of patches. +For cross-compilation you want LLVM with [llvm/llvm-project#121439 (merged)](https://github.com/llvm/llvm-project/pull/121439) applied to fix the LLVM codegen on importing external global variables from DLLs. +No native builds on Cygwin now. It should be possible theoretically though, but might need a lot of patches. ## Building Rust programs @@ -37,8 +32,8 @@ this target, you will either need to build Rust with the target enabled (see ## Testing -Created binaries work fine on Windows with Cygwin or MSYS2. +Created binaries work fine on Windows with Cygwin. ## Cross-compilation toolchains and C code -Compatible C code can be built with GCC shipped with Cygwin or MSYS2. Clang is untested. +Compatible C code can be built with GCC shipped with Cygwin. Clang is untested. diff --git a/tests/assembly/targets/targets-pe.rs b/tests/assembly/targets/targets-pe.rs index bfc5f6f3ea9a..38159063a04d 100644 --- a/tests/assembly/targets/targets-pe.rs +++ b/tests/assembly/targets/targets-pe.rs @@ -81,9 +81,6 @@ //@ revisions: x86_64_pc_cygwin //@ [x86_64_pc_cygwin] compile-flags: --target x86_64-pc-cygwin //@ [x86_64_pc_cygwin] needs-llvm-components: x86 -//@ revisions: x86_64_pc_cygwin_msys2 -//@ [x86_64_pc_cygwin_msys2] compile-flags: --target x86_64-pc-cygwin-msys2 -//@ [x86_64_pc_cygwin_msys2] needs-llvm-components: x86 // Sanity-check that each target can produce assembly code. diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index d1a92ff19c72..3b9ac0772ad9 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -156,7 +156,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_env` are: ``, `gnu`, `msvc`, `msys2`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, and `uclibc` + = note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, and `uclibc` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`