From 8523770b80ea1f78afcac21d837f9dfd50f0bed6 Mon Sep 17 00:00:00 2001 From: Felipe Gasper Date: Wed, 1 Jun 2022 05:53:58 -0400 Subject: [PATCH] Fix Cygwin compatibility (#330) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make simple WASI work in Cygwin. Issue #329 * Prevent M3_WEAK from taking effect on Cygwin. Issue #329 * Add CI to ensure that Cygwin doesn’t regress. Issue #329 --- .github/workflows/tests.yml | 13 +++++++++++++ source/m3_api_wasi.c | 2 +- source/m3_config_platforms.h | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 70d2e8f..2935b1d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -154,6 +154,19 @@ jobs: cd test python run-wasi-test.py + cygwin-build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@main + - name: Set up Cygwin + uses: egor-tensin/setup-cygwin@master + with: + platform: x64 + packages: make gcc-g++ cmake + - run: cd $GITHUB_WORKSPACE && cmake -DBUILD_WASI=simple . && make + shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}' + wasi: runs-on: ubuntu-latest timeout-minutes: 10 diff --git a/source/m3_api_wasi.c b/source/m3_api_wasi.c index 836d6f4..52714ec 100644 --- a/source/m3_api_wasi.c +++ b/source/m3_api_wasi.c @@ -33,7 +33,7 @@ #if defined(APE) // Actually Portable Executable // All functions are already included in cosmopolitan.h -#elif defined(__wasi__) || defined(__APPLE__) || defined(__ANDROID_API__) || defined(__OpenBSD__) || defined(__linux__) || defined(__EMSCRIPTEN__) +#elif defined(__wasi__) || defined(__APPLE__) || defined(__ANDROID_API__) || defined(__OpenBSD__) || defined(__linux__) || defined(__EMSCRIPTEN__) || defined(__CYGWIN__) # include # include # if defined(__APPLE__) diff --git a/source/m3_config_platforms.h b/source/m3_config_platforms.h index ecb5b74..0cb475d 100644 --- a/source/m3_config_platforms.h +++ b/source/m3_config_platforms.h @@ -67,7 +67,7 @@ # define M3_WEAK //__declspec(selectany) # define M3_NO_UBSAN # define M3_NOINLINE -# elif defined(__MINGW32__) +# elif defined(__MINGW32__) || defined(__CYGWIN__) # define M3_WEAK //__attribute__((selectany)) # define M3_NO_UBSAN # define M3_NOINLINE __attribute__((noinline))