diff --git a/.github/workflows/libloading.yml b/.github/workflows/libloading.yml index 0f63b7c6d..7cf5b3105 100644 --- a/.github/workflows/libloading.yml +++ b/.github/workflows/libloading.yml @@ -65,6 +65,26 @@ jobs: env: TARGET: ${{ matrix.rust_target}} + msys2-test: + runs-on: windows-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: rustup install nightly --profile=minimal + - run: rustup default nightly + - run: rustup component add rust-src + - uses: msys2/setup-msys2@v2 + with: + release: false + install: gcc + - run: echo "INPUT(libmsys-2.0.a)" | Out-File -FilePath "C:\msys64\usr\lib\libcygwin.a" + - run: | + $env:PATH = "C:\msys64\usr\bin\;$env:PATH" + cargo test --target x86_64-pc-cygwin -Zbuild-std + env: + CARGO_TARGET_X86_64_PC_CYGWIN_LINKER: x86_64-pc-msys-gcc.exe + bare-cross-build: runs-on: ubuntu-latest strategy: diff --git a/Cargo.toml b/Cargo.toml index 5192896cb..75e146265 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,4 +34,7 @@ all-features = true rustdoc-args = ["--cfg", "libloading_docs"] [lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(libloading_docs)'] } +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(libloading_docs)', + 'cfg(target_os, values("cygwin"))', +] } diff --git a/src/os/unix/consts.rs b/src/os/unix/consts.rs index 4f069e212..4ae00592d 100644 --- a/src/os/unix/consts.rs +++ b/src/os/unix/consts.rs @@ -88,6 +88,7 @@ mod posix { target_os = "redox", target_os = "nto", target_os = "hurd", + target_os = "cygwin", ))] { pub(super) const RTLD_LAZY: c_int = 1; } else { @@ -127,6 +128,7 @@ mod posix { target_os = "redox", target_os = "nto", target_os = "hurd", + target_os = "cygwin", ))] { pub(super) const RTLD_NOW: c_int = 2; } else if #[cfg(all(target_os = "android",target_pointer_width = "32"))] { @@ -150,6 +152,7 @@ mod posix { target_env = "uclibc", all(target_os = "linux", target_arch = "mips"), all(target_os = "linux", target_arch = "mips64"), + target_os = "cygwin", ))] { pub(super) const RTLD_GLOBAL: c_int = 4; } else if #[cfg(any( @@ -224,6 +227,7 @@ mod posix { target_os = "fuchsia", target_os = "redox", target_os = "hurd", + target_os = "cygwin", ))] { pub(super) const RTLD_LOCAL: c_int = 0; } else { diff --git a/src/os/unix/mod.rs b/src/os/unix/mod.rs index a575d9aba..0e42c50d9 100644 --- a/src/os/unix/mod.rs +++ b/src/os/unix/mod.rs @@ -278,7 +278,8 @@ impl Library { target_os = "solaris", target_os = "illumos", target_os = "redox", - target_os = "fuchsia" + target_os = "fuchsia", + target_os = "cygwin", ))] { self.get_singlethreaded(symbol) } else { diff --git a/tests/functions.rs b/tests/functions.rs index b9c9ac315..c94592e7a 100644 --- a/tests/functions.rs +++ b/tests/functions.rs @@ -191,6 +191,8 @@ fn test_static_ptr() { // the target. Especially since it is very unlikely to be fixed given the state of support its // support. #[cfg(not(all(target_arch = "x86", target_os = "windows", target_env = "gnu")))] +// Cygwin returns errors on `close`. +#[cfg(not(target_os = "cygwin"))] fn manual_close_many_times() { make_helpers(); let join_handles: Vec<_> = (0..16) @@ -224,6 +226,8 @@ fn library_this_get() { .get::(b"test_identity_u32") .is_err()); // Something obscure from libc... + // Cygwin behaves like Windows so ignore it. + #[cfg(not(target_os = "cygwin"))] assert!(this.get::(b"freopen").is_ok()); } } diff --git a/tests/library_filename.rs b/tests/library_filename.rs index efe51b865..4642ece08 100644 --- a/tests/library_filename.rs +++ b/tests/library_filename.rs @@ -2,7 +2,7 @@ extern crate libloading; use libloading::library_filename; use std::path::Path; -#[cfg(target_os = "windows")] +#[cfg(any(target_os = "windows", target_os = "cygwin"))] const EXPECTED: &str = "audioengine.dll"; #[cfg(target_os = "linux")] const EXPECTED: &str = "libaudioengine.so";