mirror of
https://git.planet-casio.com/Lephenixnoir/sh-elf-gcc.git
synced 2024-12-29 13:03:39 +01:00
Upgrade to GCC 13.1.0 and add rustc_codegen_gcc support
This commit is contained in:
parent
91d2786895
commit
c3e4fdf7ef
4 changed files with 3541 additions and 5 deletions
17
README.md
17
README.md
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
This repository provides scripts to automatically compile and install an SH3/SH4-compatible [GCC cross-compiler](https://gcc.gnu.org/). GCC is a collection of compilers most commonly used for C/C++.
|
This repository provides scripts to automatically compile and install an SH3/SH4-compatible [GCC cross-compiler](https://gcc.gnu.org/). GCC is a collection of compilers most commonly used for C/C++.
|
||||||
|
|
||||||
|
This repo currently builds GCC version 13.1.0 with additional patches from [this fork](https://github.com/antoyo/gcc) by antoyo, who works on the GCC backend for rustc, to allow rustc_codedgen_gcc to work. GCC and any patches are licenced under the GNU General Public License version 3 with a runtime exception; see the [GCC source code](https://ftp.gnu.org/gnu/gcc/gcc-13.1.0/) for more details.
|
||||||
|
|
||||||
The following three methods can be used to install the compiler with different levels of automation.
|
The following three methods can be used to install the compiler with different levels of automation.
|
||||||
|
|
||||||
Note that this repository should usually be built twice: first to build the compiler, and then after the libc is installed to build the C++ library.
|
Note that this repository should usually be built twice: first to build the compiler, and then after the libc is installed to build the C++ library.
|
||||||
|
@ -49,7 +51,7 @@ First here is the [guide for installing GCC](https://gcc.gnu.org/install/index.h
|
||||||
|
|
||||||
Get your GCC version of choice from [gcc.gnu.org](https://ftp.gnu.org/gnu/gcc/) and extract the archive.
|
Get your GCC version of choice from [gcc.gnu.org](https://ftp.gnu.org/gnu/gcc/) and extract the archive.
|
||||||
|
|
||||||
**Warning:** GCC 12.1 and GCC 12.2 on your host computer (ie. the one you see with `gcc --version`) has a [critical bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106609) which causes it to incorrectly compile sh-elf-gcc starting from version 12. If your host GCC is version 12.1 or 12.2, stick to version 11.1 for the SuperH compiler.
|
**Warning:** GCC 12.1 to 12.3 for SuperH have a [critical bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106609) which causes them to compile add-ins incorrectly. If you install GCC manually, use either GCC 11.1 (or earlier) or GCC 13 (or later).
|
||||||
|
|
||||||
If using GCC 11.1 (or possibly earlier) for the SuperH compiler, we need to patch the libstdc++ configure script because it tries to run tests that are too advanced for our setup and not actually intended to run on cross-compilers. GCC 12 has this patch upstream.
|
If using GCC 11.1 (or possibly earlier) for the SuperH compiler, we need to patch the libstdc++ configure script because it tries to run tests that are too advanced for our setup and not actually intended to run on cross-compilers. GCC 12 has this patch upstream.
|
||||||
|
|
||||||
|
@ -57,6 +59,14 @@ If using GCC 11.1 (or possibly earlier) for the SuperH compiler, we need to patc
|
||||||
% patch -u -N -p0 < patches/gcc-11.1.0-libstdc++-v3-skip-dlopen.patch
|
% patch -u -N -p0 < patches/gcc-11.1.0-libstdc++-v3-skip-dlopen.patch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want Rust support you will also need to apply some patches to add some needed functionality to libgccjit, taken from the fork mentioned above. This patch has been tested to work when applied to GCC 13.1.0. Note that arguments to this command are slightly different that the last one and it must be applied within the source directory.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
% cd gcc-$VERSION
|
||||||
|
% patch -t -u -N -p1 < ../patches/gcc-13.1.0-rustc-codegen-gcc.patch
|
||||||
|
% cd ..
|
||||||
|
```
|
||||||
|
|
||||||
Also download prerequisites if you don't have them system-wide.
|
Also download prerequisites if you don't have them system-wide.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -88,7 +98,8 @@ You can then configure and build GCC.
|
||||||
--prefix="$SYSROOT" \
|
--prefix="$SYSROOT" \
|
||||||
--target="sh3eb-elf" \
|
--target="sh3eb-elf" \
|
||||||
--with-multilib-list="m3,m4-nofpu" \
|
--with-multilib-list="m3,m4-nofpu" \
|
||||||
--enable-languages="c,c++" \
|
--enable-languages="c,c++,jit" \
|
||||||
|
--enable-host-shared \
|
||||||
--without-headers \
|
--without-headers \
|
||||||
--program-prefix="sh-elf-" \
|
--program-prefix="sh-elf-" \
|
||||||
--enable-libssp \
|
--enable-libssp \
|
||||||
|
@ -100,6 +111,8 @@ You can then configure and build GCC.
|
||||||
--enable-cxx-flags="-fno-exceptions"
|
--enable-cxx-flags="-fno-exceptions"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* `--enable-languages="c,c++,jit"`: rustc_codegen_gcc uses libgccjit. If you don't need Rust support you can remove `jit`.
|
||||||
|
* `--enable-host-shared`: Builds as a shared library for rustc_codegen_gcc. Again, if you don't need Rust support you can remove this.
|
||||||
* `--without-headers`: Also indicates a cross-compiler in many scenarios.
|
* `--without-headers`: Also indicates a cross-compiler in many scenarios.
|
||||||
* `--enable-clocale="generic"`: Makes it easier to build the libstdc++.
|
* `--enable-clocale="generic"`: Makes it easier to build the libstdc++.
|
||||||
* `--enable-libstdcxx-allocator`: Same; `=malloc` might be an option too.
|
* `--enable-libstdcxx-allocator`: Same; `=malloc` might be an option too.
|
||||||
|
|
12
configure.sh
12
configure.sh
|
@ -21,7 +21,7 @@ CAN_BUILD_LIBSTDCXX=
|
||||||
#---
|
#---
|
||||||
|
|
||||||
if [[ -f "$SYSROOT_GCC" ]]; then
|
if [[ -f "$SYSROOT_GCC" ]]; then
|
||||||
SYSROOT_GCC_VERSION=$("$SYSROOT_GCC" --version | head -n 1 | grep -Eo '[0-9.]+$')
|
SYSROOT_GCC_VERSION=$("$SYSROOT_GCC" --version | head -n 1 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||||
|
|
||||||
# TODO: Once we start using the full C++ library, check for libstdc++.a instead
|
# TODO: Once we start using the full C++ library, check for libstdc++.a instead
|
||||||
LIBSTDCXX_FILE=$("$SYSROOT_GCC" -print-file-name=libsupc++.a)
|
LIBSTDCXX_FILE=$("$SYSROOT_GCC" -print-file-name=libsupc++.a)
|
||||||
|
@ -97,6 +97,13 @@ else
|
||||||
echo "$TAG Applying patches/gcc-11.1.0-libstdc++-v3-skip-dlopen.patch..."
|
echo "$TAG Applying patches/gcc-11.1.0-libstdc++-v3-skip-dlopen.patch..."
|
||||||
patch -u -N -p0 < patches/gcc-11.1.0-libstdc++-v3-skip-dlopen.patch
|
patch -u -N -p0 < patches/gcc-11.1.0-libstdc++-v3-skip-dlopen.patch
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$VERSION" = "13.1.0" ]]; then
|
||||||
|
echo "$TAG Applying patches/gcc-13.1.0-rustc-codegen-gcc.patch..."
|
||||||
|
cd gcc-$VERSION
|
||||||
|
patch -t -u -N -p1 < ../patches/gcc-13.1.0-rustc-codegen-gcc.patch
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download prerequisites
|
# Download prerequisites
|
||||||
|
@ -142,7 +149,8 @@ elif [[ "$SYSROOT_GCC_VERSION" != "$VERSION" ]]; then
|
||||||
--prefix="$SYSROOT" \
|
--prefix="$SYSROOT" \
|
||||||
--target="sh3eb-elf" \
|
--target="sh3eb-elf" \
|
||||||
--with-multilib-list="m3,m4-nofpu" \
|
--with-multilib-list="m3,m4-nofpu" \
|
||||||
--enable-languages="c,c++" \
|
--enable-languages="c,c++,jit" \
|
||||||
|
--enable-host-shared \
|
||||||
--without-headers \
|
--without-headers \
|
||||||
--program-prefix="sh-elf-" \
|
--program-prefix="sh-elf-" \
|
||||||
--enable-libssp \
|
--enable-libssp \
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# giteapc: depends=Lephenixnoir/sh-elf-binutils
|
# giteapc: depends=Lephenixnoir/sh-elf-binutils
|
||||||
|
|
||||||
PREFIX ?= $(GITEAPC_PREFIX)
|
PREFIX ?= $(GITEAPC_PREFIX)
|
||||||
VERSION = 11.1.0
|
VERSION = 13.1.0
|
||||||
|
|
||||||
-include giteapc-config.make
|
-include giteapc-config.make
|
||||||
|
|
||||||
|
|
3515
patches/gcc-13.1.0-rustc-codegen-gcc.patch
Normal file
3515
patches/gcc-13.1.0-rustc-codegen-gcc.patch
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue