Skip to content

Commit

Permalink
Add aarch64-pc-cygwin target to advanced.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackhex committed Sep 5, 2024
1 parent b5edb17 commit 1b0bee4
Show file tree
Hide file tree
Showing 23 changed files with 3,823 additions and 45 deletions.
13 changes: 12 additions & 1 deletion .github/scripts/binutils/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$BINUTILS_BUILD_PATH/Makefile" ]]; then
--enable-host-shared \
--enable-64-bit-bfd \
--enable-install-libiberty \
--enable-targets=x86_64-pep \
--with-sysroot=$TOOLCHAIN_PATH \
--with-build-sysroot=$TOOLCHAIN_PATH \
--with-system-zlib \
Expand All @@ -42,6 +41,18 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$BINUTILS_BUILD_PATH/Makefile" ]]; then
;;
esac

case "$ARCH-$PLATFORM" in
x86_64-*cygwin*)
TARGET_OPTIONS="$TARGET_OPTIONS \
--enable-targets=x86_64-pep"
;;
aarch64-*cygwin*)
TARGET_OPTIONS="$TARGET_OPTIONS \
--enable-targets=aarch64-pep \
--disable-sim"
;;
esac

$SOURCE_PATH/binutils/configure \
--prefix=$TOOLCHAIN_PATH \
--build=$BUILD \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ echo "::group::Patch Cygwin binutils"
PATCH_DIR=$SOURCE_PATH/cygwin-packages/binutils
patch -p2 -i $PATCH_DIR/binutils-2.42-cygwin-config-rpath.patch
patch -p2 -i $PATCH_DIR/binutils-2.42-cygwin-pep-dll-double-definition.patch

case "$ARCH" in
aarch64)
patch -p1 -i $PATCHES_PATH/binutils/0001-aarch64-cygwin.patch
;;
esac
echo "::endgroup::"

echo 'Success!'
17 changes: 14 additions & 3 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ fi
if [[ "$APPLY_PATCHES" = 1 ]]; then
case "$PLATFORM" in
*cygwin*)
$ROOT_PATH/.github/scripts/binutils/patch-cygwin.sh 1
$ROOT_PATH/.github/scripts/binutils/patch-cygwin-binutils.sh 1
$ROOT_PATH/.github/scripts/toolchain/patch-cygwin-gcc.sh 1
$ROOT_PATH/.github/scripts/toolchain/patch-cygwin-mingw.sh 1
$ROOT_PATH/.github/scripts/toolchain/patch-cygwin.sh 1
;;
esac
Expand Down Expand Up @@ -61,8 +63,8 @@ fi
if [[ "$APPLY_PATCHES" = 1 ]]; then
case "$PLATFORM" in
*cygwin*)
$ROOT_PATH/.github/scripts/binutils/patch-cygwin.sh 2
$ROOT_PATH/.github/scripts/toolchain/patch-cygwin.sh 2
$ROOT_PATH/.github/scripts/toolchain/patch-cygwin-gcc.sh 2
$ROOT_PATH/.github/scripts/toolchain/patch-cygwin-mingw.sh 2
;;
esac
fi
Expand All @@ -76,6 +78,15 @@ $ROOT_PATH/.github/scripts/toolchain/build-gcc.sh
if [[ "$PLATFORM" =~ (mingw|cygwin) ]]; then
$ROOT_PATH/.github/scripts/toolchain/build-mingw.sh
fi

if [[ "$APPLY_PATCHES" = 1 ]]; then
case "$PLATFORM" in
*cygwin*)
$ROOT_PATH/.github/scripts/toolchain/patch-cygwin.sh 2
;;
esac
fi

if [[ "$PLATFORM" =~ cygwin ]]; then
$ROOT_PATH/.github/scripts/toolchain/build-cygwin.sh 2
fi
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ set -x # echo on
set -o pipefail # fail of any command in pipeline is an error

ARCH=${ARCH:-aarch64}
PLATFORM=${PLATFORM:-w64-mingw32}
PLATFORM=${PLATFORM:-pc-cygwin}
if [[ "$PLATFORM" =~ (mingw|cygwin) ]]; then
CRT=${CRT:-msvcrt}
else
CRT=${CRT:-libc}
fi

PROCESSOR=$(uname --processor)
PROCESSOR=$(gcc -dumpmachine)
BUILD=${BUILD:-$PROCESSOR-pc-linux-gnu}
HOST=${HOST:-$PROCESSOR-pc-linux-gnu}
TARGET=$ARCH-$PLATFORM
Expand Down
7 changes: 7 additions & 0 deletions .github/scripts/toolchain/build-cygwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$CYGWIN_BUILD_PATH/Makefile" ]]; then
echo "::group::Configure Cygwin"
rm -rf $CYGWIN_BUILD_PATH/*

if [ "$DEBUG" = 1 ] ; then
HOST_OPTIONS="$HOST_OPTIONS \
--enable-debug \
--disable-lto"
fi

case "$STAGE" in
1)
TARGET_OPTIONS="$TARGET_OPTIONS \
Expand All @@ -37,6 +43,7 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$CYGWIN_BUILD_PATH/Makefile" ]]; then
--with-sysroot=$TOOLCHAIN_PATH \
--with-build-sysroot=$TOOLCHAIN_PATH \
--with-cross-bootstrap \
$HOST_OPTIONS \
$TARGET_OPTIONS
echo "::endgroup::"
fi
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/toolchain/build-mingw-crt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ if [[ "$RUN_INSTALL" = 1 ]]; then
ln -fs w32api/libuserenv.a .
ln -fs w32api/libnetapi32.a .
ln -fs w32api/libdbghelp.a .
ln -fs w32api/libonecore.a .
ln -fs w32api/libpdh.a .
popd
;;
esac
Expand Down
35 changes: 35 additions & 0 deletions .github/scripts/toolchain/patch-cygwin-gcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

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

echo "::group::Patch Cygwin GCC"
cd $SOURCE_PATH/$GCC_VERSION

if [[ "$RESET_SOURCES" = 1 ]]; then
git reset --hard HEAD
git clean -fdx
fi

PATCH_DIR=$SOURCE_PATH/cygwin-packages/gcc
patch -p1 -i $PATCH_DIR/0001-Cygwin-use-SysV-ABI-on-x86_64.patch
patch -p1 -i $PATCH_DIR/0002-Cygwin-add-dummy-pthread-tsaware-and-large-address-a.patch
patch -p1 -i $PATCH_DIR/0003-Cygwin-handle-dllimport-properly-in-medium-model-V2.patch
patch -p1 -i $PATCH_DIR/0004-Cygwin-MinGW-skip-test.patch
patch -p1 -i $PATCH_DIR/0005-Cygwin-define-RTS_CONTROL_ENABLE-and-DTR_CONTROL_ENA.patch
patch -p1 -i $PATCH_DIR/0007-Cygwin-__cxa-atexit.patch
patch -p1 -i $PATCH_DIR/0008-Cygwin-libgomp-soname.patch
patch -p1 -i $PATCH_DIR/0009-Cygwin-g-time.patch
patch -p1 -i $PATCH_DIR/0010-Cygwin-newlib-ftm.patch
patch -p1 -i $PATCH_DIR/0011-Cygwin-define-STD_UNIX.patch
patch -p1 -i $PATCH_DIR/0101-Cygwin-enable-libgccjit-not-just-for-MingW.patch
patch -p1 -i $PATCH_DIR/0102-Cygwin-testsuite-fixes-for-libgccjit.patch

case "$ARCH" in
aarch64)
patch -p1 -i $PATCHES_PATH/gcc/0001-aarch64-cygwin.patch
patch -p1 -i $PATCHES_PATH/gcc/0002-cygming-extern.patch
;;
esac
echo "::endgroup::"

echo 'Success!'
20 changes: 20 additions & 0 deletions .github/scripts/toolchain/patch-cygwin-mingw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

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

echo echo "::group::Patch MinGW"
cd $SOURCE_PATH/$MINGW_VERSION

if [[ "$RESET_SOURCES" = 1 ]]; then
git reset --hard HEAD
git clean -fdx
fi

case "$ARCH" in
aarch64)
patch -p1 -i $PATCHES_PATH/mingw/0001-aarch64-cygwin.patch
;;
esac
echo "::endgroup::"

echo 'Success!'
41 changes: 11 additions & 30 deletions .github/scripts/toolchain/patch-cygwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,6 @@ source `dirname ${BASH_SOURCE[0]}`/../config.sh

STAGE=$1

# Force source reset for Cygwin stage 2 build.
if [[ "$STAGE" = 2 && "$PLATFORM" =~ cygwin ]]; then
RESET_SOURCES=1
fi

echo "::group::Patch Cygwin GCC"
cd $SOURCE_PATH/gcc

if [[ "$RESET_SOURCES" = 1 ]]; then
git reset --hard HEAD
git clean -fdx
fi

PATCH_DIR=$SOURCE_PATH/cygwin-packages/gcc
patch -p1 -i $PATCH_DIR/0001-Cygwin-use-SysV-ABI-on-x86_64.patch
patch -p1 -i $PATCH_DIR/0002-Cygwin-add-dummy-pthread-tsaware-and-large-address-a.patch
patch -p1 -i $PATCH_DIR/0003-Cygwin-handle-dllimport-properly-in-medium-model-V2.patch
patch -p1 -i $PATCH_DIR/0004-Cygwin-MinGW-skip-test.patch
patch -p1 -i $PATCH_DIR/0005-Cygwin-define-RTS_CONTROL_ENABLE-and-DTR_CONTROL_ENA.patch
patch -p1 -i $PATCH_DIR/0007-Cygwin-__cxa-atexit.patch
patch -p1 -i $PATCH_DIR/0008-Cygwin-libgomp-soname.patch
patch -p1 -i $PATCH_DIR/0009-Cygwin-g-time.patch
patch -p1 -i $PATCH_DIR/0010-Cygwin-newlib-ftm.patch
patch -p1 -i $PATCH_DIR/0011-Cygwin-define-STD_UNIX.patch
patch -p1 -i $PATCH_DIR/0101-Cygwin-enable-libgccjit-not-just-for-MingW.patch
patch -p1 -i $PATCH_DIR/0102-Cygwin-testsuite-fixes-for-libgccjit.patch
echo "::endgroup::"

echo "::group::Patch Cygwin"
cd $SOURCE_PATH/cygwin

Expand All @@ -45,13 +17,22 @@ echo "::group::Patch Cygwin"
patch -p1 -i $PATCH_DIR/0001-before-autogen.patch
fi

patch -p1 -i $PATCHES_PATH/cygwin/0003-master.patch

case "$ARCH" in
aarch64)
patch -p1 -i $PATCHES_PATH/cygwin/0004-aarch64-cygwin.patch
if [ "$STAGE" = "2" ]; then
patch -p1 -i $PATCHES_PATH/cygwin/0005-aarch64-gendef.patch
fi
;;
esac

(cd winsup && ./autogen.sh)

if [[ "$STAGE" = "1" ]]; then
patch -p1 -i $PATCH_DIR/0002-after-autogen.patch
fi

patch -p1 -i $PATCHES_PATH/cygwin/0003-master.patch
echo "::endgroup::"

echo 'Success!'
18 changes: 12 additions & 6 deletions .github/workflows/advanced.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ env:
FFMPEG_BRANCH: release/6.1

TOOLCHAIN_PATH: ${{ github.workspace }}/cross
TOOLCHAIN_NAME: aarch64-w64-mingw32-msvcrt
TOOLCHAIN_PACKAGE_NAME: aarch64-w64-mingw32-msvcrt-toolchain.tar.gz
TOOLCHAIN_NAME: ${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}
TOOLCHAIN_PACKAGE_NAME: ${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-toolchain.tar.gz

SOURCE_PATH: ${{ github.workspace }}/code
BUILD_PATH: ${{ github.workspace }}/build
Expand Down Expand Up @@ -129,8 +129,6 @@ jobs:
crt: ucrt
- platform: pc-cygwin
crt: libc
- platform: pc-cygwin
arch: aarch64

env:
ARCH: ${{ matrix.arch }}
Expand Down Expand Up @@ -240,11 +238,13 @@ jobs:
- name: Patch binutils stage1
if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform == 'pc-cygwin' }}
run: |
.github/scripts/binutils/patch-cygwin.sh 1
.github/scripts/binutils/patch-cygwin-binutils.sh 1
- name: Patch toolchain stage1
if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform == 'pc-cygwin' }}
run: |
.github/scripts/toolchain/patch-cygwin-gcc.sh 1
.github/scripts/toolchain/patch-cygwin-mingw.sh 1
.github/scripts/toolchain/patch-cygwin.sh 1
- name: Install libraries
Expand Down Expand Up @@ -314,7 +314,8 @@ jobs:
- name: Patch toolchain stage2
if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform == 'pc-cygwin' }}
run: |
.github/scripts/toolchain/patch-cygwin.sh 2
.github/scripts/toolchain/patch-cygwin-gcc.sh 2
.github/scripts/toolchain/patch-cygwin-mingw.sh 2
- name: Install libraries
if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' }}
Expand All @@ -331,6 +332,11 @@ jobs:
run: |
.github/scripts/toolchain/build-mingw.sh
- name: Patch Cygwin stage2
if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && inputs.platform == 'pc-cygwin' }}
run: |
.github/scripts/toolchain/patch-cygwin.sh 2
- name: Build Cygwin stage2
if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' && matrix.platform == 'pc-cygwin' }}
run: |
Expand Down
Loading

0 comments on commit 1b0bee4

Please sign in to comment.