Skip to content
Draft
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
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ jobs:
with:
name: vitasdk-linux
path: build/*.tar.bz2
- uses: svenstaro/upload-release-action@v2
if: contains(github.ref,'refs/heads/musl')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/*.tar.bz2
overwrite: true
file_glob: true
tag: musl-linux-v${{github.run_number}}
release_name: musl-linux-v${{github.run_number}}
build-macos:
runs-on: macos-10.15
steps:
Expand All @@ -51,6 +60,15 @@ jobs:
with:
name: vitasdk-macos
path: build/*.tar.bz2
- uses: svenstaro/upload-release-action@v2
if: contains(github.ref,'refs/heads/musl')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/*.tar.bz2
overwrite: true
file_glob: true
tag: musl-macos-v${{github.run_number}}
release_name: musl-macos-v${{github.run_number}}
build-windows:
runs-on: ubuntu-latest
container: ubuntu:14.04
Expand Down Expand Up @@ -79,3 +97,12 @@ jobs:
with:
name: vitasdk-windows
path: build/*.tar.bz2
- uses: svenstaro/upload-release-action@v2
if: contains(github.ref,'refs/heads/musl')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/*.tar.bz2
overwrite: true
file_glob: true
tag: musl-windows-v${{github.run_number}}
release_name: musl-windows-v${{github.run_number}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build_linux
/build_mingw
/.idea
/build
62 changes: 19 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ set(GDB_HASH SHA256=360cd7ae79b776988e89d8f9a01c985d0b1fa21c767a4295e5f88cb49175

# Branches to fetch the different project targets. Can be overriden from command line.
set(LIBZIP_TAG master CACHE STRING "libzip branch name, commit id or tag")
set(NEWLIB_TAG vita CACHE STRING "newlib branch name, commit id or tag")
set(MUSL_TAG vita CACHE STRING "musl branch name, commit id or tag")
set(SAMPLES_TAG master CACHE STRING "samples branch name, commit id or tag")
set(HEADERS_TAG master CACHE STRING "vita-headers branch name, commit id or tag")
set(TOOLCHAIN_TAG master CACHE STRING "vita-toolchain branch name, commit id or tag")
set(PTHREAD_TAG master CACHE STRING "pthread-embedded branch name, commit id or tag")
set(VDPM_TAG master CACHE STRING "vdpm branch name, commit id or tag")
set(VITA_MAKEPKG_TAG master CACHE STRING "vita-makepkg branch name, commit id or tag")

Expand Down Expand Up @@ -416,13 +415,6 @@ list(APPEND compiler_target_tools
CXX_FOR_TARGET=${binutils_prefix}-g++
)

# Compilers used to build pthread-embedded (no need to override PATH with this)
list(APPEND pthread_tools
CC=${binutils_prefix}-gcc
CXX=${binutils_prefix}-g++
AR=${binutils_prefix}-ar
)

if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
# GCC on OSX (Clang in diguise) needs more bracket nesting depth to compile gcc
set(GCC_CFLAGS "${GCC_CFLAGS} -fbracket-depth=512")
Expand All @@ -444,7 +436,6 @@ set(common_gcc_configure_args
--disable-tls
--with-gnu-as
--with-gnu-ld
--with-newlib
--disable-multilib
--with-arch=armv7-a
--with-tune=cortex-a9
Expand All @@ -458,7 +449,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
list(APPEND common_gcc_configure_args "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
endif()

# Build a basic gcc compiler, needed to compile newlib
# Build a basic gcc compiler, needed to compile musl
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
Expand All @@ -474,6 +465,7 @@ ExternalProject_add(gcc-base
--libdir=${toolchain_build_install_dir}/lib
--libexecdir=${toolchain_build_install_dir}/lib
--with-sysroot=${toolchain_build_install_dir}/${target_arch}
--with-native-system-header-dir=/include
--with-gmp=${toolchain_build_depends_dir}
--with-mpfr=${toolchain_build_depends_dir}
--with-mpc=${toolchain_build_depends_dir}
Expand Down Expand Up @@ -514,38 +506,36 @@ ExternalProject_add(vita-headers
${UPDATE_DISCONNECTED_SUPPORT}
)

ExternalProject_Add(newlib
ExternalProject_Add(musl
DEPENDS binutils_${target_suffix} gcc-base vita-headers
GIT_REPOSITORY https://github.com/vitasdk/newlib
GIT_TAG ${NEWLIB_TAG}
GIT_REPOSITORY https://github.com/DaveeFTW/musl
GIT_TAG ${MUSL_TAG}
${GIT_SHALLOW_SUPPORT}
# Pass the compiler_target_tools here so newlib picks up the fresh gcc-base compiler
CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools} ${compiler_target_tools}
${wrapper_command} <SOURCE_DIR>/configure "CFLAGS_FOR_TARGET=-g -O2 -ffunction-sections -fdata-sections"
# Pass the compiler_target_tools here so musl picks up the fresh gcc-base compiler
CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools} ${compiler_target_tools} "CC=${binutils_prefix}-gcc" "CROSS_COMPILE=${binutils_prefix}-"
${wrapper_command} <SOURCE_DIR>/configure "CFLAGS=-g -O2 -ffunction-sections -fdata-sections -DSYSCALL_NO_INLINE -I${CMAKE_INSTALL_PREFIX}/${target_arch}/include"
--build=${build_native}
--host=${host_native}
--target=${target_arch}
# Use this prefix so the install target can be run twice with different paths
--prefix=/
--with-build-sysroot=${CMAKE_INSTALL_PREFIX}/${target_arch}
--enable-newlib-io-long-long
--enable-newlib-register-fini
--disable-newlib-supplied-syscalls
--disable-nls
--disable-shared
BUILD_COMMAND ${compiler_flags} ${toolchain_tools} ${wrapper_command} $(MAKE)
INSTALL_COMMAND $(MAKE) install DESTDIR=${CMAKE_INSTALL_PREFIX}
# Install a copy of newlib in the toolchain directory (required for pthread-embedded target)
INSTALL_COMMAND $(MAKE) install DESTDIR=${CMAKE_INSTALL_PREFIX}/${target_arch}
# Install a copy of musl in the toolchain directory (required for pthread-embedded target)
COMMAND $(MAKE) install DESTDIR=${toolchain_build_install_dir}
# Save the commit id for tracking purposes
COMMAND ${GIT_EXECUTABLE} -C <SOURCE_DIR> rev-parse HEAD > ${CMAKE_BINARY_DIR}/newlib-version.txt
COMMAND ${GIT_EXECUTABLE} -C <SOURCE_DIR> rev-parse HEAD > ${CMAKE_BINARY_DIR}/musl-version.txt
${UPDATE_DISCONNECTED_SUPPORT}
)

# Build a complete gcc compiler to be able to compile the full gcc for the host when crosscompiling.
# Using gcc-base doesn't work since is missing some headers.
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}
DEPENDS musl 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_HASH ${GCC_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
Expand Down Expand Up @@ -580,25 +570,9 @@ else()
set(GCC_DEPENDS gcc-base)
endif()

ExternalProject_Add(pthread-embedded
DEPENDS binutils_${target_suffix} gcc-base newlib vita-headers
GIT_REPOSITORY https://github.com/vitasdk/pthread-embedded
GIT_TAG ${PTHREAD_TAG}
${GIT_SHALLOW_SUPPORT}
# TODO: this project should have a proper makefile to support out-of-source builds
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ${compiler_flags} ${wrapper_command} $(MAKE)
-C <SOURCE_DIR>/platform/vita ${pthread_tools} PREFIX=${CMAKE_INSTALL_PREFIX}
INSTALL_COMMAND $(MAKE) -C <SOURCE_DIR>/platform/vita PREFIX=${CMAKE_INSTALL_PREFIX}/${target_arch} install
# Save the commit id for tracking purposes
COMMAND ${GIT_EXECUTABLE} -C <SOURCE_DIR> rev-parse HEAD > ${CMAKE_BINARY_DIR}/pthread-embedded-version.txt
${UPDATE_DISCONNECTED_SUPPORT}
)

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
DEPENDS musl ${GCC_DEPENDS}
URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
URL_HASH ${GCC_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
Expand All @@ -612,6 +586,8 @@ ExternalProject_add(gcc-final
--libdir=${CMAKE_INSTALL_PREFIX}/lib
--libexecdir=${CMAKE_INSTALL_PREFIX}/lib
--with-sysroot=${CMAKE_INSTALL_PREFIX}/${target_arch}
--with-build-sysroot=${CMAKE_INSTALL_PREFIX}/${target_arch}
--with-native-system-header-dir=/include
--with-gmp=${toolchain_target_depends_dir}
--with-mpfr=${toolchain_target_depends_dir}
--with-mpc=${toolchain_target_depends_dir}
Expand Down Expand Up @@ -722,13 +698,13 @@ set(version_info_file ${CMAKE_INSTALL_PREFIX}/version_info.txt)
add_custom_command(OUTPUT ${version_info_file}
COMMAND ${CMAKE_COMMAND} -DINPUT_DIR=${CMAKE_BINARY_DIR} -DOUTPUT_FILE=${version_info_file}
-P ${CMAKE_SOURCE_DIR}/cmake/create_version.cmake
DEPENDS vita-headers vita-toolchain_${target_suffix} newlib pthread-embedded samples
DEPENDS vita-headers vita-toolchain_${target_suffix} musl samples
COMMENT "Creating version_info.txt"
)

add_custom_command(OUTPUT "vitasdk-${host_native}-${build_date}.tar.bz2"
COMMAND ${CMAKE_COMMAND} -E tar "cfvj" "vitasdk-${host_native}-${build_date}.tar.bz2" "${CMAKE_INSTALL_PREFIX}"
DEPENDS vita-toolchain_${target_suffix} binutils_${target_suffix} gdb_${target_suffix} vita-headers newlib pthread-embedded samples vdpm vita-makepkg
DEPENDS vita-toolchain_${target_suffix} binutils_${target_suffix} gdb_${target_suffix} vita-headers musl samples vdpm vita-makepkg
DEPENDS gcc-final ${version_info_file}
COMMENT "Creating vitasdk-${host_os}-${build_date}.tar.bz2"
)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ You can pass then on the cmake phrase like this `cmake .. -DFOO=ON`.

If you want to fetch an specific revision of a part of the toolchain
then you can pass the branch/tag/id from the command line. The available
values are `NEWLIB_TAG`, `TOOLCHAIN_TAG`, `PTHREAD_TAG`, `HEADERS_TAG`
values are `MUSL_TAG`, `TOOLCHAIN_TAG`, `HEADERS_TAG`
and `SAMPLES_TAG`. For example:

``` sh
cmake /path/to/cmakelists -DNEWLIB_TAG=0254c2dc0c2686f69580030af3cacc795c94d616
cmake /path/to/cmakelists -DMUSL_TAG=0254c2dc0c2686f69580030af3cacc795c94d616
```

This will configure the vitasdk to use that newlib commit instead of the `vita` branch.
This will configure the vitasdk to use that musl commit instead of the `vita` branch.

If you need to change the download directory used for the tarballs then do the following,
for example:
Expand Down
6 changes: 2 additions & 4 deletions cmake/create_version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S" UTC)

file(READ ${INPUT_DIR}/vita-toolchain-version.txt _toolchain_sha1)
file(READ ${INPUT_DIR}/vita-headers-version.txt _headers_sha1)
file(READ ${INPUT_DIR}/newlib-version.txt _newlib_sha1)
file(READ ${INPUT_DIR}/pthread-embedded-version.txt _pthread_sha1)
file(READ ${INPUT_DIR}/musl-version.txt _musl_sha1)
file(READ ${INPUT_DIR}/samples-version.txt _samples_sha1)

file(WRITE ${OUTPUT_FILE} "Built at ${BUILD_DATE}\n")
file(APPEND ${OUTPUT_FILE} "newlib ${_newlib_sha1}")
file(APPEND ${OUTPUT_FILE} "pthread-embedded ${_pthread_sha1}")
file(APPEND ${OUTPUT_FILE} "musl ${_musl_sha1}")
file(APPEND ${OUTPUT_FILE} "samples ${_samples_sha1}")
file(APPEND ${OUTPUT_FILE} "vita-headers ${_headers_sha1}")
file(APPEND ${OUTPUT_FILE} "vita-toolchain ${_toolchain_sha1}")
46 changes: 45 additions & 1 deletion patches/gcc/0001-gcc-8.patch
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,51 @@ index 4f57765b0..a4d5ffb14 100644
+#undef LIB_SPEC
#ifndef LIB_SPEC
-#define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
+#define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}} -lSceRtc_stub -lSceSysmem_stub -lSceKernelThreadMgr_stub -lSceKernelModulemgr_stub -lSceIofilemgr_stub -lSceProcessmgr_stub -lSceLibKernel_stub -lSceNet_stub"
+#define LIB_SPEC "%{!shared:%{g*:-lc} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}} -lSceRtc_stub -lSceSysmem_stub -lSceKernelThreadMgr_stub -lSceKernelModulemgr_stub -lSceIofilemgr_stub -lSceProcessmgr_stub -lSceLibKernel_stub -lSceNet_stub"
#endif

/* When using -fsplit-stack we need to wrap pthread_create, in order

diff -ru a/libstdc++-v3/configure b/libstdc++-v3/configure
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -5369,13 +5369,6 @@ $as_echo "$as_me: OS config directory is $os_include_dir" >&6;}



-# Libtool setup.
-if test "x${with_newlib}" != "xyes"; then
- enable_dlopen=yes
-
-
-
-fi
case `pwd` in
*\ * | *\ *)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5

diff -ru a/libstdc++-v3/configure b/libstdc++-v3/configure
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -48457,7 +48457,7 @@
;;
esac
;;
- *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-cygwin* | *-solaris*)
+ *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-cygwin* | *-solaris* | arm-vita-eabi*)

# All these tests are for C++; save the language and the compiler flags.
# The CXXFLAGS thing is suspicious, but based on similar bits previously

diff -ru a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h
--- a/gcc/config/arm/unknown-elf.h
+++ b/gcc/config/arm/unknown-elf.h
@@ -29,7 +29,7 @@
#endif

/* Now we define the strings used to build the spec file. */
-#define UNKNOWN_ELF_STARTFILE_SPEC " crti%O%s crtbegin%O%s crt0%O%s"
+#define UNKNOWN_ELF_STARTFILE_SPEC " crti%O%s crtbegin%O%s crt1%O%s"

#undef STARTFILE_SPEC
#define STARTFILE_SPEC \