Skip to content

Commit 517afdb

Browse files
committed
Fix Cygwin toolchain build to be compatible with upstream workflow
1 parent e8aad8c commit 517afdb

File tree

8 files changed

+31
-15
lines changed

8 files changed

+31
-15
lines changed

.github/scripts/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fi
5151

5252
$ROOT_PATH/.github/scripts/toolchain/build-gcc.sh
5353

54-
if [[ "$PLATFORM" =~ (mingw|cygwin) ]]; then
54+
if [[ "$PLATFORM" =~ mingw ]]; then
5555
$ROOT_PATH/.github/scripts/toolchain/build-mingw.sh
5656
fi
5757
if [[ "$PLATFORM" =~ cygwin ]]; then

.github/scripts/config.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MINGW_REPO=${MINGW_REPO:-Windows-on-ARM-Experiments/mingw-woarm64}
1515
MINGW_BRANCH=${MINGW_BRANCH:-woarm64}
1616

1717
CYGWIN_REPO=${CYGWIN_REPO:-Windows-on-ARM-Experiments/newlib-cygwin}
18-
CYGWIN_BRANCH=${CYGWIN_BRANCH:-woarm64}
18+
CYGWIN_BRANCH=${CYGWIN_BRANCH:-upstream-workflow}
1919

2020
CYGWIN_PACKAGES_REPO=${CYGWIN_PACKAGES_REPO:-Windows-on-ARM-Experiments/cygwin-packages}
2121
CYGWIN_PACKAGES_BRANCH=${CYGWIN_PACKAGES_BRANCH:-main}
@@ -128,3 +128,9 @@ if [[ "$CCACHE" = 1 ]]; then
128128
PATH=$CCACHE_LIB_DIR:$TOOLCHAIN_CCACHE_LIB_DIR:$PATH
129129
export CCACHE_DIR=$CCACHE_DIR_PATH
130130
fi
131+
132+
# Cygwin toolchain is using only Win32 API headers from MinGW. Upstream Cygwin
133+
# is being built with 12.0.0 tag.
134+
if [[ "$PLATFORM" =~ cygwin ]]; then
135+
MINGW_BRANCH=v12.0.0
136+
fi

.github/scripts/toolchain/build-cygwin.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$CYGWIN_BUILD_PATH/Makefile" ]]; then
3131

3232
# ADDED: --disable-doc
3333
# ADDED: --disable-dumper
34-
CXXFLAGS_FOR_TARGET="-Wno-error -Wno-narrowing" \
34+
# -D_WIN64 is a workaround for missing https://github.com/Windows-on-ARM-Experiments/mingw-woarm64/blob/woarm64/mingw-w64-headers/crt/_cygwin.h#L32
35+
# in v12.0.0 branch of MinGW.
36+
CXXFLAGS_FOR_TARGET="$CXXFLAGS_FOR_TARGET -D_WIN64 -Wno-error -Wno-narrowing" \
3537
$CYGWIN_SOURCE_PATH/configure \
3638
--prefix=$TOOLCHAIN_PATH \
3739
--build=$HOST \

.github/scripts/toolchain/build-gcc-stage1.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$GCC_BUILD_PATH/Makefile" ]]; then
4242
--enable-threads=posix \
4343
--with-dwarf2 \
4444
--with-system-zlib"
45+
# Workaround for missing https://github.com/Windows-on-ARM-Experiments/mingw-woarm64/blob/woarm64/mingw-w64-headers/crt/_cygwin.h#L32
46+
# in v12.0.0 branch of MinGW.
47+
CFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET -D_WIN64"
4548
;;
4649
*mingw*)
4750
TARGET_OPTIONS="$TARGET_OPTIONS \
@@ -76,7 +79,8 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$GCC_BUILD_PATH/Makefile" ]]; then
7679
--with-gnu-ld \
7780
--without-headers \
7881
$HOST_OPTIONS \
79-
$TARGET_OPTIONS
82+
$TARGET_OPTIONS \
83+
CFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET"
8084
echo "::endgroup::"
8185
fi
8286

