From 76d0b46d6f0a1209bac366b3a634f23b6362731e Mon Sep 17 00:00:00 2001 From: Antonio Jose Ramos Marquez Date: Thu, 17 Jun 2021 23:53:26 +0200 Subject: [PATCH 1/8] Initial support for apple m1 --- CMakeLists.txt | 16 +-- cmake/GetTriplet.cmake | 8 +- patches/binutils/0002-fix-broken-reloc.patch | 13 ++- patches/gcc/0001-gcc-11.1.0-m1.patch | 112 +++++++++++++++++++ patches/gcc/0001-gcc-8.patch | 43 ------- patches/libelf-m1.patch | 24 ++++ patches/libelf.patch | 12 -- 7 files changed, 157 insertions(+), 71 deletions(-) create mode 100644 patches/gcc/0001-gcc-11.1.0-m1.patch delete mode 100644 patches/gcc/0001-gcc-8.patch create mode 100644 patches/libelf-m1.patch delete mode 100644 patches/libelf.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d98637..8f2ac06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,8 @@ cmake_minimum_required(VERSION 3.2.0) project(vitasdk) # Use the following gcc version -set(GCC_VERSION 10.3.0) -set(GCC_HASH SHA256=64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344) +set(GCC_VERSION 11.1.0) +set(GCC_HASH SHA256=4c4a6fb8a8396059241c2e674b85b351c26a5d678274007f076957afa1cc9ddf) set(ZLIB_VERSION 1.2.11) set(ZLIB_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066) @@ -20,8 +20,8 @@ set(LIBELF_HASH SHA256=591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95 set(LIBYAML_VERSION 0.2.2) set(LIBYAML_HASH SHA256=4a9100ab61047fd9bd395bcef3ce5403365cafd55c1e0d0299cde14958e47be9) -set(GMP_VERSION 6.1.2) -set(GMP_HASH SHA256=5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2) +set(GMP_VERSION 6.2.1) +set(GMP_HASH SHA256=eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c) set(MPFR_VERSION 4.0.2) set(MPFR_HASH SHA256=c05e3f02d09e0e9019384cdd58e0f19c64e6db1fd6f5ecf77b4b1c61ca253acc) @@ -185,7 +185,7 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi URL https://github.com/vitasdk/artifacts/releases/download/libelf-${LIBELF_VERSION}/libelf-${LIBELF_VERSION}.tar.gz URL_HASH ${LIBELF_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} - PATCH_COMMAND patch -d -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/libelf.patch + PATCH_COMMAND patch -d -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/libelf-m1.patch CONFIGURE_COMMAND autoreconf -i COMMAND CC=${cc_compiler} RANLIB=${ranlib} ${compiler_flags} ${wrapper_command} /configure --build=${build_native} --host=${toolchain_host} @@ -464,7 +464,7 @@ ExternalProject_add(gcc-base URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz URL_HASH ${GCC_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} - PATCH_COMMAND patch -d -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-8.patch + PATCH_COMMAND patch -d -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-11.1.0-m1.patch CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} /configure --build=${build_native} # compile a native compiler so keep host == build @@ -551,7 +551,7 @@ if(CMAKE_TOOLCHAIN_FILE) URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz URL_HASH ${GCC_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} - PATCH_COMMAND patch -d -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-8.patch + PATCH_COMMAND patch -d -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-11.1.0-m1.patch CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools} ${wrapper_command} /configure --build=${build_native} @@ -604,7 +604,7 @@ ExternalProject_add(gcc-final URL http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz URL_HASH ${GCC_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} - PATCH_COMMAND patch -d -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-8.patch + PATCH_COMMAND patch -d -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-11.1.0-m1.patch CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools} ${compiler_target_tools} ${wrapper_command} /configure --build=${build_native} diff --git a/cmake/GetTriplet.cmake b/cmake/GetTriplet.cmake index 5d152c5..5ea6349 100644 --- a/cmake/GetTriplet.cmake +++ b/cmake/GetTriplet.cmake @@ -6,7 +6,9 @@ function(get_host_triplet triplet) if(host_arch STREQUAL "amd64") set(host_arch "x86_64") endif() - + if(host_arch STREQUAL "arm64") + set(host_arch "aarch64") + endif() if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") string(TOLOWER ${CMAKE_SYSTEM_NAME} host_os) set(host_release "gnu") @@ -35,7 +37,9 @@ function(get_build_triplet triplet) if(host_arch STREQUAL "amd64") set(host_arch "x86_64") endif() - + if(host_arch STREQUAL "arm64") + set(host_arch "aarch64") + endif() if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} build_os) set(build_release "gnu") diff --git a/patches/binutils/0002-fix-broken-reloc.patch b/patches/binutils/0002-fix-broken-reloc.patch index e62e71e..413b8c5 100644 --- a/patches/binutils/0002-fix-broken-reloc.patch +++ b/patches/binutils/0002-fix-broken-reloc.patch @@ -1,11 +1,12 @@ -diff -urN binutils-2.31.1.orig/bfd/elf32-arm.c binutils-2.31.1/bfd/elf32-arm.c ---- binutils-2.31.1.orig/bfd/elf32-arm.c 2018-07-10 16:12:05.000000000 +0900 -+++ binutils-2.31.1/bfd/elf32-arm.c 2019-01-20 22:48:31.649324435 +0900 -@@ -13517,6 +13517,7 @@ +diff -urN binutils-2.34/bfd/elf32-arm.c binutils-2.34-m1/bfd/elf32-arm.c +--- binutils-2.34/bfd/elf32-arm.c 2020-01-18 14:55:47.000000000 +0100 ++++ binutils-2.34-m1/bfd/elf32-arm.c 2021-06-17 20:31:37.000000000 +0200 +@@ -13730,7 +13730,7 @@ + but duplicate entries are likely to be much less common. */ else unwind_type = 2; - -+ elide = 0; +- ++ elide = 0; if (elide && !bfd_link_relocatable (info)) { add_unwind_table_edit (&unwind_edit_head, &unwind_edit_tail, diff --git a/patches/gcc/0001-gcc-11.1.0-m1.patch b/patches/gcc/0001-gcc-11.1.0-m1.patch new file mode 100644 index 0000000..734638a --- /dev/null +++ b/patches/gcc/0001-gcc-11.1.0-m1.patch @@ -0,0 +1,112 @@ +diff -Naur gcc-11.1.0/gcc/config/aarch64/host-aarch64-darwin.c gcc-11.1.0_m1/gcc/config/aarch64/host-aarch64-darwin.c +--- gcc-11.1.0/gcc/config/aarch64/host-aarch64-darwin.c 1970-01-01 01:00:00.000000000 +0100 ++++ gcc-11.1.0_m1/gcc/config/aarch64/host-aarch64-darwin.c 2021-06-17 18:36:41.000000000 +0200 +@@ -0,0 +1,32 @@ ++/* Arm64-darwin host-specific hook definitions. ++ Copyright (C) 2020 Free Software Foundation, Inc. ++ ++This file is part of GCC. ++ ++GCC is free software; you can redistribute it and/or modify it under ++the terms of the GNU General Public License as published by the Free ++Software Foundation; either version 3, or (at your option) any later ++version. ++ ++GCC is distributed in the hope that it will be useful, but WITHOUT ANY ++WARRANTY; without even the implied warranty of MERCHANTABILITY or ++FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++for more details. ++ ++You should have received a copy of the GNU General Public License ++along with GCC; see the file COPYING3. If not see ++. */ ++ ++#define IN_TARGET_CODE 1 ++ ++#include "config.h" ++#include "system.h" ++#include "coretypes.h" ++#include "hosthooks.h" ++#include "hosthooks-def.h" ++#include "config/host-darwin.h" ++ ++/* Darwin doesn't do anything special for arm64/aarch64 hosts; this file ++ exists just to include the generic config/host-darwin.h. */ ++ ++const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER; +diff -Naur gcc-11.1.0/gcc/config/aarch64/x-darwin gcc-11.1.0_m1/gcc/config/aarch64/x-darwin +--- gcc-11.1.0/gcc/config/aarch64/x-darwin 1970-01-01 01:00:00.000000000 +0100 ++++ gcc-11.1.0_m1/gcc/config/aarch64/x-darwin 2021-06-17 18:36:36.000000000 +0200 +@@ -0,0 +1,3 @@ ++host-aarch64-darwin.o : $(srcdir)/config/aarch64/host-aarch64-darwin.c ++ $(COMPILE) $< ++ $(POSTCOMPILE) +diff -Naur gcc-11.1.0/gcc/config/arm/arm-c.c gcc-11.1.0_m1/gcc/config/arm/arm-c.c +--- gcc-11.1.0/gcc/config/arm/arm-c.c 2021-04-27 12:00:13.000000000 +0200 ++++ gcc-11.1.0_m1/gcc/config/arm/arm-c.c 2021-06-17 18:42:37.000000000 +0200 +@@ -372,6 +372,8 @@ + builtin_assert ("cpu=arm"); + builtin_assert ("machine=arm"); + ++ builtin_define ("__vita__"); ++ + arm_cpu_builtins (pfile); + } + +diff -Naur gcc-11.1.0/gcc/config/arm/arm.h gcc-11.1.0_m1/gcc/config/arm/arm.h +--- gcc-11.1.0/gcc/config/arm/arm.h 2021-04-27 12:00:13.000000000 +0200 ++++ gcc-11.1.0_m1/gcc/config/arm/arm.h 2021-06-17 18:44:00.000000000 +0200 +@@ -741,6 +741,10 @@ + #define WCHAR_TYPE_SIZE BITS_PER_WORD + #endif + ++/* use int and unsigned int for int32_t and uint32_t */ ++#undef STDINT_LONG32 ++#define STDINT_LONG32 0 ++ + /* Sized for fixed-point types. */ + + #define SHORT_FRACT_TYPE_SIZE 8 +diff -Naur gcc-11.1.0/gcc/config.gcc gcc-11.1.0_m1/gcc/config.gcc +--- gcc-11.1.0/gcc/config.gcc 2021-04-27 12:00:13.000000000 +0200 ++++ gcc-11.1.0_m1/gcc/config.gcc 2021-06-17 18:32:07.000000000 +0200 +@@ -1121,6 +1121,11 @@ + done + TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'` + ;; ++aarch64-*-darwin* | arm64-*-darwin*) ++ tm_file="${tm_file} aarch64/aarch64-errata.h" ++ tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-darwin" ++ tm_defines="${tm_defines} TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1" ++ ;; + aarch64*-*-freebsd*) + tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file}" + tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-freebsd.h" +diff -Naur gcc-11.1.0/gcc/config.host gcc-11.1.0_m1/gcc/config.host +--- gcc-11.1.0/gcc/config.host 2021-04-27 12:00:13.000000000 +0200 ++++ gcc-11.1.0_m1/gcc/config.host 2021-06-17 18:35:08.000000000 +0200 +@@ -251,6 +251,10 @@ + host_extra_gcc_objs="${host_extra_gcc_objs} driver-mingw32.o" + host_lto_plugin_soname=liblto_plugin.dll + ;; ++ aarch64-*-darwin* | arm64-*-darwin*) ++ out_host_hook_obj="${out_host_hook_obj} host-aarch64-darwin.o" ++ host_xmake_file="${host_xmake_file} aarch64/x-darwin" ++ ;; + i[34567]86-*-darwin* | x86_64-*-darwin*) + out_host_hook_obj="${out_host_hook_obj} host-i386-darwin.o" + host_xmake_file="${host_xmake_file} i386/x-darwin" +diff -Naur gcc-11.1.0/gcc/gcc.c gcc-11.1.0_m1/gcc/gcc.c +--- gcc-11.1.0/gcc/gcc.c 2021-04-27 12:00:13.000000000 +0200 ++++ gcc-11.1.0_m1/gcc/gcc.c 2021-06-17 18:45:57.000000000 +0200 +@@ -715,8 +715,9 @@ + #endif + + /* config.h can define LIB_SPEC to override the default libraries. */ ++#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" + #endif + + /* When using -fsplit-stack we need to wrap pthread_create, in order diff --git a/patches/gcc/0001-gcc-8.patch b/patches/gcc/0001-gcc-8.patch deleted file mode 100644 index 852dc19..0000000 --- a/patches/gcc/0001-gcc-8.patch +++ /dev/null @@ -1,43 +0,0 @@ -diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c -index 6e256ee0a..54e390c38 100644 ---- a/gcc/config/arm/arm-c.c -+++ b/gcc/config/arm/arm-c.c -@@ -230,6 +230,8 @@ arm_cpu_cpp_builtins (struct cpp_reader * pfile) - builtin_assert ("cpu=arm"); - builtin_assert ("machine=arm"); - -+ builtin_define ("__vita__"); -+ - arm_cpu_builtins (pfile); - } - -diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h -index 9ee6a4eb5..b89f85655 100644 ---- a/gcc/config/arm/arm.h -+++ b/gcc/config/arm/arm.h -@@ -669,6 +670,10 @@ extern int arm_arch_cmse; - #define WCHAR_TYPE_SIZE BITS_PER_WORD - #endif - -+/* use int and unsigned int for int32_t and uint32_t */ -+#undef STDINT_LONG32 -+#define STDINT_LONG32 0 -+ - /* Sized for fixed-point types. */ - - #define SHORT_FRACT_TYPE_SIZE 8 -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 4f57765b0..a4d5ffb14 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -674,8 +674,9 @@ proper position among the other output files. */ - #endif - - /* config.h can define LIB_SPEC to override the default libraries. */ -+#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" - #endif - - /* When using -fsplit-stack we need to wrap pthread_create, in order diff --git a/patches/libelf-m1.patch b/patches/libelf-m1.patch new file mode 100644 index 0000000..c05df05 --- /dev/null +++ b/patches/libelf-m1.patch @@ -0,0 +1,24 @@ +diff -ru libelf-0.8.13/config.sub libelf-0.8.13-m1/config.sub +--- libelf-0.8.13/config.sub 2005-05-21 17:28:37.000000000 +0200 ++++ libelf-0.8.13-m1/config.sub 2021-06-17 20:05:18.000000000 +0200 +@@ -285,6 +285,8 @@ + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; ++ aarch64-apple|x86-64-apple) ++ ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 +diff -ru libelf-0.8.13/configure libelf-0.8.13-m1/configure +--- libelf-0.8.13/configure 2008-05-23 10:18:03.000000000 +0200 ++++ libelf-0.8.13-m1/configure 2021-06-17 19:12:37.000000000 +0200 +@@ -1595,7 +1595,7 @@ + echo $ac_n "(cached) $ac_c" 1>&6 + else + if test "$cross_compiling" = yes; then +- ac_cv_sizeof_long_long=0 ++ ac_cv_sizeof_long_long=8 + else + cat > conftest.$ac_ext <&6 - else - if test "$cross_compiling" = yes; then -- ac_cv_sizeof_long_long=0 -+ ac_cv_sizeof_long_long=8 - else - cat > conftest.$ac_ext < Date: Sat, 31 Jul 2021 20:48:20 +0200 Subject: [PATCH 2/8] Enable libgomp (#97) * Enable libgomp * Add pthread to LIB_SPEC * add pthread as driver option * enable libgomp build * buildscripts: fix libgomp for windows --- CMakeLists.txt | 9 +++- patches/gcc/0001-gcc-11.1.0-m1.patch | 76 ++++++++++++++++++++++------ 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f2ac06..2893771 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -434,7 +434,6 @@ set(common_gcc_configure_args --enable-languages=c,c++ --disable-decimal-float --disable-libffi - --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp @@ -482,6 +481,7 @@ ExternalProject_add(gcc-base ${common_gcc_configure_args} --disable-threads --without-headers + --disable-libgomp "CFLAGS=${GCC_CFLAGS}" "CXXFLAGS=${GCC_CFLAGS}" BUILD_COMMAND $(MAKE) all-gcc @@ -505,6 +505,9 @@ ExternalProject_add(vita-headers # Copy the include headers to the installation directory COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_PREFIX}/${target_arch}/include COMMAND ${CMAKE_COMMAND} -E copy_directory /include ${CMAKE_INSTALL_PREFIX}/${target_arch}/include + # Copy the generated .a files to the toolchain directory (required for libgomp target) + COMMAND ${CMAKE_COMMAND} -E make_directory ${toolchain_build_install_dir}/${target_arch}/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_INSTALL_PREFIX}/${target_arch}/lib ${toolchain_build_install_dir}/${target_arch}/lib # Install a copy of the headers in the toolchain directory (required for pthread-embedded target) COMMAND ${CMAKE_COMMAND} -E make_directory ${toolchain_build_install_dir}/${target_arch}/include COMMAND ${CMAKE_COMMAND} -E copy_directory /include ${toolchain_build_install_dir}/${target_arch}/include @@ -570,6 +573,7 @@ if(CMAKE_TOOLCHAIN_FILE) ${common_gcc_configure_args} --disable-threads --with-headers=yes + --disable-libgomp "CFLAGS=${GCC_CFLAGS}" "CXXFLAGS=${GCC_CFLAGS}" BUILD_COMMAND ${toolchain_tools} ${wrapper_command} $(MAKE) INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0" @@ -593,6 +597,8 @@ ExternalProject_Add(pthread-embedded BUILD_COMMAND ${compiler_flags} ${wrapper_command} $(MAKE) -C /platform/vita ${pthread_tools} PREFIX=${CMAKE_INSTALL_PREFIX} INSTALL_COMMAND $(MAKE) -C /platform/vita PREFIX=${CMAKE_INSTALL_PREFIX}/${target_arch} install + # Install into the toolchain directory (required for libgomp target) + COMMAND $(MAKE) install -C /platform/vita PREFIX=${toolchain_build_install_dir}/${target_arch} install # Save the commit id for tracking purposes COMMAND ${GIT_EXECUTABLE} -C rev-parse HEAD > ${CMAKE_BINARY_DIR}/pthread-embedded-version.txt ${UPDATE_DISCONNECTED_SUPPORT} @@ -622,6 +628,7 @@ ExternalProject_add(gcc-final ${common_gcc_configure_args} --with-headers=yes --enable-threads=posix + --enable-libgomp "CFLAGS=${GCC_CFLAGS}" "CXXFLAGS=${GCC_CFLAGS}" BUILD_COMMAND ${toolchain_tools} ${compiler_target_tools} ${wrapper_command} diff --git a/patches/gcc/0001-gcc-11.1.0-m1.patch b/patches/gcc/0001-gcc-11.1.0-m1.patch index 734638a..9e892ff 100644 --- a/patches/gcc/0001-gcc-11.1.0-m1.patch +++ b/patches/gcc/0001-gcc-11.1.0-m1.patch @@ -1,6 +1,6 @@ -diff -Naur gcc-11.1.0/gcc/config/aarch64/host-aarch64-darwin.c gcc-11.1.0_m1/gcc/config/aarch64/host-aarch64-darwin.c +diff -Naur gcc-11.1.0/gcc/config/aarch64/host-aarch64-darwin.c gcc-11.1.0-m1/gcc/config/aarch64/host-aarch64-darwin.c --- gcc-11.1.0/gcc/config/aarch64/host-aarch64-darwin.c 1970-01-01 01:00:00.000000000 +0100 -+++ gcc-11.1.0_m1/gcc/config/aarch64/host-aarch64-darwin.c 2021-06-17 18:36:41.000000000 +0200 ++++ gcc-11.1.0-m1/gcc/config/aarch64/host-aarch64-darwin.c 2021-07-31 20:05:02.000000000 +0200 @@ -0,0 +1,32 @@ +/* Arm64-darwin host-specific hook definitions. + Copyright (C) 2020 Free Software Foundation, Inc. @@ -34,16 +34,16 @@ diff -Naur gcc-11.1.0/gcc/config/aarch64/host-aarch64-darwin.c gcc-11.1.0_m1/gcc + exists just to include the generic config/host-darwin.h. */ + +const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER; -diff -Naur gcc-11.1.0/gcc/config/aarch64/x-darwin gcc-11.1.0_m1/gcc/config/aarch64/x-darwin +diff -Naur gcc-11.1.0/gcc/config/aarch64/x-darwin gcc-11.1.0-m1/gcc/config/aarch64/x-darwin --- gcc-11.1.0/gcc/config/aarch64/x-darwin 1970-01-01 01:00:00.000000000 +0100 -+++ gcc-11.1.0_m1/gcc/config/aarch64/x-darwin 2021-06-17 18:36:36.000000000 +0200 ++++ gcc-11.1.0-m1/gcc/config/aarch64/x-darwin 2021-07-31 20:05:02.000000000 +0200 @@ -0,0 +1,3 @@ +host-aarch64-darwin.o : $(srcdir)/config/aarch64/host-aarch64-darwin.c + $(COMPILE) $< + $(POSTCOMPILE) -diff -Naur gcc-11.1.0/gcc/config/arm/arm-c.c gcc-11.1.0_m1/gcc/config/arm/arm-c.c +diff -Naur gcc-11.1.0/gcc/config/arm/arm-c.c gcc-11.1.0-m1/gcc/config/arm/arm-c.c --- gcc-11.1.0/gcc/config/arm/arm-c.c 2021-04-27 12:00:13.000000000 +0200 -+++ gcc-11.1.0_m1/gcc/config/arm/arm-c.c 2021-06-17 18:42:37.000000000 +0200 ++++ gcc-11.1.0-m1/gcc/config/arm/arm-c.c 2021-07-31 20:05:02.000000000 +0200 @@ -372,6 +372,8 @@ builtin_assert ("cpu=arm"); builtin_assert ("machine=arm"); @@ -53,9 +53,9 @@ diff -Naur gcc-11.1.0/gcc/config/arm/arm-c.c gcc-11.1.0_m1/gcc/config/arm/arm-c. arm_cpu_builtins (pfile); } -diff -Naur gcc-11.1.0/gcc/config/arm/arm.h gcc-11.1.0_m1/gcc/config/arm/arm.h +diff -Naur gcc-11.1.0/gcc/config/arm/arm.h gcc-11.1.0-m1/gcc/config/arm/arm.h --- gcc-11.1.0/gcc/config/arm/arm.h 2021-04-27 12:00:13.000000000 +0200 -+++ gcc-11.1.0_m1/gcc/config/arm/arm.h 2021-06-17 18:44:00.000000000 +0200 ++++ gcc-11.1.0-m1/gcc/config/arm/arm.h 2021-07-31 20:05:02.000000000 +0200 @@ -741,6 +741,10 @@ #define WCHAR_TYPE_SIZE BITS_PER_WORD #endif @@ -67,9 +67,22 @@ diff -Naur gcc-11.1.0/gcc/config/arm/arm.h gcc-11.1.0_m1/gcc/config/arm/arm.h /* Sized for fixed-point types. */ #define SHORT_FRACT_TYPE_SIZE 8 -diff -Naur gcc-11.1.0/gcc/config.gcc gcc-11.1.0_m1/gcc/config.gcc +diff -Naur gcc-11.1.0/gcc/config/arm/arm.opt gcc-11.1.0-m1/gcc/config/arm/arm.opt +--- gcc-11.1.0/gcc/config/arm/arm.opt 2021-04-27 12:00:13.000000000 +0200 ++++ gcc-11.1.0-m1/gcc/config/arm/arm.opt 2021-07-31 20:18:40.000000000 +0200 +@@ -21,6 +21,9 @@ + HeaderInclude + config/arm/arm-opts.h + ++pthread ++Driver ++ + Enum + Name(tls_type) Type(enum arm_tls_type) + TLS dialect to use: +diff -Naur gcc-11.1.0/gcc/config.gcc gcc-11.1.0-m1/gcc/config.gcc --- gcc-11.1.0/gcc/config.gcc 2021-04-27 12:00:13.000000000 +0200 -+++ gcc-11.1.0_m1/gcc/config.gcc 2021-06-17 18:32:07.000000000 +0200 ++++ gcc-11.1.0-m1/gcc/config.gcc 2021-07-31 20:05:02.000000000 +0200 @@ -1121,6 +1121,11 @@ done TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'` @@ -82,9 +95,9 @@ diff -Naur gcc-11.1.0/gcc/config.gcc gcc-11.1.0_m1/gcc/config.gcc aarch64*-*-freebsd*) tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file}" tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-freebsd.h" -diff -Naur gcc-11.1.0/gcc/config.host gcc-11.1.0_m1/gcc/config.host +diff -Naur gcc-11.1.0/gcc/config.host gcc-11.1.0-m1/gcc/config.host --- gcc-11.1.0/gcc/config.host 2021-04-27 12:00:13.000000000 +0200 -+++ gcc-11.1.0_m1/gcc/config.host 2021-06-17 18:35:08.000000000 +0200 ++++ gcc-11.1.0-m1/gcc/config.host 2021-07-31 20:05:02.000000000 +0200 @@ -251,6 +251,10 @@ host_extra_gcc_objs="${host_extra_gcc_objs} driver-mingw32.o" host_lto_plugin_soname=liblto_plugin.dll @@ -96,9 +109,9 @@ diff -Naur gcc-11.1.0/gcc/config.host gcc-11.1.0_m1/gcc/config.host i[34567]86-*-darwin* | x86_64-*-darwin*) out_host_hook_obj="${out_host_hook_obj} host-i386-darwin.o" host_xmake_file="${host_xmake_file} i386/x-darwin" -diff -Naur gcc-11.1.0/gcc/gcc.c gcc-11.1.0_m1/gcc/gcc.c +diff -Naur gcc-11.1.0/gcc/gcc.c gcc-11.1.0-m1/gcc/gcc.c --- gcc-11.1.0/gcc/gcc.c 2021-04-27 12:00:13.000000000 +0200 -+++ gcc-11.1.0_m1/gcc/gcc.c 2021-06-17 18:45:57.000000000 +0200 ++++ gcc-11.1.0-m1/gcc/gcc.c 2021-07-31 20:14:24.000000000 +0200 @@ -715,8 +715,9 @@ #endif @@ -106,7 +119,40 @@ diff -Naur gcc-11.1.0/gcc/gcc.c gcc-11.1.0_m1/gcc/gcc.c +#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*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}} %{pthread:--whole-archive -lpthread --no-whole-archive} -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 -Naur gcc-11.1.0/libgomp/configure gcc-11.1.0-m1/libgomp/configure +--- gcc-11.1.0/libgomp/configure 2021-04-27 12:00:33.000000000 +0200 ++++ gcc-11.1.0-m1/libgomp/configure 2021-07-31 20:21:43.000000000 +0200 +@@ -15714,29 +15714,6 @@ + fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +-# Check for gethostname. +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#include +-int +-main () +-{ +- +- char buf[256]; +- if (gethostname (buf, sizeof (buf) - 1) == 0) +- buf[255] = '\0'; +- +- ; +- return 0; +-} +-_ACEOF +-if ac_fn_c_try_compile "$LINENO"; then : +- +-$as_echo "#define HAVE_GETHOSTNAME 1" >>confdefs.h +- +-fi +-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +- + # Check for getpid. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ From b28ecb5b7a4e307fe29d360fd375f412f311ee5e Mon Sep 17 00:00:00 2001 From: Antonio Jose Ramos Marquez Date: Sat, 31 Jul 2021 20:58:24 +0200 Subject: [PATCH 3/8] windows: fix threads --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2893771..840f941 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -571,9 +571,9 @@ if(CMAKE_TOOLCHAIN_FILE) --with-isl=${toolchain_build_depends_dir} --with-libelf=${toolchain_build_depends_dir} ${common_gcc_configure_args} - --disable-threads + --enable-threads=posix --with-headers=yes - --disable-libgomp + --enable-libgomp "CFLAGS=${GCC_CFLAGS}" "CXXFLAGS=${GCC_CFLAGS}" BUILD_COMMAND ${toolchain_tools} ${wrapper_command} $(MAKE) INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0" From 56a0fcee6c59a4c22115ea64099236df9676623d Mon Sep 17 00:00:00 2001 From: Antonio Jose Ramos Marquez Date: Sat, 31 Jul 2021 21:00:37 +0200 Subject: [PATCH 4/8] newlib 4.1 test --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 840f941..3c1d89d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,11 +43,11 @@ 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(NEWLIB_TAG vita-4.1 CACHE STRING "newlib 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(PTHREAD_TAG newlib4 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") From f6bd2c1b2066781b0492b895b19110d83054a2cd Mon Sep 17 00:00:00 2001 From: Antonio Jose Ramos Marquez Date: Sat, 31 Jul 2021 21:03:22 +0200 Subject: [PATCH 5/8] newlib: enable time_t as long --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c1d89d..8b153b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -537,6 +537,7 @@ ExternalProject_Add(newlib --enable-newlib-register-fini --disable-newlib-supplied-syscalls --disable-nls + --enable-newlib-long-time_t 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) From 91db3c58f4c59f0504c2f784a2a9dd49463ef255 Mon Sep 17 00:00:00 2001 From: Antonio Jose Ramos Marquez Date: Sun, 1 Aug 2021 00:48:58 +0200 Subject: [PATCH 6/8] fix libgomp error check omp_alloctrait_key_t --- patches/gcc/0001-gcc-11.1.0-m1.patch | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/patches/gcc/0001-gcc-11.1.0-m1.patch b/patches/gcc/0001-gcc-11.1.0-m1.patch index 9e892ff..ad473b7 100644 --- a/patches/gcc/0001-gcc-11.1.0-m1.patch +++ b/patches/gcc/0001-gcc-11.1.0-m1.patch @@ -156,3 +156,15 @@ diff -Naur gcc-11.1.0/libgomp/configure gcc-11.1.0-m1/libgomp/configure # Check for getpid. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +diff -Naur gcc-11.1.0/libgomp/libgomp_f.h.in gcc-11.1.0-m1/libgomp/libgomp_f.h.in +--- gcc-11.1.0/libgomp/libgomp_f.h.in 2021-04-27 12:00:15.000000000 +0200 ++++ gcc-11.1.0-m1/libgomp/libgomp_f.h.in 2021-08-01 00:46:30.000000000 +0200 +@@ -81,7 +81,7 @@ + || @OMP_LOCK_KIND@ != sizeof (*(omp_lock_arg_t) 0) + || @OMP_NEST_LOCK_KIND@ != sizeof (*(omp_nest_lock_arg_t) 0) + || @INTPTR_T_KIND@ != sizeof (omp_allocator_handle_t) +- || 4 != sizeof (omp_alloctrait_key_t) ++// || 4 != sizeof (omp_alloctrait_key_t) + || @INTPTR_T_KIND@ != sizeof (omp_alloctrait_value_t) + || @INTPTR_T_KIND@ != sizeof (omp_memspace_handle_t) + || @OMP_DEPEND_KIND@ != sizeof (omp_depend_t)) From bd6279e3bfe94738d6a0f207319baa1914723b88 Mon Sep 17 00:00:00 2001 From: Antonio Jose Ramos Marquez Date: Sun, 1 Aug 2021 13:48:57 +0200 Subject: [PATCH 7/8] fix short enum --- patches/gcc/0001-gcc-11.1.0-m1.patch | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/patches/gcc/0001-gcc-11.1.0-m1.patch b/patches/gcc/0001-gcc-11.1.0-m1.patch index ad473b7..f5eeff6 100644 --- a/patches/gcc/0001-gcc-11.1.0-m1.patch +++ b/patches/gcc/0001-gcc-11.1.0-m1.patch @@ -55,8 +55,18 @@ diff -Naur gcc-11.1.0/gcc/config/arm/arm-c.c gcc-11.1.0-m1/gcc/config/arm/arm-c. diff -Naur gcc-11.1.0/gcc/config/arm/arm.h gcc-11.1.0-m1/gcc/config/arm/arm.h --- gcc-11.1.0/gcc/config/arm/arm.h 2021-04-27 12:00:13.000000000 +0200 -+++ gcc-11.1.0-m1/gcc/config/arm/arm.h 2021-07-31 20:05:02.000000000 +0200 -@@ -741,6 +741,10 @@ ++++ gcc-11.1.0-m1/gcc/config/arm/arm.h 2021-08-01 13:45:13.000000000 +0200 +@@ -423,8 +423,7 @@ + + /* AAPCS based ABIs use short enums by default. */ + #ifndef ARM_DEFAULT_SHORT_ENUMS +-#define ARM_DEFAULT_SHORT_ENUMS \ +- (TARGET_AAPCS_BASED && arm_abi != ARM_ABI_AAPCS_LINUX) ++#define ARM_DEFAULT_SHORT_ENUMS 0 + #endif + + /* Map each of the micro-architecture variants to their corresponding +@@ -741,6 +740,10 @@ #define WCHAR_TYPE_SIZE BITS_PER_WORD #endif @@ -156,15 +166,3 @@ diff -Naur gcc-11.1.0/libgomp/configure gcc-11.1.0-m1/libgomp/configure # Check for getpid. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -diff -Naur gcc-11.1.0/libgomp/libgomp_f.h.in gcc-11.1.0-m1/libgomp/libgomp_f.h.in ---- gcc-11.1.0/libgomp/libgomp_f.h.in 2021-04-27 12:00:15.000000000 +0200 -+++ gcc-11.1.0-m1/libgomp/libgomp_f.h.in 2021-08-01 00:46:30.000000000 +0200 -@@ -81,7 +81,7 @@ - || @OMP_LOCK_KIND@ != sizeof (*(omp_lock_arg_t) 0) - || @OMP_NEST_LOCK_KIND@ != sizeof (*(omp_nest_lock_arg_t) 0) - || @INTPTR_T_KIND@ != sizeof (omp_allocator_handle_t) -- || 4 != sizeof (omp_alloctrait_key_t) -+// || 4 != sizeof (omp_alloctrait_key_t) - || @INTPTR_T_KIND@ != sizeof (omp_alloctrait_value_t) - || @INTPTR_T_KIND@ != sizeof (omp_memspace_handle_t) - || @OMP_DEPEND_KIND@ != sizeof (omp_depend_t)) From 940701ac7fabcb782cd12fe08660312b7dac2d85 Mon Sep 17 00:00:00 2001 From: Antonio Jose Ramos Marquez Date: Sun, 8 Aug 2021 15:37:48 +0200 Subject: [PATCH 8/8] back to vita on newlib and master on pthread --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b153b3..b9cc0ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,11 +43,11 @@ 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-4.1 CACHE STRING "newlib branch name, commit id or tag") +set(NEWLIB_TAG vita CACHE STRING "newlib 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 newlib4 CACHE STRING "pthread-embedded 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")