Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 43 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Build
on:
push:
pull_request:
workflow_dispatch:
repository_dispatch:
types: [run_build]

Expand All @@ -12,6 +13,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
sudo apt-get update
Expand All @@ -21,7 +24,7 @@ jobs:
run: |
git config --global user.email "builds@travis-ci.com"
git config --global user.name "Travis CI"
mkdir build
mkdir -p build
cd build
cmake ..
make -j$(nproc) tarball
Expand All @@ -36,6 +39,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
sudo apt-get update
Expand All @@ -45,7 +50,7 @@ jobs:
run: |
git config --global user.email "builds@travis-ci.com"
git config --global user.name "Travis CI"
mkdir build
mkdir -p build
cd build
cmake ..
make -j$(nproc) tarball
Expand All @@ -56,24 +61,52 @@ jobs:
name: vitasdk-linux-arm64
path: build/*.tar.bz2
build-macos:
runs-on: macos-12
runs-on: macos-15-intel
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
brew install autoconf automake libtool texinfo
- name: Build
run: |
git config --global user.email "builds@travis-ci.com"
git config --global user.name "Travis CI"
brew install autoconf automake libtool
mkdir build
mkdir -p build
cd build
cmake ..
make -j$(nproc) tarball
make -j4 tarball
- name: Upload artifacts
if: ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: vitasdk-macos-x86_64
path: build/*.tar.bz2
build-macos-arm64:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
brew install autoconf automake libtool texinfo
- name: Build
run: |
git config --global user.email "builds@travis-ci.com"
git config --global user.name "Travis CI"
mkdir -p build
cd build
cmake ..
make -j4 tarball
- name: Upload artifacts
if: ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: vitasdk-macos
name: vitasdk-macos-arm64
path: build/*.tar.bz2
build-windows:
# TODO match as build-linux
Expand All @@ -83,6 +116,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
sudo apt-get update
Expand All @@ -94,7 +129,7 @@ jobs:
git config --global user.name "Travis CI"
unset CXX
unset CC
mkdir build
mkdir -p build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=toolchain-x86_64-w64-mingw32.cmake
make -j$(nproc) tarball
Expand Down
55 changes: 43 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
ExternalProject_Add_Step(zlib${suffix}
delete_shared
DEPENDEES install
COMMAND ${CMAKE_COMMAND} -E remove
COMMAND ${CMAKE_COMMAND} -E remove -f
${toolchain_deps_dir}/lib/libz.so
${toolchain_deps_dir}/lib/libz.so.1
${toolchain_deps_dir}/lib/libz.dylib
${toolchain_deps_dir}/lib/libz.*.dylib
COMMENT "Delete shared libraries, if present"
)
endif()
Expand All @@ -173,7 +175,8 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
GIT_REPOSITORY https://github.com/vitasdk/libzip
GIT_TAG ${LIBZIP_TAG}
${GIT_SHALLOW_SUPPORT}
PATCH_COMMAND patch -d <SOURCE_DIR> -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/libzip.patch
PATCH_COMMAND git -C <SOURCE_DIR> reset --hard HEAD && git -C <SOURCE_DIR> clean -fd
COMMAND patch -d <SOURCE_DIR> -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/libzip.patch
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${toolchain_deps_dir}
${toolchain_cmake_args} ${libzip_configure}
-DZLIB_INCLUDE_DIR=${toolchain_deps_dir}/include
Expand All @@ -185,6 +188,7 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
URL_HASH ${LIBELF_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND patch -d <SOURCE_DIR> -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/libelf.patch
COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND autoreconf -i <SOURCE_DIR> COMMAND CC=${cc_compiler} RANLIB=${ranlib} ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
Expand All @@ -195,9 +199,10 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
)

ExternalProject_add(libyaml${suffix}
URL http://pyyaml.org/download/libyaml/yaml-${LIBYAML_VERSION}.tar.gz
URL https://pyyaml.org/download/libyaml/yaml-${LIBYAML_VERSION}.tar.gz
URL_HASH ${LIBYAML_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>/config
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
Expand All @@ -208,25 +213,37 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
"CFLAGS=-DYAML_DECLARE_STATIC"
)

# GMP assembly causes issues on macOS - need to disable it and use PIC
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(gmp_asm_flag --disable-assembly)
set(gmp_env_command ${CMAKE_COMMAND} -E env "CFLAGS=-fPIC -fexceptions" "CXXFLAGS=-fPIC -fexceptions")
else()
set(gmp_asm_flag "")
set(gmp_env_command ${CMAKE_COMMAND} -E env "CFLAGS=-fexceptions" "CXXFLAGS=-fexceptions")
endif()

ExternalProject_add(gmp${suffix}
URL http://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.bz2
URL https://ftpmirror.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.bz2
URL_HASH ${GMP_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
CONFIGURE_COMMAND CPPFLAGS=-fexceptions ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
PATCH_COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND ${gmp_env_command} ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
--prefix=${toolchain_deps_dir}
--libdir=${toolchain_deps_dir}/lib
--enable-cxx
--disable-shared
${gmp_asm_flag}
BUILD_COMMAND ${compiler_flags} ${wrapper_command} $(MAKE)
)

ExternalProject_add(mpfr${suffix}
DEPENDS gmp${suffix}
URL http://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VERSION}.tar.bz2
URL https://ftpmirror.gnu.org/gnu/mpfr/mpfr-${MPFR_VERSION}.tar.bz2
URL_HASH ${MPFR_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
Expand All @@ -238,9 +255,10 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi

ExternalProject_add(mpc${suffix}
DEPENDS gmp${suffix} mpfr${suffix}
URL https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz
URL https://ftpmirror.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz
URL_HASH ${MPC_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
Expand All @@ -257,6 +275,7 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
GIT_REPOSITORY https://github.com/Meinersbur/isl
GIT_TAG isl-${ISL_VERSION}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND cd <SOURCE_DIR> && ./autogen.sh COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
Expand All @@ -270,6 +289,7 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
URL https://github.com/libexpat/libexpat/releases/download/R_2_3_0/expat-${EXPAT_VERSION}.tar.bz2
URL_HASH ${EXPAT_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>/conftools
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
Expand All @@ -294,13 +314,15 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
)

ExternalProject_Add(binutils${suffix}
URL https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz
URL https://ftpmirror.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz
URL_HASH ${BINUTILS_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND
patch -d <SOURCE_DIR> -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/binutils/0001-vita.patch
&& patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/binutils/0002-fix-broken-reloc.patch
&& patch -d <SOURCE_DIR> -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/binutils/0003-fix-elf-vaddr.patch
&& patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/common/zlib-fdopen-macos.patch
&& sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
Expand All @@ -319,10 +341,13 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
)

ExternalProject_Add(gdb${suffix}
URL https://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.xz
URL https://ftpmirror.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.xz
URL_HASH ${GDB_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gdb.patch
&& patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/common/zlib-fdopen-macos.patch
&& patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gdb-enum-fix.patch
&& sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
Expand Down Expand Up @@ -459,10 +484,12 @@ endif()
# Build a basic gcc compiler, needed to compile newlib
ExternalProject_add(gcc-base
DEPENDS gmp_${build_suffix} mpfr_${build_suffix} mpc_${build_suffix} isl_${build_suffix} libelf_${build_suffix}
URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
URL https://ftpmirror.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
URL_HASH ${GCC_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-10.patch
&& patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0002-fix-macos-arm64.patch
&& sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
# compile a native compiler so keep host == build
Expand Down Expand Up @@ -557,10 +584,12 @@ ExternalProject_Add(newlib
if(CMAKE_TOOLCHAIN_FILE)
ExternalProject_add(gcc-complete
DEPENDS newlib gmp_${build_suffix} mpfr_${build_suffix} mpc_${build_suffix} isl_${build_suffix} libelf_${build_suffix}
URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
URL https://ftpmirror.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
URL_HASH ${GCC_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-10.patch
&& patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0002-fix-macos-arm64.patch
&& sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools}
${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
Expand Down Expand Up @@ -613,10 +642,12 @@ ExternalProject_Add(pthread-embedded
ExternalProject_add(gcc-final
DEPENDS gmp_${target_suffix} mpfr_${target_suffix} mpc_${target_suffix} isl_${target_suffix} libelf_${target_suffix}
DEPENDS newlib ${GCC_DEPENDS} pthread-embedded
URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
URL https://ftpmirror.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
URL_HASH ${GCC_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-10.patch
&& patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0002-fix-macos-arm64.patch
&& sh ${PROJECT_SOURCE_DIR}/cmake/update_config_files.sh <SOURCE_DIR>
CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools} ${compiler_target_tools}
${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
Expand Down
75 changes: 75 additions & 0 deletions cmake/update_config_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/sh
# Update config.sub and config.guess for ARM64 support
set -e

SOURCE_DIR=$1

if [ -z "$SOURCE_DIR" ]; then
echo "Error: No source directory provided" >&2
echo "Usage: $0 <source_directory>" >&2
exit 1
fi

if [ ! -d "$SOURCE_DIR" ]; then
echo "Error: Source directory does not exist: $SOURCE_DIR" >&2
exit 1
fi

# Update on ARM64 platforms (macOS and Linux) - old config files don't recognize aarch64
ARCH=$(uname -m)
OS=$(uname -s)

# Check if we're on ARM64 (macOS uses "arm64", Linux uses "aarch64")
if [ "$ARCH" != "arm64" ] && [ "$ARCH" != "aarch64" ]; then
echo "Skipping config files update (not ARM64 platform: $ARCH)"
exit 0
fi

echo "Updating config.sub and config.guess in $SOURCE_DIR for ARM64 support ($OS $ARCH)"

# Check if curl is available
if ! command -v curl >/dev/null 2>&1; then
echo "Error: curl command not found. Cannot download config files." >&2
echo " Please install curl or manually update config.sub and config.guess" >&2
exit 1
fi

# Remove old files if they exist and are read-only
[ -f "$SOURCE_DIR/config.sub" ] && chmod +w "$SOURCE_DIR/config.sub" 2>/dev/null
[ -f "$SOURCE_DIR/config.guess" ] && chmod +w "$SOURCE_DIR/config.guess" 2>/dev/null

# Download latest config files from GNU config repository
CONFIG_BASE_URL='https://git.savannah.gnu.org/cgit/config.git/plain'

# Try to download latest config.sub with timeout and retries
if ! curl -f -s -S -L --connect-timeout 30 --max-time 60 --retry 3 \
-o "$SOURCE_DIR/config.sub" "$CONFIG_BASE_URL/config.sub"; then
echo "Warning: Failed to download config.sub from $CONFIG_BASE_URL/config.sub" >&2
echo " Build might fail on ARM64 if config.sub doesn't support aarch64" >&2
else
echo "Successfully downloaded config.sub"
fi

# Try to download latest config.guess with timeout and retries
if ! curl -f -s -S -L --connect-timeout 30 --max-time 60 --retry 3 \
-o "$SOURCE_DIR/config.guess" "$CONFIG_BASE_URL/config.guess"; then
echo "Warning: Failed to download config.guess from $CONFIG_BASE_URL/config.guess" >&2
echo " Build might fail on ARM64 if config.guess doesn't recognize this platform" >&2
else
echo "Successfully downloaded config.guess"
fi

# Make them executable if they exist
if [ -f "$SOURCE_DIR/config.sub" ]; then
chmod +x "$SOURCE_DIR/config.sub"
echo "Made config.sub executable"
fi

if [ -f "$SOURCE_DIR/config.guess" ]; then
chmod +x "$SOURCE_DIR/config.guess"
echo "Made config.guess executable"
fi

echo "Config files update completed"
exit 0

Loading