.github/scripts/toolchain/build-gcc.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$GCC_BUILD_PATH/Makefile" ]]; then
5959
--with-default-libstdcxx-abi=gcc4-compatible \
6060
--without-libiconv-prefix \
6161
--without-libintl-prefix"
62+
# Workaround for missing https://github.com/Windows-on-ARM-Experiments/mingw-woarm64/blob/woarm64/mingw-w64-headers/crt/_cygwin.h#L32
63+
# in v12.0.0 branch of MinGW.
64+
CFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET -D_WIN64"
6265
;;
6366
*mingw*)
6467
TARGET_OPTIONS="$TARGET_OPTIONS \
@@ -115,7 +118,8 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$GCC_BUILD_PATH/Makefile" ]]; then
115118
--with-gnu-as \
116119
--with-gnu-ld \
117120
$HOST_OPTIONS \
118-
$TARGET_OPTIONS
121+
$TARGET_OPTIONS \
122+
CFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET"
119123
echo "::endgroup::"
120124
fi
121125

.github/scripts/toolchain/build-mingw-crt.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$MINGW_BUILD_PATH/Makefile" ]]; then
3737
*cygwin*)
3838
TARGET_OPTIONS="$TARGET_OPTIONS \
3939
--enable-w32api"
40+
# Workaround for missing https://github.com/Windows-on-ARM-Experiments/mingw-woarm64/blob/woarm64/mingw-w64-headers/crt/_cygwin.h#L32
41+
# in v12.0.0 branch of MinGW.
42+
CFLAGS="$CFLAGS -D_WIN64"
4043
;;
4144
*mingw*)
4245
TARGET_OPTIONS="$TARGET_OPTIONS \

.github/scripts/toolchain/build-mingw-headers.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,15 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$MINGW_HEADERS_BUILD_PATH/Makefile" ]]; t
2121
TARGET_OPTIONS="$TARGET_OPTIONS \
2222
--enable-w32api"
2323
;;
24-
*mingw*)
25-
TARGET_OPTIONS="$TARGET_OPTIONS \
26-
--enable-sdk=all"
27-
;;
2824
esac
2925

30-
case "$CRT" in
31-
ucrt)
26+
case "$PLATFORM-$CRT" in
27+
*mingw*-ucrt)
3228
TARGET_OPTIONS="$TARGET_OPTIONS \
3329
--with-default-win32-winnt=0x603 \
3430
--with-default-msvcrt=ucrt"
3531
;;
36-
msvcrt)
32+
*mingw*-msvcrt)
3733
TARGET_OPTIONS="$TARGET_OPTIONS \
3834
--with-default-win32-winnt=0x601 \
3935
--with-default-msvcrt=msvcrt"
@@ -44,6 +40,7 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$MINGW_HEADERS_BUILD_PATH/Makefile" ]]; t
4440
--prefix=$TOOLCHAIN_PATH/$TARGET \
4541
--build=$BUILD \
4642
--host=$TARGET \
43+
--enable-sdk=all \
4744
$HOST_OPTIONS \
4845
$TARGET_OPTIONS
4946
echo "::endgroup::"

.github/workflows/advanced.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ env:
7878
MINGW_BRANCH: ${{ inputs.mingw_branch || 'woarm64' }}
7979

8080
CYGWIN_REPO: Windows-on-ARM-Experiments/newlib-cygwin
81-
CYGWIN_BRANCH: ${{ inputs.cygwin_branch || 'woarm64' }}
81+
CYGWIN_BRANCH: ${{ inputs.cygwin_branch || 'upstream-workflow' }}
8282

8383
CYGWIN_PACKAGES_REPO: Windows-on-ARM-Experiments/cygwin-packages
8484
CYGWIN_PACKAGES_BRANCH: ${{ inputs.cygwin_packages_branch || 'main' }}
@@ -212,7 +212,7 @@ jobs:
212212
uses: actions/checkout@v4
213213
with:
214214
repository: ${{ env.MINGW_REPO }}
215-
ref: ${{ env.MINGW_BRANCH }}
215+
ref: ${{ matrix.platform == 'pc-cygwin' && 'v12.0.0' || env.MINGW_BRANCH }}
216216
path: ${{ env.SOURCE_PATH }}/mingw
217217

218218
- name: Checkout Cygwin
@@ -320,7 +320,7 @@ jobs:
320320
.github/scripts/toolchain/build-gcc.sh
321321
322322
- name: Build MinGW
323-
if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform != 'pc-linux-gnu' }}
323+
if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform == 'w64-mingw32' }}
324324
run: |
325325
.github/scripts/toolchain/build-mingw.sh
326326

0 commit comments

Comments
 (0)