Skip to content

Commit 27ee9ca

Browse files
BerrysoftOokiineko
authored andcommitted
Add cygwin support
Co-authored-by: Ookiineko <chiisaineko@protonmail.com>
1 parent 4690673 commit 27ee9ca

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

build.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ mod c {
575575
("__fe_raise_inexact", "fp_mode.c"),
576576
]);
577577

578-
if target.os != "windows" {
578+
if target.os != "windows" && target.os != "cygwin" {
579579
sources.extend(&[("__multc3", "multc3.c")]);
580580
}
581581
}
@@ -608,13 +608,15 @@ mod c {
608608
sources.remove(&["__aeabi_cdcmp", "__aeabi_cfcmp"]);
609609
}
610610

611-
// Android uses emulated TLS so we need a runtime support function.
612-
if target.os == "android" {
611+
// Android and Cygwin uses emulated TLS so we need a runtime support function.
612+
if target.os == "android" || target.os == "cygwin" {
613613
sources.extend(&[("__emutls_get_address", "emutls.c")]);
614+
}
614615

615-
// Work around a bug in the NDK headers (fixed in
616-
// https://r.android.com/2038949 which will be released in a future
617-
// NDK version) by providing a definition of LONG_BIT.
616+
// Work around a bug in the NDK headers (fixed in
617+
// https://r.android.com/2038949 which will be released in a future
618+
// NDK version) by providing a definition of LONG_BIT.
619+
if target.os == "android" {
618620
cfg.define("LONG_BIT", "(8 * sizeof(long))");
619621
}
620622

examples/intrinsics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -673,17 +673,17 @@ pub fn __aeabi_unwind_cpp_pr0() {}
673673
#[no_mangle]
674674
pub fn __aeabi_unwind_cpp_pr1() {}
675675

676-
#[cfg(not(windows))]
676+
#[cfg(not(any(windows, target_os = "cygwin")))]
677677
#[allow(non_snake_case)]
678678
#[no_mangle]
679679
pub fn _Unwind_Resume() {}
680680

681-
#[cfg(not(windows))]
681+
#[cfg(not(any(windows, target_os = "cygwin")))]
682682
#[lang = "eh_personality"]
683683
#[no_mangle]
684684
pub extern "C" fn eh_personality() {}
685685

686-
#[cfg(all(windows, target_env = "gnu"))]
686+
#[cfg(any(all(windows, target_env = "gnu"), target_os = "cygwin"))]
687687
mod mingw_unwinding {
688688
#[no_mangle]
689689
pub fn rust_eh_personality() {}

src/macros.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ macro_rules! intrinsics {
193193

194194
$($rest:tt)*
195195
) => (
196-
#[cfg(all(any(windows, all(target_os = "uefi", target_arch = "x86_64")), target_pointer_width = "64"))]
196+
#[cfg(all(any(windows, target_os = "cygwin", all(target_os = "uefi", target_arch = "x86_64")), target_pointer_width = "64"))]
197197
intrinsics! {
198198
$(#[$($attr)*])*
199199
pub extern "unadjusted" fn $name( $($argname: $ty),* ) $(-> $ret)? {
200200
$($body)*
201201
}
202202
}
203203

204-
#[cfg(not(all(any(windows, all(target_os = "uefi", target_arch = "x86_64")), target_pointer_width = "64")))]
204+
#[cfg(not(all(any(windows, target_os = "cygwin", all(target_os = "uefi", target_arch = "x86_64")), target_pointer_width = "64")))]
205205
intrinsics! {
206206
$(#[$($attr)*])*
207207
pub extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
@@ -257,7 +257,7 @@ macro_rules! intrinsics {
257257
#[cfg(all(target_vendor = "apple", any(target_arch = "x86", target_arch = "x86_64"), not(feature = "mangled-names")))]
258258
mod $name {
259259
#[no_mangle]
260-
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
260+
#[cfg_attr(not(any(all(windows, target_env = "gnu"), target_os = "cygwin")), linkage = "weak")]
261261
$(#[$($attr)*])*
262262
extern $abi fn $name( $($argname: u16),* ) $(-> $ret)? {
263263
super::$name($(f16::from_bits($argname)),*)
@@ -293,7 +293,7 @@ macro_rules! intrinsics {
293293
#[cfg(all(target_vendor = "apple", any(target_arch = "x86", target_arch = "x86_64"), not(feature = "mangled-names")))]
294294
mod $name {
295295
#[no_mangle]
296-
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
296+
#[cfg_attr(not(any(all(windows, target_env = "gnu"), target_os = "cygwin")), linkage = "weak")]
297297
$(#[$($attr)*])*
298298
extern $abi fn $name( $($argname: $ty),* ) -> u16 {
299299
super::$name($($argname),*).to_bits()
@@ -334,7 +334,7 @@ macro_rules! intrinsics {
334334
#[cfg(all(target_arch = "arm", not(feature = "mangled-names")))]
335335
mod $name {
336336
#[no_mangle]
337-
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
337+
#[cfg_attr(not(any(all(windows, target_env = "gnu"), target_os = "cygwin")), linkage = "weak")]
338338
$(#[$($attr)*])*
339339
extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
340340
super::$name($($argname),*)
@@ -344,7 +344,7 @@ macro_rules! intrinsics {
344344
#[cfg(all(target_arch = "arm", not(feature = "mangled-names")))]
345345
mod $alias {
346346
#[no_mangle]
347-
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
347+
#[cfg_attr(not(any(all(windows, target_env = "gnu"), target_os = "cygwin")), linkage = "weak")]
348348
$(#[$($attr)*])*
349349
extern "aapcs" fn $alias( $($argname: $ty),* ) $(-> $ret)? {
350350
super::$name($($argname),*)
@@ -411,7 +411,7 @@ macro_rules! intrinsics {
411411
mod $name {
412412
$(#[$($attr)*])*
413413
#[no_mangle]
414-
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
414+
#[cfg_attr(not(any(all(windows, target_env = "gnu"), target_os = "cygwin")), linkage = "weak")]
415415
unsafe extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
416416
super::$name($($argname),*)
417417
}
@@ -436,7 +436,7 @@ macro_rules! intrinsics {
436436
#[naked]
437437
$(#[$($attr)*])*
438438
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
439-
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
439+
#[cfg_attr(not(any(all(windows, target_env = "gnu"), target_os = "cygwin")), linkage = "weak")]
440440
pub unsafe extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
441441
$($body)*
442442
}
@@ -503,7 +503,7 @@ macro_rules! intrinsics {
503503
mod $name {
504504
$(#[$($attr)*])*
505505
#[no_mangle]
506-
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
506+
#[cfg_attr(not(any(all(windows, target_env = "gnu"), target_os = "cygwin")), linkage = "weak")]
507507
$(unsafe $($empty)?)? extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
508508
super::$name($($argname),*)
509509
}

src/probestack.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
//! be more than welcome to accept such a change!
4343
4444
#![cfg(not(feature = "mangled-names"))]
45-
// Windows already has builtins to do this.
46-
#![cfg(not(windows))]
45+
// Windows and Cygwin already has builtins to do this.
46+
#![cfg(not(any(windows, target_os = "cygwin")))]
4747
// All these builtins require assembly
4848
#![cfg(not(feature = "no-asm"))]
4949
// We only define stack probing for these architectures today.

src/x86_64.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ use core::intrinsics;
1010
intrinsics! {
1111
#[naked]
1212
#[cfg(all(
13-
any(all(windows, target_env = "gnu"), target_os = "uefi"),
13+
any(
14+
all(windows, target_env = "gnu"),
15+
target_os = "cygwin",
16+
target_os = "uefi"
17+
),
1418
not(feature = "no-asm")
1519
))]
1620
pub unsafe extern "C" fn ___chkstk_ms() {

0 commit comments

Comments
 (0)