Skip to content

Commit 8b07e30

Browse files
committed
Changes needed to build Cygwin toolchain inside Cygwin shell
1 parent d4d4a72 commit 8b07e30

File tree

13 files changed

+814
-59
lines changed

13 files changed

+814
-59
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.sh text eol=lf
2+
apt-cyg text eol=lf

.github/scripts/build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ fi
4444
if [[ "$PLATFORM" =~ mingw ]]; then
4545
$ROOT_PATH/.github/scripts/toolchain/build-mingw-winpthreads.sh
4646
fi
47+
4748
if [[ "$PLATFORM" =~ cygwin ]]; then
48-
$ROOT_PATH/.github/scripts/toolchain/build-cocom.sh
49+
if [[ "$CYGWIN" = 0 ]]; then
50+
$ROOT_PATH/.github/scripts/toolchain/build-cocom.sh
51+
fi
4952
$ROOT_PATH/.github/scripts/toolchain/build-cygwin.sh 1
5053
fi
5154

.github/scripts/config.sh

Lines changed: 6 additions & 5 deletions
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:-native-cygwin}
1919

2020
CYGWIN_PACKAGES_REPO=${CYGWIN_PACKAGES_REPO:-Windows-on-ARM-Experiments/cygwin-packages}
2121
CYGWIN_PACKAGES_BRANCH=${CYGWIN_PACKAGES_BRANCH:-main}
@@ -32,17 +32,18 @@ CYGWIN_PACKAGES_BASE_BRANCH=main
3232
COCOM_BASE_BRANCH=master
3333

3434
ARCH=${ARCH:-aarch64}
35-
PLATFORM=${PLATFORM:-w64-mingw32}
35+
PLATFORM=${PLATFORM:-pc-cygwin}
3636
if [[ "$PLATFORM" =~ (mingw|cygwin) ]]; then
3737
CRT=${CRT:-msvcrt}
3838
else
3939
CRT=${CRT:-libc}
4040
fi
4141

42-
PROCESSOR=$(uname --processor)
43-
BUILD=${BUILD:-$PROCESSOR-pc-linux-gnu}
44-
HOST=${HOST:-$PROCESSOR-pc-linux-gnu}
42+
PROCESSOR=x86_64
43+
BUILD=${BUILD:-$PROCESSOR-pc-cygwin}
44+
HOST=${HOST:-$PROCESSOR-pc-cygwin}
4545
TARGET=$ARCH-$PLATFORM
46+
CYGWIN=`if uname | grep -qi cygwin; then echo 1; else echo 0; fi`
4647
TOOLCHAIN_NAME=${TOOLCHAIN_NAME:-$ARCH-$PLATFORM-$CRT}
4748

