Skip to content

Commit

Permalink
gcc: Update to 13.1.0.
Browse files Browse the repository at this point in the history
- This adds support for Apple Silicon hosts.
- The patch was renamed (and updated) to reflect the change.
- Add zstd support.
  • Loading branch information
FtZPetruska committed Jul 29, 2023
1 parent ef049f0 commit 6f7a1ce
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 40 deletions.
29 changes: 16 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ cmake_minimum_required(VERSION 3.7.0)
project(vitasdk)

# Use the following gcc version
set(GCC_VERSION 10.3.0)
set(GCC_HASH SHA256=64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344)
set(GCC_VERSION 13.1.0)
set(GCC_HASH SHA256=61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86)

set(ZLIB_VERSION 1.2.13)
set(ZLIB_HASH SHA256=d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da0540107fb98)
Expand Down Expand Up @@ -494,12 +494,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}
DEPENDS gmp_${build_suffix} mpfr_${build_suffix} mpc_${build_suffix} isl_${build_suffix} libelf_${build_suffix} zstd_${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}
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-10.patch
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-13-vita.patch
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${compiler_flag} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
# compile a native compiler so keep host == build
--host=${build_native}
Expand All @@ -513,6 +513,7 @@ ExternalProject_add(gcc-base
--with-mpc=${toolchain_build_depends_dir}
--with-isl=${toolchain_build_depends_dir}
--with-libelf=${toolchain_build_depends_dir}
--with-zstd=${toolchain_build_depends_dir}
${common_gcc_configure_args}
--disable-threads
--without-headers
Expand Down Expand Up @@ -592,12 +593,12 @@ ExternalProject_Add(newlib
# 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 newlib gmp_${build_suffix} mpfr_${build_suffix} mpc_${build_suffix} isl_${build_suffix} libelf_${build_suffix} zstd_${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}
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-10.patch
CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools}
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-13-vita.patch
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${compiler_flags} ${toolchain_tools}
${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
# compile a native compiler so keep host == build
Expand All @@ -612,13 +613,14 @@ if(CMAKE_TOOLCHAIN_FILE)
--with-mpc=${toolchain_build_depends_dir}
--with-isl=${toolchain_build_depends_dir}
--with-libelf=${toolchain_build_depends_dir}
--with-zstd=${toolchain_build_depends_dir}
${common_gcc_configure_args}
--enable-threads=posix
--with-headers=yes
--enable-libgomp
"CFLAGS=${GCC_CFLAGS}"
"CXXFLAGS=${GCC_CFLAGS}"
BUILD_COMMAND ${toolchain_tools} ${wrapper_command} $(MAKE) INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
BUILD_COMMAND ${CMAKE_COMMAND} -E env ${toolchain_tools} ${wrapper_command} $(MAKE) INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
INSTALL_COMMAND $(MAKE) install
)
# Add this target as dependency of the final gcc target
Expand Down Expand Up @@ -647,13 +649,13 @@ 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 gmp_${target_suffix} mpfr_${target_suffix} mpc_${target_suffix} isl_${target_suffix} libelf_${target_suffix} zstd_${target_suffix}
DEPENDS newlib ${GCC_DEPENDS} pthread-embedded
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 <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-10.patch
CONFIGURE_COMMAND ${compiler_flags} ${toolchain_tools} ${compiler_target_tools}
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/gcc/0001-gcc-13-vita.patch
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${compiler_flags} ${toolchain_tools} ${compiler_target_tools}
${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${host_native}
Expand All @@ -667,13 +669,14 @@ ExternalProject_add(gcc-final
--with-mpc=${toolchain_target_depends_dir}
--with-isl=${toolchain_target_depends_dir}
--with-libelf=${toolchain_target_depends_dir}
--with-zstd=${toolchain_target_depends_dir}
${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}
BUILD_COMMAND ${CMAKE_COMMAND} -E env ${toolchain_tools} ${compiler_target_tools} ${wrapper_command}
$(MAKE) INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
INSTALL_COMMAND $(MAKE) install
# Remove gcc docs to reduce size
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c
index 7468a20bd..3496590c4 100644
--- a/gcc/config/arm/arm-c.c
+++ b/gcc/config/arm/arm-c.c
@@ -372,6 +372,8 @@ arm_cpu_cpp_builtins (struct cpp_reader * pfile)
diff --git a/gcc/config/arm/arm-c.cc b/gcc/config/arm/arm-c.cc
index 59c0d8c..6468c67 100644
--- a/gcc/config/arm/arm-c.cc
+++ b/gcc/config/arm/arm-c.cc
@@ -415,6 +415,7 @@ 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 30e1d6dc9..bd5f7b19c 100644
index 7d40b8b..a9b9f55 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -731,6 +731,10 @@ extern const int arm_arch_cde_coproc_bits[];
@@ -744,6 +744,10 @@ extern const int arm_arch_cde_coproc_bits[];
#define WCHAR_TYPE_SIZE BITS_PER_WORD
#endif

Expand All @@ -26,7 +25,7 @@ index 30e1d6dc9..bd5f7b19c 100644
/* Sized for fixed-point types. */

#define SHORT_FRACT_TYPE_SIZE 8
@@ -1996,7 +2000,7 @@ enum arm_auto_incmodes
@@ -2116,7 +2120,7 @@ enum arm_auto_incmodes
/* signed 'char' is most compatible, but RISC OS wants it unsigned.
unsigned is probably best, but may break some code. */
#ifndef DEFAULT_SIGNED_CHAR
Expand All @@ -36,24 +35,24 @@ index 30e1d6dc9..bd5f7b19c 100644

/* Max number of bytes we can move from memory to memory
diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt
index cd3d8e1be..523b92aa1 100644
index 3a49b51..840b2b3 100644
--- a/gcc/config/arm/arm.opt
+++ b/gcc/config/arm/arm.opt
@@ -30,6 +30,9 @@ const char *x_arm_cpu_string
TargetSave
const char *x_arm_tune_string
@@ -33,6 +33,9 @@ unsigned aarch_enable_bti = 0
TargetVariable
enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A

+pthread
+Driver
+
Enum
Name(tls_type) Type(enum arm_tls_type)
TLS dialect to use:
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 9f790db0d..27a38bb02 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -673,8 +673,9 @@ proper position among the other output files. */
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 16bb07f..8c440dc 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -732,8 +732,9 @@ proper position among the other output files. */
#endif

/* config.h can define LIB_SPEC to override the default libraries. */
Expand All @@ -64,10 +63,10 @@ index 9f790db0d..27a38bb02 100644
#endif

/* When using -fsplit-stack we need to wrap pthread_create, in order
diff --git a/gcc/genconditions.c b/gcc/genconditions.c
index 3a5b85d11..3ca61913f 100644
--- a/gcc/genconditions.c
+++ b/gcc/genconditions.c
diff --git a/gcc/genconditions.cc b/gcc/genconditions.cc
index 28655fa..27cb71b 100644
--- a/gcc/genconditions.cc
+++ b/gcc/genconditions.cc
@@ -58,7 +58,7 @@ write_header (void)
/* It is necessary, but not entirely safe, to include the headers below\n\
in a generator program. As a defensive measure, don't do so when the\n\
Expand All @@ -92,14 +91,14 @@ index 3a5b85d11..3ca61913f 100644
" puts (\"(define_conditions [\");\n"
- "#if GCC_VERSION >= 3001\n"
+ "#if GCC_VERSION >= 3001 && __clang_major__ < 9\n"
" for (i = 0; i < ARRAY_SIZE (insn_conditions); i++)\n"
" for (i = 0; i < ARRAY_SIZE (insn_conditions) - 1; i++)\n"
" {\n"
" printf (\" (%d \\\"\", insn_conditions[i].value);\n"
diff --git a/libgomp/configure b/libgomp/configure
index 5240f7e9d..de5dc96e4 100755
index fd0e337..2366415 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -15768,29 +15768,6 @@ $as_echo "#define HAVE_UNAME 1" >>confdefs.h
@@ -15552,28 +15552,6 @@ $as_echo "#define HAVE_UNAME 1" >>confdefs.h
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

Expand All @@ -125,7 +124,19 @@ index 5240f7e9d..de5dc96e4 100755
-
-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. */
diff --git a/libgomp/libgomp_f.h.in b/libgomp/libgomp_f.h.in
index d8e61c8..9d120f6 100644
--- a/libgomp/libgomp_f.h.in
+++ b/libgomp/libgomp_f.h.in
@@ -81,7 +81,7 @@ omp_check_defines (void)
|| @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)
+ || 1 != 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))

0 comments on commit 6f7a1ce

Please sign in to comment.