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 authored and github-actions committed Apr 22, 2024
1 parent 2f89bc6 commit c76598f
Show file tree
Hide file tree
Showing 22 changed files with 3,922 additions and 17 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_VERSION/configure \
--prefix=$TOOLCHAIN_PATH \
--build=$BUILD \
Expand Down
6 changes: 6 additions & 0 deletions .github/scripts/binutils/patch-cygwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ echo "::group::Patch Cygwin 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!'
6 changes: 3 additions & 3 deletions .github/scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ LIBJPEG_TURBO_VERSION=${LIBJPEG_TURBO_VERSION:-libjpeg-turbo-main}
FFMPEG_VERSION=${FFMPEG_VERSION:-ffmpeg-master}

ARCH=${ARCH:-aarch64}
PLATFORM=${PLATFORM:-w64-mingw32}
PLATFORM=${PLATFORM:-pc-cygwin}
if [[ "$PLATFORM" =~ (mingw|cygwin) ]]; then
CRT=${CRT:-msvcrt}
else
CRT=${CRT:-libc}
fi
BUILD=x86_64-pc-linux-gnu
HOST=x86_64-pc-linux-gnu
BUILD=`gcc -dumpmachine`
HOST=`gcc -dumpmachine`
TARGET=$ARCH-$PLATFORM
TOOLCHAIN_NAME=${TOOLCHAIN_NAME:-$ARCH-$PLATFORM-$CRT}

Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source `dirname ${BASH_SOURCE[0]}`/config.sh

echo "::group::Install Dependencies"
sudo apt update
sudo apt install -y build-essential binutils-for-build texinfo bison flex ccache docbook2x xmlto zlib1g-dev libgmp-dev libmpc-dev libc6-dev-arm64-cross libc6-dev-amd64-cross libisl-dev dejagnu
sudo apt install -y autoconf automake build-essential binutils-for-build texinfo bison flex ccache docbook2x xmlto zlib1g-dev libgmp-dev libmpc-dev libc6-dev-arm64-cross libc6-dev-amd64-cross libisl-dev dejagnu
echo "::endgroup::"

echo 'Success!'
4 changes: 2 additions & 2 deletions .github/scripts/tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ "$RUN_CONFIG" = 1 ] || [ ! -f build/CMakeCache.txt ] ; then
fi

echo "::group::Build tests"
cmake --build build
cmake --build build ${BUILD_MAKE_OPTIONS//V=1/-v}

case "$PLATFORM" in
w64-mingw32)
Expand All @@ -24,7 +24,7 @@ echo "::group::Build tests"
pc-cygwin)
cp $TOOLCHAIN_PATH/bin/cygwin1.dll build/bin
cp $TOOLCHAIN_PATH/lib/gcc/$TARGET/cyggcc_s-seh-1.dll build/bin
cp $TOOLCHAIN_PATH/lib/gcc/$TARGET/14/cyggomp-1.dll build/bin
cp $TOOLCHAIN_PATH/lib/gcc/$TARGET/14/cyggomp-1.dll build/bin && true
;;
esac
echo "::endgroup::"
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
30 changes: 28 additions & 2 deletions .github/scripts/toolchain/patch-cygwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ echo "::group::Patch Cygwin GCC"
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 echo "::group::Patch MinGW"
cd $SOURCE_PATH/$MINGW_VERSION

git reset --hard
git clean -fdx

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

echo "::group::Patch Cygwin"
Expand All @@ -36,13 +56,19 @@ 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
;;
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!'
5 changes: 2 additions & 3 deletions .github/workflows/advanced.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ env:
TOOLCHAIN_PATH: ${{ github.workspace }}/cross
TOOLCHAIN_NAME: ${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}
TOOLCHAIN_PACKAGE_NAME: ${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-toolchain.tar.gz

TESTS_PACKAGE_NAME: ${{ inputs.arch }}-${{ inputs.crt }}-tests.tar.gz
TESTS_PACKAGE_NAME: ${{ inputs.arch }}-${{ inputs.platform }}-${{ inputs.crt }}-tests.tar.gz

SOURCE_PATH: ${{ github.workspace }}/code
ARTIFACT_PATH: ${{ github.workspace }}/artifact

TEST_TOOLCHAIN: ${{ (inputs.arch == 'aarch64' && inputs.platform == 'w64-mingw32' && inputs.crt == 'msvcrt') || (inputs.arch == 'x86_64' && inputs.platform == 'pc-cygwin') }}
TEST_TOOLCHAIN: ${{ (inputs.arch == 'aarch64' && inputs.platform == 'w64-mingw32' && inputs.crt == 'msvcrt') || inputs.platform == 'pc-cygwin' }}
TEST_PACKAGES: ${{ inputs.arch == 'aarch64' && inputs.platform == 'w64-mingw32' && inputs.crt == 'msvcrt' }}

jobs:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ jobs:
crt: ucrt
- platform: pc-cygwin
crt: libc
- platform: pc-cygwin
arch: aarch64

uses: ./.github/workflows/advanced.yml
with:
Expand Down
186 changes: 186 additions & 0 deletions patches/binutils/0001-aarch64-cygwin.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 6553aac1e99d..c3be7e0fe585 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -248,7 +248,7 @@ case "${targ}" in
targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec aarch64_pei_le_vec aarch64_pe_le_vec"
want64=true
;;
- aarch64-*-pe* | aarch64-*-mingw*)
+ aarch64-*-pe* | aarch64-*-mingw* | aarch64-*-cygwin*)
targ_defvec=aarch64_pe_le_vec
targ_selvecs="aarch64_pe_le_vec aarch64_pei_le_vec aarch64_elf64_le_vec aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec pdb_vec"
want64=true
diff --git a/binutils/configure b/binutils/configure
index 2b9f52720c3e..654476cd2e1d 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -16426,7 +16426,7 @@ do
esac

case $targ in
- aarch64-*-mingw*)
+ aarch64-*-mingw* | aarch64-*-cygwin*)
BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
if test -z "$DLLTOOL_DEFAULT"; then
DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_AARCH64"
diff --git a/binutils/configure.ac b/binutils/configure.ac
index dac72c1bdd4d..28a51bdd7e93 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -369,7 +369,7 @@ changequote([,])dnl
esac

case $targ in
- aarch64-*-mingw*)
+ aarch64-*-mingw*| aarch64-*-cygwin* )
BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
if test -z "$DLLTOOL_DEFAULT"; then
DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_AARCH64"
diff --git a/config.guess b/config.guess
index cdfc4392047c..91a44145ed1a 100755
--- a/config.guess
+++ b/config.guess
@@ -951,6 +951,9 @@ EOF
i*:UWIN*:*)
GUESS=$UNAME_MACHINE-pc-uwin
;;
+ aarch64:CYGWIN*:*:*)
+ GUESS=aarch64-pc-cygwin
+ ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
GUESS=x86_64-pc-cygwin
;;
diff --git a/gas/configure.tgt b/gas/configure.tgt
index 7c66734e362b..94fa2407f416 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -138,7 +138,7 @@ case ${generic_target} in
aarch64*-*-netbsd*) fmt=elf em=nbsd;;
aarch64*-*-nto*) fmt=elf;;
aarch64*-*-openbsd*) fmt=elf;;
- aarch64*-*-pe* | aarch64*-*-mingw*) fmt=coff em=pepaarch64 ;;
+ aarch64*-*-pe* | aarch64*-*-mingw* | aarch64*-*-cygwin*) fmt=coff em=pepaarch64 ;;
alpha-*-*vms*) fmt=evax ;;
alpha-*-osf*) fmt=ecoff ;;
alpha-*-linux*ecoff*) fmt=ecoff ;;
diff --git a/gdb/configure.host b/gdb/configure.host
index da71675b201b..05debc74ab3c 100644
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -81,6 +81,7 @@ case "${host}" in

aarch64*-*-linux*) gdb_host=linux ;;
aarch64*-*-freebsd*) gdb_host=fbsd ;;
+aarch64*-*-cygwin*) gdb_host=cygwin64 ;;

alpha*-*-linux*) gdb_host=alpha-linux ;;
alpha*-*-netbsdaout* | alpha*-*-knetbsdaout*-gnu)
diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
index 9e861a75088a..c986da39f051 100644
--- a/gdbserver/configure.srv
+++ b/gdbserver/configure.srv
@@ -66,6 +66,13 @@ case "${gdbserver_host}" in
srv_tgtobj="${srv_tgtobj} nat/netbsd-nat.o"
srv_tgtobj="${srv_tgtobj} arch/aarch64-insn.o arch/aarch64.o"
;;
+ aarch64-*-cygwin*) srv_regobj=""
+ srv_tgtobj="aarch64-low.o nat/aarch64-dregs.o"
+ srv_tgtobj="${srv_tgtobj} nat/aarch64-xstate.o aarch64-fp.o"
+ srv_tgtobj="${srv_tgtobj} win32-low.o win32-aarch64-low.o"
+ srv_tgtobj="${srv_tgtobj} nat/windows-nat.o"
+ srv_tgtobj="${srv_tgtobj} arch/aarch64.o"
+ ;;
arc*-*-linux*)
srv_regobj=""
srv_tgtobj="linux-arc-low.o arch/arc.o $srv_linux_obj"
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 27b63e5112ad..f6a5d0feab9e 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -127,7 +127,7 @@ aarch64-*-haiku*) targ_emul=aarch64haiku
aarch64-*-nto*) targ_emul=aarch64nto
targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb"
;;
-aarch64-*-pe* | aarch64-*-mingw*)
+aarch64-*-pe* | aarch64-*-mingw* | aarch64-*-cygwin*)
targ_emul=aarch64pe
targ_extra_emuls=arm64pe
targ_extra_ofiles="deffilep.o pep-dll-aarch64.o pe-dll.o pdb.o"
@@ -1145,7 +1145,7 @@ spu-*-elf*)
NATIVE_LIB_DIRS='/lib'
;;

-i[03-9x]86-*-cygwin* | x86_64-*-cygwin*)
+aarch64-*-cygwin* | i[03-9x]86-*-cygwin* | x86_64-*-cygwin*)
NATIVE_LIB_DIRS='/usr/lib /usr/lib/w32api'
;;

diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 9ab5e6ef481c..0a2ff3f7fb48 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -69,6 +69,7 @@ fragment <<EOF
EOF

case ${target} in
+ aarch64-*-mingw* | aarch64-*-pe* | aarch64-*-cygwin | \
x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin | \
i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe)
fragment <<EOF
@@ -126,9 +126,8 @@ fragment <<EOF
#define DEFAULT_PSEUDO_RELOC_VERSION 1
#endif

-#define DEFAULT_DLL_CHARACTERISTICS (${cygwin_behavior} ? 0 : \
- IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE \
- | IMAGE_DLL_CHARACTERISTICS_NX_COMPAT)
+#define DEFAULT_DLL_CHARACTERISTICS ( IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE \
+ | IMAGE_DLL_CHARACTERISTICS_NX_COMPAT)

#if defined(TARGET_IS_i386pe) || ! defined(DLL_SUPPORT)
#define PE_DEF_SUBSYSTEM IMAGE_SUBSYSTEM_WINDOWS_CUI
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 5c9dddfc9369..2b282e130879 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -78,9 +78,9 @@ fragment <<EOF
EOF

case ${target} in
+ aarch64-*-mingw* | aarch64-*-pe* | aarch64-*-cygwin | \
x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin | \
- i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe | \
- aarch64-*-mingw* | aarch64-*-pe* )
+ i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe)
fragment <<EOF
#include "pdb.h"
EOF
@@ -126,10 +126,9 @@ fragment <<EOF
#define DLL_SUPPORT
#endif

-#define DEFAULT_DLL_CHARACTERISTICS (${cygwin_behavior} ? 0 : \
- IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE \
- | IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA \
- | IMAGE_DLL_CHARACTERISTICS_NX_COMPAT)
+#define DEFAULT_DLL_CHARACTERISTICS ( IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE \
+ | IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA \
+ | IMAGE_DLL_CHARACTERISTICS_NX_COMPAT)

#if defined(TARGET_IS_i386pep) || defined(COFF_WITH_peAArch64) || ! defined(DLL_SUPPORT)
#define PE_DEF_SUBSYSTEM IMAGE_SUBSYSTEM_WINDOWS_CUI
diff --git a/readline/readline/support/config.guess b/readline/readline/support/config.guess
index cc7a81070119..9c9b836c8ba4 100755
--- a/readline/readline/support/config.guess
+++ b/readline/readline/support/config.guess
@@ -915,6 +915,9 @@ EOF
i*:UWIN*:*)
echo "$UNAME_MACHINE"-pc-uwin
exit ;;
+ aarch64:CYGWIN*:*:*)
+ echo aarch64-pc-cygwin
+ ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
echo x86_64-pc-cygwin
exit ;;
4 changes: 2 additions & 2 deletions patches/cygwin/0001-before-autogen.patch
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ index 9efdd4c..a6c204d 100644
--- a/winsup/Makefile.am
+++ b/winsup/Makefile.am
@@ -14,10 +14,10 @@ cygdoc_DATA = \
CYGWIN_LICENSE \
COPYING
CYGWIN_LICENSE \
COPYING

-SUBDIRS = cygwin cygserver utils testsuite
+SUBDIRS = cygwin cygserver
Expand Down
2 changes: 1 addition & 1 deletion patches/cygwin/0002-after-autogen.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ diff --git a/winsup/configure b/winsup/configure
index e146cb7..e71d678 100755
--- a/winsup/configure
+++ b/winsup/configure
@@ -3938,150 +3938,6 @@ main (void)
@@ -3940,150 +3940,6 @@ main (void)
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
Expand Down
Loading

0 comments on commit c76598f

Please sign in to comment.