4849
if [[ ("$PLATFORM" =~ (mingw|cygwin) && ! ("$CRT" =~ (msvcrt|ucrt))) ||

.github/scripts/enable-ccache.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
source `dirname ${BASH_SOURCE[0]}`/config.sh
44

5+
mkdir -p $CCACHE_LIB_DIR
56
mkdir -p $TOOLCHAIN_CCACHE_LIB_DIR
67

78
echo "::group::Add $TARGET toolchain to ccache"

.github/scripts/install-dependencies.sh

Lines changed: 61 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,67 @@
33
source `dirname ${BASH_SOURCE[0]}`/config.sh
44

55
echo "::group::Install Dependencies"
6-
sudo apt update
7-
sudo apt install -y \
8-
autoconf \
9-
autogen \
10-
automake \
11-
autotools-dev \
12-
binutils-for-build \
13-
bison \
14-
build-essential \
15-
busybox \
16-
ccache \
17-
dejagnu \
18-
docbook2x \
19-
flex \
20-
gdc \
21-
jq \
22-
libc6-dev-arm64-cross \
23-
libc6-dev-amd64-cross \
24-
texinfo \
25-
xmlto \
26-
zlib1g-dev \
27-
zstd
6+
if [[ "$CYGWIN" = 1 ]]; then
7+
# wget needs to be already installed
8+
$ROOT_PATH/tools/apt-cyg update
9+
$ROOT_PATH/tools/apt-cyg install \
10+
autoconf \
11+
autogen \
12+
automake \
13+
binutils \
14+
bison \
15+
busybox \
16+
ccache \
17+
cygutils-extra \
18+
cygwin-devel \
19+
dejagnu \
20+
docbook2X \
21+
flex \
22+
gcc-core \
23+
gcc-g++ \
24+
gcc-gdc \
25+
jq \
26+
libgmp10 \
27+
libgmp-devel \
28+
libmpc3 \
29+
libmpc-devel \
30+
libzstd-devel \
31+
libisl23 \
32+
libisl-devel \
33+
make \
34+
mingw64-x86_64-gcc-core \
35+
mingw64-x86_64-gcc-g++ \
36+
mingw64-x86_64-zlib \
37+
patch \
38+
texinfo \
39+
w32api-runtime \
40+
xmlto \
41+
zlib-devel \
42+
zstd
43+
else
44+
sudo apt update
45+
sudo apt install -y \
46+
autoconf \
47+
autogen \
48+
automake \
49+
autotools-dev \
50+
binutils-for-build \
51+
bison \
52+
build-essential \
53+
busybox \
54+
ccache \
55+
dejagnu \
56+
docbook2x \
57+
flex \
58+
gdc \
59+
jq \
60+
libc6-dev-arm64-cross \
61+
libc6-dev-amd64-cross \
62+
texinfo \
63+
xmlto \
64+
zlib1g-dev \
65+
zstd
66+
fi
2867
echo "::endgroup::"
2968

3069
echo 'Success!'

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$CYGWIN_BUILD_PATH/Makefile" ]]; then
1313
echo "::group::Configure Cygwin"
1414
rm -rf $CYGWIN_BUILD_PATH/*
1515

16+
if [[ "$BUILD" != "$TARGET" ]] && [[ "$CYGWIN" = 0 ]]; then
17+
BUILD_OPTIONS="$BUILD_OPTIONS \
18+
--with-cross-bootstrap"
19+
fi
20+
1621
if [ "$DEBUG" = 1 ] ; then
1722
HOST_OPTIONS="$HOST_OPTIONS \
1823
--enable-debug \
@@ -43,7 +48,7 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$CYGWIN_BUILD_PATH/Makefile" ]]; then
4348
--disable-dumper \
4449
--with-sysroot=$TOOLCHAIN_PATH \
4550
--with-build-sysroot=$TOOLCHAIN_PATH \
46-
--with-cross-bootstrap \
51+
$BUILD_OPTIONS \
4752
$HOST_OPTIONS \
4853
$TARGET_OPTIONS
4954
echo "::endgroup::"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$GCC_BUILD_PATH/Makefile" ]]; then
109109
--host=$HOST \
110110
--target=$TARGET \
111111
--enable-static \
112-
--enable-languages=c,c++,d,fortran,lto,m2,objc,obj-c++ \
112+
--enable-languages=c,c++,fortran,lto,m2,objc,obj-c++ \
113113
--disable-bootstrap \
114114
--disable-multilib \
115115
--with-gnu-as \

.github/scripts/toolchain/execute-cygwin-tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ mkdir -p $ARTIFACT_PATH
1212

1313
echo "::group::Execute Cygwin tests"
1414
pushd "$CYGWIN_WINSUP_TEST_PATH" || exit 1
15+
pushd mingw
16+
make
17+
popd
18+
1519
if [[ -z "$NAMES" ]]; then
1620
MAKE_CHECK_COMMAND=( make $CHECK_MAKE_OPTIONS check )
1721
else

.github/workflows/advanced.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
87
workflow_dispatch:
98
inputs:
109
binutils_branch:

.github/workflows/main.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build main toolchain
1+
name: Build Cygwin toolchain
22

33
on:
44
push:
@@ -19,23 +19,47 @@ on:
1919
description: 'Mingw branch to build'
2020
required: false
2121
default: 'woarm64'
22+
cygwin_branch:
23+
description: 'Cygwin branch to build'
24+
required: false
25+
default: 'native-cygwin'
26+
2227
env:
2328
BINUTILS_BRANCH: ${{ inputs.binutils_branch || 'woarm64' }}
2429
GCC_BRANCH: ${{ inputs.gcc_branch || 'woarm64' }}
2530
MINGW_BRANCH: ${{ inputs.mingw_branch || 'woarm64' }}
31+
CYGWIN_BRANCH: ${{ inputs.cygwin_branch || 'native-cygwin' }}
32+
33+
ARCH: aarch64
34+
PLATFORM: pc-cygwin
2635

2736
BUILD_PATH: ${{ github.workspace }}/build
2837
CCACHE_DIR_PATH: ${{ github.workspace }}/ccache
2938
TOOLCHAIN_PATH: ${{ github.workspace }}/cross
3039

31-
CCACHE: 1
40+
CCACHE: 0
3241
DELETE_BUILD: 1
3342

3443
jobs:
3544
build-toolchain:
36-
runs-on: ubuntu-24.04-arm
45+
runs-on: windows-11-arm
46+
47+
defaults:
48+
run:
49+
shell: bash --noprofile --norc -eo pipefail -c "PATH=/usr/bin:$(/usr/bin/cygpath $SYSTEMROOT)/system32:$PATH $(s=$(/usr/bin/cygpath '{0}') && /usr/bin/sed -i 's/\r$//' $s && echo $s)"
3750

3851
steps:
52+
- name: Install Cygwin
53+
uses: cygwin/cygwin-install-action@master
54+
with:
55+
platform: x86_64
56+
packages: >-
57+
wget
58+
59+
- name: Setup Git
60+
run: |
61+
git config --global core.autocrlf input
62+
3963
- name: Checkout repository
4064
uses: actions/checkout@v4
4165

@@ -48,8 +72,8 @@ jobs:
4872
uses: actions/cache/restore@v4
4973
with:
5074
path: ${{ env.CCACHE_DIR_PATH }}
51-
key: main-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }}
52-
restore-keys: main-gcc-ccache-
75+
key: cygwin-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }}
76+
restore-keys: cygwin-gcc-ccache-
5377

5478
- name: Run Build
5579
run: |
@@ -64,19 +88,19 @@ jobs:
6488
uses: actions/cache/save@v4
6589
with:
6690
path: ${{ env.CCACHE_DIR_PATH }}
67-
key: main-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }}
91+
key: cygwin-gcc-ccache-${{ steps.get-cache-key.outputs.timestamp }}
6892

6993
- name: Upload build folder
7094
if: failure()
7195
uses: actions/upload-artifact@v4
7296
with:
73-
name: main-aarch64-w64-mingw32-build
97+
name: aarch64-pc-cygwin-build
7498
retention-days: 1
7599
path: ${{ env.BUILD_PATH }}
76100

77101
- name: Upload artifact
78102
uses: actions/upload-artifact@v4
79103
with:
80-
name: main-aarch64-w64-mingw32-toolchain
104+
name: aarch64-pc-cygwin-toolchain
81105
path: ${{ env.TOOLCHAIN_PATH }}
82106
retention-days: 1

0 commit comments

Comments
 (0)