Add cygwin target.
Co-authored-by: Ookiineko <chiisaineko@protonmail.com> Co-authored-by: nora <48135649+Noratrieb@users.noreply.github.com> Co-authored-by: Jubilee <workingjubilee@gmail.com>
This commit is contained in:
parent
c03c38d5c2
commit
f94ada13de
10 changed files with 138 additions and 5 deletions
51
compiler/rustc_target/src/spec/base/cygwin.rs
Normal file
51
compiler/rustc_target/src/spec/base/cygwin.rs
Normal file
|
@ -0,0 +1,51 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use crate::spec::{Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions, cvs};
|
||||
|
||||
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",
|
||||
"--enable-auto-image-base",
|
||||
]);
|
||||
crate::spec::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[
|
||||
// Tell GCC to avoid linker plugins, because we are not bundling
|
||||
// them with Windows installer, and Rust does its own LTO anyways.
|
||||
"-fno-use-linker-plugin",
|
||||
"-Wl,--disable-dynamicbase",
|
||||
"-Wl,--enable-auto-image-base",
|
||||
]);
|
||||
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(
|
||||
&mut late_link_args,
|
||||
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
|
||||
cygwin_libs,
|
||||
);
|
||||
TargetOptions {
|
||||
os: "cygwin".into(),
|
||||
vendor: "pc".into(),
|
||||
// FIXME(#13846) this should be enabled for cygwin
|
||||
function_sections: false,
|
||||
linker: Some("gcc".into()),
|
||||
dynamic_linking: true,
|
||||
dll_prefix: "".into(),
|
||||
dll_suffix: ".dll".into(),
|
||||
exe_suffix: ".exe".into(),
|
||||
families: cvs!["unix"],
|
||||
is_like_windows: true,
|
||||
allows_weak_linkage: false,
|
||||
pre_link_args,
|
||||
late_link_args,
|
||||
abi_return_struct_as_int: true,
|
||||
emit_debug_gdb_scripts: false,
|
||||
requires_uwtable: true,
|
||||
eh_frame_header: false,
|
||||
// FIXME(davidtwco): Support Split DWARF on Cygwin - may require LLVM changes to
|
||||
// output DWO, despite using DWARF, doesn't use ELF..
|
||||
debuginfo_kind: DebuginfoKind::Pdb,
|
||||
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ pub(crate) mod android;
|
|||
pub(crate) mod apple;
|
||||
pub(crate) mod avr_gnu;
|
||||
pub(crate) mod bpf;
|
||||
pub(crate) mod cygwin;
|
||||
pub(crate) mod dragonfly;
|
||||
pub(crate) mod freebsd;
|
||||
pub(crate) mod fuchsia;
|
||||
|
|
|
@ -2020,6 +2020,7 @@ supported_targets! {
|
|||
("riscv64imac-unknown-nuttx-elf", riscv64imac_unknown_nuttx_elf),
|
||||
("riscv64gc-unknown-nuttx-elf", riscv64gc_unknown_nuttx_elf),
|
||||
|
||||
("x86_64-pc-cygwin", x86_64_pc_cygwin),
|
||||
}
|
||||
|
||||
/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
|
||||
|
@ -3001,8 +3002,8 @@ impl Target {
|
|||
);
|
||||
check_eq!(
|
||||
self.is_like_windows,
|
||||
self.os == "windows" || self.os == "uefi",
|
||||
"`is_like_windows` must be set if and only if `os` is `windows` or `uefi`"
|
||||
self.os == "windows" || self.os == "uefi" || self.os == "cygwin",
|
||||
"`is_like_windows` must be set if and only if `os` is `windows`, `uefi` or `cygwin`"
|
||||
);
|
||||
check_eq!(
|
||||
self.is_like_wasm,
|
||||
|
|
32
compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs
Normal file
32
compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs
Normal file
|
@ -0,0 +1,32 @@
|
|||
use crate::spec::{Cc, LinkerFlavor, Lld, Target, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
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),
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue