Skip to content

Instantly share code, notes, and snippets.

@xerpi
Last active March 2, 2025 09:14
Show Gist options
  • Save xerpi/82c7ca88861297d7fa57dc73a3ea576c to your computer and use it in GitHub Desktop.
Save xerpi/82c7ca88861297d7fa57dc73a3ea576c to your computer and use it in GitHub Desktop.
devkitARM Switch 32-bits
export GCC_VER=13.1.0
export BINUTILS_VER=2.40
export NEWLIB_VER=4.3.0.20230120
export TARGET=arm-none-eabi
export PREFIX=$DEVKITPRO/devkitARM
export PATH=$PREFIX/bin:$PATH
# download
wget https://ftp.gnu.org/gnu/gcc/gcc-$GCC_VER/gcc-$GCC_VER.tar.gz
wget https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VER.tar.gz
wget ftp://sourceware.org/pub/newlib/newlib-$NEWLIB_VER.tar.gz
# extract
tar -zxvf gcc-$GCC_VER.tar.gz
tar -zxvf binutils-$BINUTILS_VER.tar.gz
tar -zxvf newlib-$NEWLIB_VER.tar.gz
# no patches needed to binutils for now
# build binutils
mkdir binutils-build && cd binutils-build
../binutils-$BINUTILS_VER/configure \
--prefix=$PREFIX \
--target=$TARGET \
--disable-nls --disable-werror \
--enable-lto --enable-plugins --enable-poison-system-directories
make -j 10 all 2>&1 | tee ./binutils-build-logs.log
make install
# patch gcc
cd gcc-$GCC_VER
wget https://gist.githubusercontent.com/xerpi/82c7ca88861297d7fa57dc73a3ea576c/raw/985aa53291a8979c766e65c057b093469c49c17d/gcc-13.1.0.patch
patch -p1 < gcc-$GCC_VER.patch
cd ..
# build gcc
mkdir gcc-build && cd gcc-build
CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections -fPIC" \
CXXFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections -fPIC" \
LDFLAGS_FOR_TARGET="" \
../gcc-$GCC_VER/configure \
--target=$TARGET \
--prefix=$PREFIX \
--enable-languages=c,c++,objc,lto \
--with-gnu-as --with-gnu-ld --with-gcc \
--enable-cxx-flags='-ffunction-sections' \
--disable-libstdcxx-verbose \
--enable-poison-system-directories \
--enable-interwork --enable-multilib \
--enable-threads --disable-win32-registry --disable-nls --disable-debug \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libstdcxx-pch \
--enable-libstdcxx-time=yes \
--enable-libstdcxx-filesystem-ts \
--with-newlib \
--with-headers=../newlib-$NEWLIB_VER/newlib/libc/include \
--enable-lto \
--with-system-zlib \
--disable-tm-clone-registry \
--disable-__cxa_atexit \
--with-bugurl="http://wiki.devkitpro.org/index.php/Bug_Reports" --with-pkgversion="devkitARM release 61 (mod for Switch aarch32)"
make -j 10 all-gcc 2>&1 | tee ./gcc-build-withoutnewlib-logs.log
make install-gcc
# download devkitPRO's buildscripts for the newlib patch
git clone https://github.com/devkitPro/buildscripts.git
# patch newlib
cd newlib-$NEWLIB_VER
patch -p1 < ../buildscripts/dkarm-eabi/patches/newlib-4.3.0.20230120.patch/newlib-$NEWLIB_VER.patch
cd ..
# build newlib
mkdir newlib-build && cd newlib-build
CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections -fPIC" \
../newlib-$NEWLIB_VER/configure \
--target=$TARGET \
--prefix=$PREFIX \
--disable-newlib-supplied-syscalls \
--enable-newlib-mb \
--disable-newlib-wide-orient
make -j 10 all 2>&1 | tee ./newlib-build-logs.log
make install
# build gcc stage 2
cd gcc-build
make -j 10 all 2>&1 | tee ./gcc-build-withnewlib-logs.log
make install
# important!
# No need anymore since GCC 13 or so
# rm -rf $PREFIX/$TARGET/sys-include
# install devkitARM rules
git clone https://github.com/devkitPro/devkitarm-rules.git
cp devkitarm-rules/* /opt/devkitpro/devkitARM/
# build and install libnx
[constants]
DEVKITPRO = '/opt/devkitpro'
PREFIX = DEVKITPRO + '/devkitARM'
compile_args = ['-march=armv8-a+crc+crypto', '-mtune=cortex-a57', '-mtp=soft', '-fPIC', '-O2', '-ffunction-sections']
[binaries]
c = PREFIX + '/bin/arm-none-eabi-gcc'
cpp = PREFIX + '/bin/arm-none-eabi-g++'
ar = PREFIX + '/bin/arm-none-eabi-ar'
strip = PREFIX + '/bin/arm-none-eabi-strip'
[built-in options]
c_args = compile_args
cpp_args = compile_args
c_link_args = ['-specs=' + DEVKITPRO + '/libnx32/switch32.specs', '-nostartfiles']
cpp_link_args = ['-specs=' + DEVKITPRO + '/libnx32/switch32.specs', '-nostartfiles']
From c79cc7d792c56eec0e67edb2a4d980238ea574c9 Mon Sep 17 00:00:00 2001
From: Sergi Granell <[email protected]>
Date: Tue, 8 Mar 2022 16:10:06 +0100
Subject: [PATCH 1/1] Switch 32
---
gcc/config.gcc | 9 ++++--
gcc/config.host | 4 +++
gcc/config/aarch64/host-aarch64-darwin.c | 32 +++++++++++++++++++
gcc/config/aarch64/x-darwin | 3 ++
gcc/config/arm/arm-cpus.in | 2 +-
gcc/config/arm/arm.h | 12 ++++---
gcc/config/arm/t-arm-elf | 35 +++++----------------
gcc/config/arm/unknown-elf.h | 6 ++--
gcc/config/devkitpro.h | 30 ++++++++++++++++++
gcc/config/devkitpro.opt | 29 +++++++++++++++++
gcc/config/i386/host-mingw32.c | 24 ++++++++------
gcc/gcc.c | 21 ++++++++-----
libgcc/config/arm/t-bpabi | 2 +-
libgcc/crtstuff.c | 4 +--
libstdc++-v3/include/c_compatibility/fenv.h | 6 ++++
libstdc++-v3/include/c_global/cfenv | 8 +++--
16 files changed, 166 insertions(+), 61 deletions(-)
create mode 100644 gcc/config/aarch64/host-aarch64-darwin.c
create mode 100644 gcc/config/aarch64/x-darwin
create mode 100644 gcc/config/devkitpro.h
create mode 100644 gcc/config/devkitpro.opt
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 357b0bed0673..695dc39cdd62 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -180,7 +180,7 @@
# the --with-sysroot configure option or the
# --sysroot command line option is used this
# will be relative to the sysroot.
-# target_type_format_char
+# target_type_format_char
# The default character to be used for formatting
# the attribute in a
# .type symbol_name, ${t_t_f_c}<property>
@@ -1360,9 +1360,14 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems* | arm*-*-fuchsia*)
target_cpu_cname="arm7tdmi"
case ${target} in
arm*-*-eabi*)
- tm_file="$tm_file newlib-stdint.h"
+ tm_file="$tm_file newlib-stdint.h devkitpro.h"
+ tm_defines="${tm_defines} TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1"
tmake_file="${tmake_file} arm/t-bpabi"
use_gcc_stdint=wrap
+ extra_options="${extra_options} devkitpro.opt"
+ case ${enable_threads} in
+ "" | yes | posix) thread_file='posix' ;;
+ esac
;;
arm*-*-fuchsia*)
tm_file="${tm_file} fuchsia.h arm/fuchsia-elf.h glibc-stdint.h"
diff --git a/gcc/config.host b/gcc/config.host
index 0a02c33cc804..38f7adc655e9 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -251,6 +251,10 @@ case ${host} in
host_extra_gcc_objs="${host_extra_gcc_objs} driver-mingw32.o"
host_lto_plugin_soname=liblto_plugin.dll
;;
+ aarch64-*-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 --git a/gcc/config/aarch64/host-aarch64-darwin.c b/gcc/config/aarch64/host-aarch64-darwin.c
new file mode 100644
index 000000000000..92c38b0b9db2
--- /dev/null
+++ b/gcc/config/aarch64/host-aarch64-darwin.c
@@ -0,0 +1,32 @@
+/* i386-darwin host-specific hook definitions.
+ Copyright (C) 2003-2021 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
+<http://www.gnu.org/licenses/>. */
+
+#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 aarch64 hosts; this file exists just
+ to include config/host-darwin.h. */
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff --git a/gcc/config/aarch64/x-darwin b/gcc/config/aarch64/x-darwin
new file mode 100644
index 000000000000..6d788d5e89cf
--- /dev/null
+++ b/gcc/config/aarch64/x-darwin
@@ -0,0 +1,3 @@
+host-aarch64-darwin.o : $(srcdir)/config/aarch64/host-aarch64-darwin.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
diff --git a/gcc/config/arm/arm-cpus.in b/gcc/config/arm/arm-cpus.in
index ab4b6acf5ea4..2b8d0da296f1 100644
--- a/gcc/config/arm/arm-cpus.in
+++ b/gcc/config/arm/arm-cpus.in
@@ -402,7 +402,7 @@ begin arch armv6k
tune for mpcore
tune flags CO_PROC
base 6K
- isa ARMv6k
+ isa ARMv6k VFPv2 FP_DBL
option fp add VFPv2 FP_DBL
optalias vfpv2 fp
option nofp remove ALL_FP
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index 47c13a9e57f2..379999d3c1a6 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -741,6 +741,10 @@ extern const int arm_arch_cde_coproc_bits[];
#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
@@ -1400,7 +1404,7 @@ extern const char *fp_sysreg_names[NB_FP_SYSREGS];
but prevents the compiler from extending the lifetime of these
registers. */
#define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P \
- arm_small_register_classes_for_mode_p
+ arm_small_register_classes_for_mode_p
/* Must leave BASE_REGS reloads alone */
#define THUMB_SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
@@ -1453,7 +1457,7 @@ extern const char *fp_sysreg_names[NB_FP_SYSREGS];
/* Return the maximum number of consecutive registers
needed to represent mode MODE in a register of class CLASS.
- ARM regs are UNITS_PER_WORD bits.
+ ARM regs are UNITS_PER_WORD bits.
FIXME: Is this true for iWMMX? */
#define CLASS_MAX_NREGS(CLASS, MODE) \
(ARM_NUM_REGS (MODE))
@@ -1616,14 +1620,14 @@ machine_function;
#define ARM_Q_BIT_READ (arm_q_bit_access ())
#define ARM_GE_BITS_READ (arm_ge_bits_access ())
-/* As in the machine_function, a global set of call-via labels, for code
+/* As in the machine_function, a global set of call-via labels, for code
that is in text_section. */
extern GTY(()) rtx thumb_call_via_label[14];
/* The number of potential ways of assigning to a co-processor. */
#define ARM_NUM_COPROC_SLOTS 1
-/* Enumeration of procedure calling standard variants. We don't really
+/* Enumeration of procedure calling standard variants. We don't really
support all of these yet. */
enum arm_pcs
{
diff --git a/gcc/config/arm/t-arm-elf b/gcc/config/arm/t-arm-elf
index d68def308672..97819d6d9d76 100644
--- a/gcc/config/arm/t-arm-elf
+++ b/gcc/config/arm/t-arm-elf
@@ -58,28 +58,17 @@ all_sp_only := armv7e-m armv8-m.main
MULTILIB_OPTIONS =
MULTILIB_DIRNAMES =
-MULTILIB_EXCEPTIONS =
+MULTILIB_EXCEPTIONS =
MULTILIB_MATCHES =
MULTILIB_REUSE =
-# PART 2 - multilib build rules
+# PART 2 - multilib
-MULTILIB_OPTIONS += marm/mthumb
-MULTILIB_DIRNAMES += arm thumb
+MULTILIB_OPTIONS = marm/mthumb march=armv8-a+crc mfloat-abi=hard fPIC
+MULTILIB_DIRNAMES = marm thumb armv8-a+crc fpu pic
-MULTILIB_OPTIONS += mfpu=auto
-MULTILIB_DIRNAMES += autofp
-
-MULTILIB_OPTIONS += march=armv5te+fp/march=armv7+fp
-MULTILIB_DIRNAMES += v5te v7
-
-MULTILIB_OPTIONS += mfloat-abi=hard
-MULTILIB_DIRNAMES += fpu
-
-# Build a total of 4 library variants (base options plus the following):
-MULTILIB_REQUIRED += mthumb
-MULTILIB_REQUIRED += marm/mfpu=auto/march=armv5te+fp/mfloat-abi=hard
-MULTILIB_REQUIRED += mthumb/mfpu=auto/march=armv7+fp/mfloat-abi=hard
+MULTILIB_REQUIRED = mthumb/march=armv8-a+crc/fPIC
+MULTILIB_REQUIRED += marm/march=armv8-a+crc/mfloat-abi=hard/fpu/fPIC
# PART 3 - Match rules
@@ -113,14 +102,4 @@ MULTILIB_MATCHES += $(foreach ARCH, $(all_v8_archs), \
MULTILIB_MATCHES += $(foreach ARCH, armv7e-m armv8-m.mainline, \
march?armv7+fp=march?$(ARCH)+fp.dp)
-# PART 4 - Reuse rules
-
-MULTILIB_REUSE += mthumb=mthumb/mfpu.auto
-MULTILIB_REUSE += mthumb=mthumb/mfpu.auto/march.armv5te+fp
-MULTILIB_REUSE += mthumb=mthumb/march.armv5te+fp
-MULTILIB_REUSE += marm/mfpu.auto/march.armv5te+fp/mfloat-abi.hard=marm/march.armv5te+fp/mfloat-abi.hard
-MULTILIB_REUSE += marm/mfpu.auto/march.armv5te+fp/mfloat-abi.hard=march.armv5te+fp/mfloat-abi.hard
-MULTILIB_REUSE += marm/mfpu.auto/march.armv5te+fp/mfloat-abi.hard=mfpu.auto/march.armv5te+fp/mfloat-abi.hard
-MULTILIB_REUSE += mthumb/mfpu.auto/march.armv7+fp/mfloat-abi.hard=mthumb/march.armv7+fp/mfloat-abi.hard
-MULTILIB_REUSE += mthumb/mfpu.auto/march.armv7+fp/mfloat-abi.hard=mfpu.auto/march.armv7+fp/mfloat-abi.hard
-MULTILIB_REUSE += mthumb/mfpu.auto/march.armv7+fp/mfloat-abi.hard=march.armv7+fp/mfloat-abi.hard
+MULTILIB_MATCHES += fPIC=fpic fPIC=fpie fPIC=fPIE
diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h
index cca6f0ece545..c4ffb21b4ce9 100644
--- 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"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
@@ -91,6 +91,6 @@
/* The libgcc udivmod functions may throw exceptions. If newlib is
configured to support long longs in I/O, then printf will depend on
udivmoddi4, which will depend on the exception unwind routines,
- which will depend on abort, which is defined in libc. */
+ which will depend on abort, which is defined in libc. */
#undef LINK_GCC_C_SEQUENCE_SPEC
-#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %{!nolibc:%L} --end-group"
+#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %L %(libgloss) --end-group"
diff --git a/gcc/config/devkitpro.h b/gcc/config/devkitpro.h
new file mode 100644
index 000000000000..8e403c9c81e7
--- /dev/null
+++ b/gcc/config/devkitpro.h
@@ -0,0 +1,30 @@
+/* Definitions for devkitPro toolchains.
+ Copyright (C) 2016-2018 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.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+ do { \
+ builtin_define ("__DEVKITARM__"); \
+ } while (0)
+
diff --git a/gcc/config/devkitpro.opt b/gcc/config/devkitpro.opt
new file mode 100644
index 000000000000..9acbbf9d27c0
--- /dev/null
+++ b/gcc/config/devkitpro.opt
@@ -0,0 +1,29 @@
+; Options for devkitPro toolchains.
+
+; Copyright (C) 2011-2018 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
+; <http://www.gnu.org/licenses/>.
+
+; See the GCC internals manual (options.texi) for a description of
+; this file's format.
+
+; Please try to keep this file in ASCII collating order.
+
+pthread
+Driver
+
+; This comment is to ensure we retain the blank line above.
diff --git a/gcc/config/i386/host-mingw32.c b/gcc/config/i386/host-mingw32.c
index 360a280b23ae..2c6faab54a09 100644
--- a/gcc/config/i386/host-mingw32.c
+++ b/gcc/config/i386/host-mingw32.c
@@ -45,12 +45,16 @@ static size_t mingw32_gt_pch_alloc_granularity (void);
static inline void w32_error(const char*, const char*, int, const char*);
/* FIXME: Is this big enough? */
+#if __MINGW64__
+static const size_t pch_VA_max_size = UINT64_C(64 * 1024 * 1024 * 1024);
+#else
static const size_t pch_VA_max_size = 128 * 1024 * 1024;
+#endif
/* Granularity for reserving address space. */
static size_t va_granularity = 0x10000;
-/* Print out the GetLastError() translation. */
+/* Print out the GetLastError() translation. */
static inline void
w32_error (const char* function, const char* file, int line,
const char* my_msg)
@@ -99,7 +103,7 @@ mingw32_gt_pch_get_address (size_t size, int)
for NT system dlls is in 0x70000000 to 0x78000000 range.
If we allocate at bottom we need to reserve the address as early
as possible and at the same point in each invocation. */
-
+
res = VirtualAlloc (NULL, pch_VA_max_size,
MEM_RESERVE | MEM_TOP_DOWN,
PAGE_NOACCESS);
@@ -109,11 +113,11 @@ mingw32_gt_pch_get_address (size_t size, int)
/* We do not need the address space for now, so free it. */
VirtualFree (res, 0, MEM_RELEASE);
- return res;
+ return res;
}
/* ADDR is an address returned by gt_pch_get_address. Attempt to allocate
- SIZE bytes at the same address and load it with the data from FD at
+ SIZE bytes at the same address and load it with the data from FD at
OFFSET. Return -1 if we couldn't allocate memory at ADDR, return 0
if the memory is allocated but the data not loaded, return 1 if done. */
@@ -123,10 +127,10 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd,
{
void * mmap_addr;
HANDLE mmap_handle;
-
+
/* Apparently, MS Vista puts unnamed file mapping objects into Global
namespace when running an application in a Terminal Server
- session. This causes failure since, by default, applications
+ session. This causes failure since, by default, applications
don't get SeCreateGlobalPrivilege. We don't need global
memory sharing so explicitly put object into Local namespace.
@@ -146,10 +150,10 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd,
version_info.dwOSVersionInfoSize = sizeof (version_info);
if (size == 0)
- return 0;
+ return 0;
/* Offset must be also be a multiple of allocation granularity for
- this to work. We can't change the offset. */
+ this to work. We can't change the offset. */
if ((offset & (va_granularity - 1)) != 0 || size > pch_VA_max_size)
return -1;
@@ -172,7 +176,7 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd,
if (mmap_handle == NULL)
{
w32_error (__FUNCTION__, __FILE__, __LINE__, "CreateFileMapping");
- return -1;
+ return -1;
}
/* Retry five times, as here might occure a race with multiple gcc's
@@ -186,7 +190,7 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd,
if (r != 4)
Sleep (500);
}
-
+
if (mmap_addr != addr)
{
w32_error (__FUNCTION__, __FILE__, __LINE__, "MapViewOfFileEx");
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 4d790f9dd4a1..3b94007fe59f 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -853,6 +853,11 @@ proper position among the other output files. */
#endif
#endif
+#ifndef LIBGLOSS_SPEC
+# define LIBGLOSS_SPEC "-lsysbase"
+#endif
+
+
/* config.h can define STARTFILE_SPEC to override the default crt0 files. */
#ifndef STARTFILE_SPEC
#define STARTFILE_SPEC \
@@ -1197,6 +1202,7 @@ static const char *link_spec = LINK_SPEC;
static const char *lib_spec = LIB_SPEC;
static const char *link_gomp_spec = "";
static const char *libgcc_spec = LIBGCC_SPEC;
+static const char *libgloss_spec = LIBGLOSS_SPEC;
static const char *endfile_spec = ENDFILE_SPEC;
static const char *startfile_spec = STARTFILE_SPEC;
static const char *linker_name_spec = LINKER_NAME;
@@ -1702,6 +1708,7 @@ static struct spec_list static_specs[] =
INIT_STATIC_SPEC ("lib", &lib_spec),
INIT_STATIC_SPEC ("link_gomp", &link_gomp_spec),
INIT_STATIC_SPEC ("libgcc", &libgcc_spec),
+ INIT_STATIC_SPEC ("libgloss", &libgloss_spec),
INIT_STATIC_SPEC ("startfile", &startfile_spec),
INIT_STATIC_SPEC ("cross_compile", &cross_compile),
INIT_STATIC_SPEC ("version", &compiler_version),
@@ -6642,7 +6649,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
"%{foo=*:bar%*}%{foo=*:one%*two}"
matches -foo=hello then it will produce:
-
+
barhello onehellotwo
*/
if (*p == 0 || *p == '}')
@@ -10440,9 +10447,9 @@ static unsigned HOST_WIDE_INT
get_random_number (void)
{
unsigned HOST_WIDE_INT ret = 0;
- int fd;
+ int fd;
- fd = open ("/dev/urandom", O_RDONLY);
+ fd = open ("/dev/urandom", O_RDONLY);
if (fd >= 0)
{
read (fd, &ret, sizeof (HOST_WIDE_INT));
@@ -10873,16 +10880,16 @@ whitespace_to_convert_p (char c, void *)
return (c == ' ' || c == '\t');
}
-/* Insert backslash before spaces in ORIG (usually a file path), to
+/* Insert backslash before spaces in ORIG (usually a file path), to
avoid being broken by spec parser.
This function is needed as do_spec_1 treats white space (' ' and '\t')
as the end of an argument. But in case of -plugin /usr/gcc install/xxx.so,
the file name should be treated as a single argument rather than being
- broken into multiple. Solution is to insert '\\' before the space in a
+ broken into multiple. Solution is to insert '\\' before the space in a
file name.
-
- This function converts and only converts all occurrence of ' '
+
+ This function converts and only converts all occurrence of ' '
to '\\' + ' ' and '\t' to '\\' + '\t'. For example:
"a b" -> "a\\ b"
"a b" -> "a\\ \\ b"
diff --git a/libgcc/config/arm/t-bpabi b/libgcc/config/arm/t-bpabi
index dddddc7c444b..c25025979537 100644
--- a/libgcc/config/arm/t-bpabi
+++ b/libgcc/config/arm/t-bpabi
@@ -17,4 +17,4 @@ SHLIB_MAPFILES += $(srcdir)/config/arm/libgcc-bpabi.ver
# On ARM, specifying -fnon-call-exceptions will needlessly pull in
# the unwinder in simple programs which use 64-bit division. Omitting
# the option is safe.
-LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions
+LIB2_DIVMOD_EXCEPTION_FLAGS := -fno-exceptions
diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c
index 675930db043f..7242abbcccdf 100644
--- a/libgcc/crtstuff.c
+++ b/libgcc/crtstuff.c
@@ -84,7 +84,7 @@ call_ ## FUNC (void) \
(defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__))
#define BSD_DL_ITERATE_PHDR_AVAILABLE
#endif
-
+
#if defined(OBJECT_FORMAT_ELF) \
&& !defined(OBJECT_FORMAT_FLAT) \
&& defined(HAVE_LD_EH_FRAME_HDR) \
@@ -325,7 +325,7 @@ register_tm_clones (void)
#ifdef OBJECT_FORMAT_ELF
-#if DEFAULT_USE_CXA_ATEXIT
+#if 1 /* DEFAULT_USE_CXA_ATEXIT */
/* Declare the __dso_handle variable. It should have a unique value
in every shared-object; in a main program its value is zero. The
object should in any case be protected. This means the instance
diff --git a/libstdc++-v3/include/c_compatibility/fenv.h b/libstdc++-v3/include/c_compatibility/fenv.h
index 0413e3b7c254..ff5f8bbe1a13 100644
--- a/libstdc++-v3/include/c_compatibility/fenv.h
+++ b/libstdc++-v3/include/c_compatibility/fenv.h
@@ -26,6 +26,10 @@
* This is a Standard C++ Library header.
*/
+#if !defined __cplusplus || defined _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+# include_next <fenv.h>
+#else
+
#ifndef _GLIBCXX_FENV_H
#define _GLIBCXX_FENV_H 1
@@ -79,3 +83,5 @@ namespace std
#endif // C++11
#endif // _GLIBCXX_FENV_H
+
+#endif // __cplusplus
diff --git a/libstdc++-v3/include/c_global/cfenv b/libstdc++-v3/include/c_global/cfenv
index 0b0ec35a8377..d24cb1a3c817 100644
--- a/libstdc++-v3/include/c_global/cfenv
+++ b/libstdc++-v3/include/c_global/cfenv
@@ -37,9 +37,11 @@
#include <bits/c++config.h>
-#if _GLIBCXX_HAVE_FENV_H
-# include <fenv.h>
-#endif
+// Need to ensure this finds the C library's <fenv.h> not a libstdc++
+// wrapper that might already be installed later in the include search path.
+#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+#include_next <fenv.h>
+#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#ifdef _GLIBCXX_USE_C99_FENV_TR1
--
2.35.1
From 483f05be557610dcc183c9f4e4e6411f6ba2ea34 Mon Sep 17 00:00:00 2001
From: Sergi Granell <[email protected]>
Date: Fri, 19 May 2023 15:38:01 +0900
Subject: [PATCH] Switch 32-bit
---
gcc/config.gcc | 5 ++
gcc/config/arm/arm-cpus.in | 2 +-
gcc/config/arm/t-arm-elf | 116 ++-----------------------------
gcc/config/arm/unknown-elf.h | 5 +-
gcc/config/devkitpro.h | 27 +++++++
gcc/config/devkitpro.opt | 29 ++++++++
gcc/config/newlib-stdint.h | 3 +-
gcc/gcc.cc | 7 ++
libgcc/config/arm/t-bpabi | 2 +-
libgcc/crtstuff.c | 2 +-
libgcc/gthr.h | 2 +-
libstdc++-v3/include/Makefile.am | 1 +
libstdc++-v3/include/Makefile.in | 2 +
13 files changed, 84 insertions(+), 119 deletions(-)
create mode 100644 gcc/config/devkitpro.h
create mode 100644 gcc/config/devkitpro.opt
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 6fd1594480a..92b82426f50 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1412,6 +1412,11 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems* | arm*-*-fuchsia*)
tm_file="$tm_file newlib-stdint.h"
tmake_file="${tmake_file} arm/t-bpabi"
use_gcc_stdint=wrap
+ tm_file="${tm_file} devkitpro.h"
+ extra_options="${extra_options} devkitpro.opt"
+ case ${enable_threads} in
+ "" | yes | posix) thread_file='posix' ;;
+ esac
;;
arm*-*-fuchsia*)
tm_file="${tm_file} fuchsia.h arm/fuchsia-elf.h glibc-stdint.h"
diff --git a/gcc/config/arm/arm-cpus.in b/gcc/config/arm/arm-cpus.in
index f1fa3fa174c..2bb894b5b2d 100644
--- a/gcc/config/arm/arm-cpus.in
+++ b/gcc/config/arm/arm-cpus.in
@@ -416,7 +416,7 @@ begin arch armv6k
tune for mpcore
tune flags CO_PROC
base 6K
- isa ARMv6k
+ isa ARMv6k VFPv2 FP_DBL
option fp add VFPv2 FP_DBL
optalias vfpv2 fp
option nofp remove ALL_FP
diff --git a/gcc/config/arm/t-arm-elf b/gcc/config/arm/t-arm-elf
index f7fc1460d1c..18a0587f508 100644
--- a/gcc/config/arm/t-arm-elf
+++ b/gcc/config/arm/t-arm-elf
@@ -16,120 +16,12 @@
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
-# Build a very basic set of libraries that should cater for most cases.
-
-# Single-precision floating-point is NOT supported; we don't build a
-# suitable library for that. Use the rm-profile config in that case.
-
-# PART 1 - Useful groups of options
-
-dp_fpus := vfp vfpv2 vfpv3 vfpv3-fp16 vfpv3-d16 vfpv3-d16-fp16 \
- neon neon-vfpv3 neon-fp16 vfpv4 neon-vfpv4 vfpv4-d16 \
- fpv5-d16 fp-armv8 neon-fp-armv8 crypto-neon-fp-armv8 \
- vfp3
-
-sp_fpus := vfpv3xd vfpv3xd-fp16 fpv4-sp-d16 fpv5-sp-d16
-
-v7a_fps := vfpv3 vfpv3-fp16 vfpv4 simd neon-fp16 neon-vfpv4
-v7ve_fps := vfpv3-d16 vfpv3 vfpv3-d16-fp16 vfpv3-fp16 vfpv4 neon \
- neon-fp16 simd
-
-# Not all these permutations exist for all architecture variants, but
-# it seems to work ok.
-v8_fps := simd fp16 crypto fp16+crypto dotprod fp16fml
-
-v9_fps := simd fp16 crypto fp16+crypto dotprod fp16fml
-
-# We don't do anything special with these. Pre-v4t probably doesn't work.
-all_early_nofp := armv4 armv4t armv5t
-
-all_early_arch := armv5tej armv6 armv6j armv6k armv6z armv6kz \
- armv6zk armv6t2 iwmmxt iwmmxt2
-
-all_v7_a_r := armv7-a armv7ve armv7-r
-
-all_v8_archs := armv8-a armv8-a+crc armv8.1-a armv8.2-a armv8.3-a armv8.4-a \
- armv8.5-a armv8.6-a
-
-all_v9_archs := armv9-a
-
-# No floating point variants, require thumb1 softfp
-all_nofp_t := armv6-m armv6s-m armv8-m.base
-
-all_nofp_t2 := armv7-m
-
-all_sp_only := armv7e-m armv8-m.main
-
-MULTILIB_OPTIONS =
-MULTILIB_DIRNAMES =
+MULTILIB_OPTIONS = marm/mthumb march=armv8-a+crc mfloat-abi=hard fPIC
+MULTILIB_DIRNAMES = marm thumb armv8-a+crc fpu pic
MULTILIB_EXCEPTIONS =
MULTILIB_MATCHES =
-MULTILIB_REUSE =
-
-# PART 2 - multilib build rules
-
-MULTILIB_OPTIONS += marm/mthumb
-MULTILIB_DIRNAMES += arm thumb
-
-MULTILIB_OPTIONS += mfpu=auto
-MULTILIB_DIRNAMES += autofp
-
-MULTILIB_OPTIONS += march=armv5te+fp/march=armv7+fp
-MULTILIB_DIRNAMES += v5te v7
-
-MULTILIB_OPTIONS += mfloat-abi=hard
-MULTILIB_DIRNAMES += fpu
-
-# Build a total of 4 library variants (base options plus the following):
-MULTILIB_REQUIRED += mthumb
-MULTILIB_REQUIRED += marm/mfpu=auto/march=armv5te+fp/mfloat-abi=hard
-MULTILIB_REQUIRED += mthumb/mfpu=auto/march=armv7+fp/mfloat-abi=hard
-
-# PART 3 - Match rules
-
-# Map all supported FPUs onto mfpu=auto
-MULTILIB_MATCHES += $(foreach FPU, $(dp_fpus), \
- mfpu?auto=mfpu?$(FPU))
-
-MULTILIB_MATCHES += march?armv5te+fp=march?armv5te
-
-MULTILIB_MATCHES += $(foreach ARCH, $(all_early_arch), \
- march?armv5te+fp=march?$(ARCH) \
- march?armv5te+fp=march?$(ARCH)+fp)
-
-MULTILIB_MATCHES += march?armv7+fp=march?armv7
-
-MULTILIB_MATCHES += $(foreach FPARCH, $(v7a_fps), \
- march?armv7+fp=march?armv7-a+$(FPARCH))
-
-MULTILIB_MATCHES += $(foreach FPARCH, $(v7ve_fps), \
- march?armv7+fp=march?armv7ve+$(FPARCH))
-
-MULTILIB_MATCHES += $(foreach ARCH, $(all_v7_a_r), \
- march?armv7+fp=march?$(ARCH) \
- march?armv7+fp=march?$(ARCH)+fp)
-
-MULTILIB_MATCHES += $(foreach ARCH, $(all_v8_archs), \
- march?armv7+fp=march?$(ARCH) \
- $(foreach FPARCH, $(v8_fps), \
- march?armv7+fp=march?$(ARCH)+$(FPARCH)))
-
-MULTILIB_MATCHES += $(foreach ARCH, $(all_v9_archs), \
- march?armv7+fp=march?$(ARCH) \
- $(foreach FPARCH, $(v9_fps), \
- march?armv7+fp=march?$(ARCH)+$(FPARCH)))
-MULTILIB_MATCHES += $(foreach ARCH, armv7e-m armv8-m.mainline, \
- march?armv7+fp=march?$(ARCH)+fp.dp)
+MULTILIB_REQUIRED = mthumb/march=armv8-a+crc/fPIC marm/march=armv8-a+crc/mfloat-abi=hard/fpu/fPIC
-# PART 4 - Reuse rules
-MULTILIB_REUSE += mthumb=mthumb/mfpu.auto
-MULTILIB_REUSE += mthumb=mthumb/mfpu.auto/march.armv5te+fp
-MULTILIB_REUSE += mthumb=mthumb/march.armv5te+fp
-MULTILIB_REUSE += marm/mfpu.auto/march.armv5te+fp/mfloat-abi.hard=marm/march.armv5te+fp/mfloat-abi.hard
-MULTILIB_REUSE += marm/mfpu.auto/march.armv5te+fp/mfloat-abi.hard=march.armv5te+fp/mfloat-abi.hard
-MULTILIB_REUSE += marm/mfpu.auto/march.armv5te+fp/mfloat-abi.hard=mfpu.auto/march.armv5te+fp/mfloat-abi.hard
-MULTILIB_REUSE += mthumb/mfpu.auto/march.armv7+fp/mfloat-abi.hard=mthumb/march.armv7+fp/mfloat-abi.hard
-MULTILIB_REUSE += mthumb/mfpu.auto/march.armv7+fp/mfloat-abi.hard=mfpu.auto/march.armv7+fp/mfloat-abi.hard
-MULTILIB_REUSE += mthumb/mfpu.auto/march.armv7+fp/mfloat-abi.hard=march.armv7+fp/mfloat-abi.hard
+MULTILIB_MATCHES += fPIC=fpic fPIC=fpie fPIC=fPIE
diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h
index 397ac3f68b9..b9a388f19be 100644
--- 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"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
@@ -93,4 +93,5 @@
udivmoddi4, which will depend on the exception unwind routines,
which will depend on abort, which is defined in libc. */
#undef LINK_GCC_C_SEQUENCE_SPEC
-#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %{!nolibc:%L} --end-group"
+#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %L %(libgloss) --end-group"
+
diff --git a/gcc/config/devkitpro.h b/gcc/config/devkitpro.h
new file mode 100644
index 00000000000..180a9ea8553
--- /dev/null
+++ b/gcc/config/devkitpro.h
@@ -0,0 +1,27 @@
+/* Definitions for devkitPro toolchains.
+ Copyright (C) 2016-2018 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.
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+ do { \
+ builtin_define ("__DEVKITPRO__"); \
+ builtin_define ("__DEVKITARM__"); \
+ } while (0)
+
+
diff --git a/gcc/config/devkitpro.opt b/gcc/config/devkitpro.opt
new file mode 100644
index 00000000000..9acbbf9d27c
--- /dev/null
+++ b/gcc/config/devkitpro.opt
@@ -0,0 +1,29 @@
+; Options for devkitPro toolchains.
+
+; Copyright (C) 2011-2018 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
+; <http://www.gnu.org/licenses/>.
+
+; See the GCC internals manual (options.texi) for a description of
+; this file's format.
+
+; Please try to keep this file in ASCII collating order.
+
+pthread
+Driver
+
+; This comment is to ensure we retain the blank line above.
diff --git a/gcc/config/newlib-stdint.h b/gcc/config/newlib-stdint.h
index 98bc77b46b8..60f51c182a9 100644
--- a/gcc/config/newlib-stdint.h
+++ b/gcc/config/newlib-stdint.h
@@ -25,7 +25,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* newlib uses 32-bit long in certain cases for all non-SPU
targets. */
#ifndef STDINT_LONG32
-#define STDINT_LONG32 (LONG_TYPE_SIZE == 32)
+/* use int and unsigned int for int32_t and uint32_t */
+#define STDINT_LONG32 0
#endif
#define SIG_ATOMIC_TYPE "int"
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 16bb07f2cdc..22a181a3a1c 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -868,6 +868,11 @@ proper position among the other output files. */
#endif
#endif
+#ifndef LIBGLOSS_SPEC
+# define LIBGLOSS_SPEC "-lsysbase"
+#endif
+
+
/* config.h can define STARTFILE_SPEC to override the default crt0 files. */
#ifndef STARTFILE_SPEC
#define STARTFILE_SPEC \
@@ -1191,6 +1196,7 @@ static const char *link_spec = LINK_SPEC;
static const char *lib_spec = LIB_SPEC;
static const char *link_gomp_spec = "";
static const char *libgcc_spec = LIBGCC_SPEC;
+static const char *libgloss_spec = LIBGLOSS_SPEC;
static const char *endfile_spec = ENDFILE_SPEC;
static const char *startfile_spec = STARTFILE_SPEC;
static const char *linker_name_spec = LINKER_NAME;
@@ -1701,6 +1707,7 @@ static struct spec_list static_specs[] =
INIT_STATIC_SPEC ("lib", &lib_spec),
INIT_STATIC_SPEC ("link_gomp", &link_gomp_spec),
INIT_STATIC_SPEC ("libgcc", &libgcc_spec),
+ INIT_STATIC_SPEC ("libgloss", &libgloss_spec),
INIT_STATIC_SPEC ("startfile", &startfile_spec),
INIT_STATIC_SPEC ("cross_compile", &cross_compile),
INIT_STATIC_SPEC ("version", &compiler_version),
diff --git a/libgcc/config/arm/t-bpabi b/libgcc/config/arm/t-bpabi
index dddddc7c444..c2502597953 100644
--- a/libgcc/config/arm/t-bpabi
+++ b/libgcc/config/arm/t-bpabi
@@ -17,4 +17,4 @@ SHLIB_MAPFILES += $(srcdir)/config/arm/libgcc-bpabi.ver
# On ARM, specifying -fnon-call-exceptions will needlessly pull in
# the unwinder in simple programs which use 64-bit division. Omitting
# the option is safe.
-LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions
+LIB2_DIVMOD_EXCEPTION_FLAGS := -fno-exceptions
diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c
index 93ff5b81dc5..20c0fe89a28 100644
--- a/libgcc/crtstuff.c
+++ b/libgcc/crtstuff.c
@@ -326,7 +326,7 @@ register_tm_clones (void)
#ifdef OBJECT_FORMAT_ELF
-#if DEFAULT_USE_CXA_ATEXIT
+#if 1 /* DEFAULT_USE_CXA_ATEXIT */
/* Declare the __dso_handle variable. It should have a unique value
in every shared-object; in a main program its value is zero. The
object should in any case be protected. This means the instance
diff --git a/libgcc/gthr.h b/libgcc/gthr.h
index 1989c0c86ed..dc3220cdf3c 100644
--- a/libgcc/gthr.h
+++ b/libgcc/gthr.h
@@ -136,7 +136,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* The pe-coff weak support isn't fully compatible to ELF's weak.
For static libraries it might would work, but as we need to deal
with shared versions too, we disable it for mingw-targets. */
-#ifdef __MINGW32__
+#ifdef __MINGW32__ || defined(__DEVKITARM__)
#undef GTHREAD_USE_WEAK
#define GTHREAD_USE_WEAK 0
#endif
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index a880e8ee227..2050e2e4ccf 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -1417,6 +1417,7 @@ ${host_builddir}/gthr.h: ${toplevel_srcdir}/libgcc/gthr.h stamp-${host_alias}
-e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \
-e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \
-e 's/_GLIBCXX___MINGW32_GLIBCXX___/__MINGW32__/g' \
+ -e 's/_GLIBCXX___DEVKITARM_GLIBCXX___/__DEVKITARM__/g' \
-e 's,^#include "\(.*\)",#include <bits/\1>,g' \
< $< > $@
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 0ff875b280b..7d270fc3a83 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -336,6 +336,7 @@ prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
python_mod_dir = @python_mod_dir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -1891,6 +1892,7 @@ ${host_builddir}/gthr.h: ${toplevel_srcdir}/libgcc/gthr.h stamp-${host_alias}
-e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \
-e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \
-e 's/_GLIBCXX___MINGW32_GLIBCXX___/__MINGW32__/g' \
+ -e 's/_GLIBCXX___DEVKITARM_GLIBCXX___/__DEVKITARM__/g' \
-e 's,^#include "\(.*\)",#include <bits/\1>,g' \
< $< > $@
--
2.40.1
cmake_minimum_required(VERSION 3.2)
include(CMakeParseArguments)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
if(NOT DEFINED ENV{DEVKITPRO})
message(FATAL_ERROR "Cannot find devkitpro")
endif()
set(DEVKITPRO "$ENV{DEVKITPRO}" CACHE PATH "Path to devkitpro root")
set(CMAKE_SYSTEM_PROCESSOR "armv8-a")
set(CMAKE_C_COMPILER "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler")
set(CMAKE_CXX_COMPILER "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler")
set(CMAKE_ASM_COMPILER "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler")
set(CMAKE_STRIP "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip")
set(CMAKE_AR "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive")
set(CMAKE_LINKER "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker")
set(CMAKE_NM "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm")
set(CMAKE_OBJCOPY "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy")
set(CMAKE_OBJDUMP "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump")
set(CMAKE_RANLIB "${DEVKITPRO}/devkitARM/bin/arm-none-eabi-ranlib${TOOL_OS_SUFFIX}" CACHE PATH "ranlib")
# Switch specific tools
set(UAM "${DEVKITPRO}/tools/bin/uam${TOOL_OS_SUFFIX}" CACHE PATH "uam")
# cache flags
set(ARCH_FLAGS "-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC")
set(CMAKE_CXX_FLAGS "${ARCH_FLAGS} -fno-rtti -fno-exceptions" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS "${ARCH_FLAGS}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c++ Release flags")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c Release flags")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c++ Debug flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c Debug flags")
set(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags")
set(CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags")
set(CMAKE_EXE_LINKER_FLAGS "-specs=${DEVKITPRO}/libnx32/switch32.specs -nostartfiles" CACHE STRING "executable linker flags")
# where is the target environment
set(CMAKE_INSTALL_PREFIX "${DEVKITPRO}/libnx32" CACHE PATH "default install path")
set(CMAKE_FIND_ROOT_PATH "${DEVKITPRO}/devkitARM/bin" "${DEVKITPRO}/devkitARM/arm-none-eabi" "${DEVKITPRO}/libnx32" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" )
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_compile_definitions(__SWITCH__)
include_directories("${DEVKITPRO}/libnx32/include")
link_directories("${DEVKITPRO}/libnx32/lib")
function(switch_create_nso)
cmake_parse_arguments(PARSED_ARGS "" "NAME;ELF" "" ${ARGN})
add_custom_command(
OUTPUT ${PARSED_ARGS_NAME}.nso
COMMAND elf2nso ${PARSED_ARGS_ELF} ${PARSED_ARGS_NAME}.nso
DEPENDS ${PARSED_ARGS_ELF}
COMMENT "Generating NSO"
)
add_custom_target(${PARSED_ARGS_NAME}-nso ALL
DEPENDS ${PARSED_ARGS_NAME}.nso
)
endfunction(switch_create_nso)
function(switch_generate_npdm)
cmake_parse_arguments(PARSED_ARGS "" "NAME;JSON" "" ${ARGN})
add_custom_command(
OUTPUT ${PARSED_ARGS_NAME}.npdm
COMMAND npdmtool ${PARSED_ARGS_JSON} ${PARSED_ARGS_NAME}.npdm
DEPENDS ${PARSED_ARGS_JSON}
COMMENT "Generating NPDM"
)
add_custom_target(${PARSED_ARGS_NAME}-npdm ALL
DEPENDS ${PARSED_ARGS_NAME}.npdm
)
endfunction(switch_generate_npdm)
function(switch_create_nsp)
cmake_parse_arguments(PARSED_ARGS "" "NAME;NSO;NPDM" "" ${ARGN})
add_custom_command(
OUTPUT ${PARSED_ARGS_NAME}.nsp
COMMAND mkdir -p exefs
COMMAND cp ${PARSED_ARGS_NSO} exefs/main
COMMAND cp ${PARSED_ARGS_NPDM} exefs/main.npdm
COMMAND build_pfs0 exefs ${PARSED_ARGS_NAME}.nsp
DEPENDS ${PARSED_ARGS_NSO} ${PARSED_ARGS_NPDM}
COMMENT "Generating NSP"
)
add_custom_target(${PARSED_ARGS_NAME}-nsp ALL
DEPENDS ${PARSED_ARGS_NAME}.nsp
)
endfunction(switch_create_nsp)
# SPIRV-Cross
cmake .. -DCMAKE_TOOLCHAIN_FILE=../../cmake/libnx32.toolchain.cmake -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS:BOOL=ON -DSPIRV_CROSS_ENABLE_HLSL:BOOL=OFF -DSPIRV_CROSS_ENABLE_MSL:BOOL=OFF -DSPIRV_CROSS_FORCE_PIC:BOOL=ON -DSPIRV_CROSS_CLI:BOOL=OFF
# fmt
cmake .. -DCMAKE_TOOLCHAIN_FILE=../../cmake/libnx32.toolchain.cmake -DFMT_TEST:BOOL=OFF
# glslang
cmake .. -DCMAKE_TOOLCHAIN_FILE=../../cmake/libnx32.toolchain.cmake -DENABLE_HLSL:BOOL=OFF -DENABLE_GLSLANG_BINARIES:BOOL=OFF -DENABLE_CTEST:BOOL=OFF -DENABLE_SPVREMAPPER:BOOL=OFF
# uam
meson --cross-file ../cross_file_switch32.txt --prefix /opt/devkitpro/libnx32 build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment