mirror of
https://git.planet-casio.com/Lephenixnoir/sh-elf-gcc.git
synced 2025-06-03 17:35:11 +02:00
Compare commits
21 commits
Author | SHA1 | Date | |
---|---|---|---|
|
fdbc1be7a8 | ||
|
bcc26c94f2 | ||
|
047a632509 | ||
|
91d2786895 | ||
|
26affe51cf | ||
|
e50b17396a | ||
|
b9b571d73c | ||
|
0c7154437d | ||
|
c7d1def359 | ||
|
9be687a07a | ||
|
954e3ccd08 | ||
|
9f33074c10 | ||
|
55017f002f | ||
|
1d344aa076 | ||
|
0217f5399d | ||
|
85f87acb15 | ||
|
2d8919397f | ||
|
aa09965a6d | ||
|
49de34fe9e | ||
|
b241b246ea | ||
|
cdc1ac5da9 |
11 changed files with 482 additions and 83 deletions
15
.gitignore
vendored
15
.gitignore
vendored
|
@ -1,11 +1,4 @@
|
|||
# Everything but the scripts
|
||||
*
|
||||
!giteapc.make
|
||||
!giteapc-config-any.make
|
||||
!configure.sh
|
||||
!build.sh
|
||||
!install.sh
|
||||
!uninstall.sh
|
||||
!util.sh
|
||||
!.gitignore
|
||||
!README.md
|
||||
/gcc-*/
|
||||
/gcc-*.tar.*
|
||||
/build*/
|
||||
/giteapc-config.make
|
||||
|
|
128
README.md
128
README.md
|
@ -1,19 +1,127 @@
|
|||
# Automatic `sh-elf-gcc` installer
|
||||
# SuperH toolchain: `sh-elf-gcc`
|
||||
|
||||
This script can be used to automatically compile and install a GCC cross-compiler targeting SH3 and SH4 calculators. The normal use is with GiteaPC:
|
||||
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++.
|
||||
|
||||
```
|
||||
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.
|
||||
|
||||
## Method 1: Using GiteaPC
|
||||
|
||||
The most common way to install this compiler is for the fxSDK, and it can be automated with [GiteaPC](/Lephenixnoir/GiteaPC):
|
||||
|
||||
```bash
|
||||
% giteapc install Lephenixnoir/sh-elf-gcc
|
||||
# After you install the libc, do it again
|
||||
```
|
||||
|
||||
You can also install manually. First install [`sh-elf-binutils`](https://gitea.planet-casio.com/Lephenixnoir/sh-elf-binutils), then run the GiteaPC Makefile with a manually-specified install prefix:
|
||||
This installs GCC (and binutils if missing) in the fxSDK's SuperH system root. Note that at first it will *not* install the C++ standard library libstdc++, because it requires the C standard library which is not available at this stage. After you install [fxlibc](/Vhex-Kernel-Core/fxlibc/) you should run GiteaPC's install command again, and this time the scripts will build libstdc++. The GiteaPC tutorial has more detailed instructions about this two-stage process.
|
||||
|
||||
```
|
||||
% make -f giteapc.make configure build install PREFIX=$HOME/.local
|
||||
```
|
||||
A `:any` configuration is provided in case you already have another version of GCC installed in the fxSDK sysroot and want to keep using it (ie. skip a version upgrade). This will mark this repository as installed, so other repositories depending on it can build, without actually compiling binutils.
|
||||
|
||||
An `any` configuration is provided in case GCC is already installed externally, to have this package installed without rebuilding it.
|
||||
|
||||
```
|
||||
```bash
|
||||
% giteapc install Lephenixnoir/sh-elf-gcc:any
|
||||
```
|
||||
|
||||
A `:clean` configuration is also provided if you want to clean up the source and build files automatically after the second pass. This frees up some disk space.
|
||||
|
||||
```bash
|
||||
% giteapc install Lephenixnoir/sh-elf-gcc:clean
|
||||
```
|
||||
|
||||
## Method 2: Manually running the scripts
|
||||
|
||||
Make sure to previously install:
|
||||
|
||||
* [fxSDK](https://gitea.planet-casio.com/Lephenixnoir/fxsdk) ≥ 2.8.1 (provides the sysroot)
|
||||
* [binutils for SuperH](https://gitea.planet-casio.com/Lephenixnoir/sh-elf-binutils)
|
||||
* Most of the [requirements for GCC](https://gcc.gnu.org/install/prerequisites.html) are checked in the binutils `configure.sh`
|
||||
|
||||
Follow the same procedure as for binutils; preferably use the same `PREFIX`.
|
||||
|
||||
```bash
|
||||
% make -f giteapc.make configure build install PREFIX="$HOME/.local"
|
||||
```
|
||||
|
||||
## Method 3: Fully manually
|
||||
|
||||
First here is the [guide for installing GCC](https://gcc.gnu.org/install/index.html) and here is [the one for libstdc++](https://gcc.gnu.org/onlinedocs/libstdc++/manual/setup.html).
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
```bash
|
||||
% patch -u -N -p0 < patches/gcc-11.1.0-libstdc++-v3-skip-dlopen.patch
|
||||
```
|
||||
|
||||
Also download prerequisites if you don't have them system-wide.
|
||||
|
||||
```bash
|
||||
% cd gcc-$VERSION
|
||||
% ./contrib/download_prerequisites
|
||||
% cd ..
|
||||
```
|
||||
|
||||
Now choose a prefix for install. If you're installing for the fxSDK, you must use `$(fxsdk path sysroot)`, otherwise anything that is isolated from the native OS is fine.
|
||||
|
||||
```bash
|
||||
% SYSROOT="$(fxsdk path sysroot)"
|
||||
```
|
||||
|
||||
Because the binutils is called `sh-elf-` and not `sh3eb-elf-`, GCC won't find it on PATH alone. Symlink them to `$SYSROOT/sh3eb-elf/bin`:
|
||||
|
||||
```bash
|
||||
% mkdir -p "$SYSROOT/sh3eb-elf/bin"
|
||||
% for TOOL in as ld ar ranlib; do \
|
||||
ln -sf $(command -v sh-elf-$TOOL) "$SYSROOT/sh3eb-elf/bin/$TOOL" \
|
||||
done
|
||||
```
|
||||
|
||||
You can then configure and build GCC.
|
||||
|
||||
```bash
|
||||
% mkdir build && cd build
|
||||
% ../gcc-$VERSION/configure \
|
||||
--prefix="$SYSROOT" \
|
||||
--target="sh3eb-elf" \
|
||||
--with-multilib-list="m3,m4-nofpu" \
|
||||
--enable-languages="c,c++" \
|
||||
--without-headers \
|
||||
--program-prefix="sh-elf-" \
|
||||
--enable-libssp \
|
||||
--enable-lto \
|
||||
--enable-clocale="generic" \
|
||||
--enable-libstdcxx-allocator \
|
||||
--disable-threads \
|
||||
--disable-libstdcxx-verbose \
|
||||
--enable-cxx-flags="-fno-exceptions"
|
||||
```
|
||||
|
||||
* `--without-headers`: Also indicates a cross-compiler in many scenarios.
|
||||
* `--enable-clocale="generic"`: Makes it easier to build the libstdc++.
|
||||
* `--enable-libstdcxx-allocator`: Same; `=malloc` might be an option too.
|
||||
* `--disable-threads`: Obvious.
|
||||
* `--disable-libstdcxx-verbose`: For space; we don't always have stderr anyway.
|
||||
* `--enable-cxx-flags="-fno-exceptions"`: Unless you have a kernel with exception support I guess.
|
||||
|
||||
Then build and install gcc.
|
||||
|
||||
```bash
|
||||
% make -j$(nproc) all-gcc all-target-libgcc
|
||||
% make install-strip-gcc install-strip-target-libgcc
|
||||
```
|
||||
|
||||
The next step is to install the libc. The standard fxSDK setup is to install [OpenLibm](https://gitea.planet-casio.com/Lephenixnoir/OpenLibm) and [fxlibc](https://gitea.planet-casio.com/Vhex-Kernel-Core/fxlibc/). Feel free to experiment. Make sure the includes and libraries end up in `$SYSROOT/sh3eb-elf/{bin,include}` since this is where GCC looks in hosted-like situations.
|
||||
|
||||
Once the libc is available we can come back to GCC's build folder and actually compile libstdc++.
|
||||
|
||||
```bash
|
||||
# Install the libc, then:
|
||||
% make -j$(nproc) all-target-libstdc++-v3
|
||||
% make install-strip-target-libstdc++-v3
|
||||
```
|
||||
|
||||
You can then clean up the source archive, source files, and build folder if needed. Link add-ins with `-lm -lstdc++ -lc -lgcc` in this order for the best results.
|
||||
|
|
21
build.sh
21
build.sh
|
@ -1,11 +1,24 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
# Avoid rebuilds of the same version
|
||||
[[ ! -d build ]] && exit 0
|
||||
[[ -e "build/giteapc-skip-rebuild.txt" ]] && exit 0
|
||||
|
||||
source util.sh
|
||||
cd build
|
||||
|
||||
echo "$TAG Compiling gcc (usually 10-20 minutes)..."
|
||||
run_quietly giteapc-build.log \
|
||||
make -j$(nproc) all-gcc all-target-libgcc
|
||||
# Number of processor cores
|
||||
if [[ $(uname) == "OpenBSD" || $(uname) == "Darwin" ]]; then
|
||||
cores=$(sysctl -n hw.ncpu)
|
||||
else
|
||||
cores=$(nproc)
|
||||
fi
|
||||
|
||||
if [[ -e "giteapc-build-libstdcxx.txt" ]]; then
|
||||
echo "$TAG Compiling libstdc++-v3..."
|
||||
run_quietly giteapc-build-libstdcxx.log \
|
||||
$MAKE_COMMAND -j"$cores" all-target-libstdc++-v3
|
||||
else
|
||||
echo "$TAG Compiling gcc (usually 10-20 minutes)..."
|
||||
run_quietly giteapc-build.log \
|
||||
$MAKE_COMMAND -j"$cores" all-gcc all-target-libgcc
|
||||
fi
|
||||
|
|
160
configure.sh
160
configure.sh
|
@ -4,38 +4,80 @@ source util.sh
|
|||
|
||||
VERSION=$1
|
||||
PREFIX="$2"
|
||||
URL="https://ftp.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION.tar.xz"
|
||||
URL="https://ftpmirror.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION.tar.xz"
|
||||
ARCHIVE=$(basename "$URL")
|
||||
|
||||
# Avoid rebuilds of the same version
|
||||
# Final location of gcc in the sysroot
|
||||
SYSROOT_GCC="$SYSROOT/bin/sh-elf-gcc"
|
||||
# Version string of any existing sh-elf-gcc in the sysroot
|
||||
SYSROOT_GCC_VERSION=
|
||||
# "1" if libstdc++-v3 is already in the install folder
|
||||
SYSROOT_HAS_LIBSTDCXX=
|
||||
# "1" if the conditions for building libstdc++-v3 are met
|
||||
CAN_BUILD_LIBSTDCXX=
|
||||
|
||||
existing_gcc="$PREFIX/bin/sh-elf-gcc"
|
||||
#---
|
||||
# Determine what parts of GCC are already installed and decide whether to build
|
||||
#---
|
||||
|
||||
if [[ -f "$existing_gcc" ]]; then
|
||||
existing_version=$(sh-elf-gcc --version | head -n 1 | grep -Eo '[0-9.]+$')
|
||||
if [[ $existing_version == $VERSION ]]; then
|
||||
echo "$TAG Version $VERSION already installed, skipping rebuild"
|
||||
if [[ -f "$SYSROOT_GCC" ]]; then
|
||||
SYSROOT_GCC_VERSION=$("$SYSROOT_GCC" --version | head -n 1 | grep -Eo '[0-9.]+$')
|
||||
|
||||
# TODO: Once we start using the full C++ library, check for libstdc++.a instead
|
||||
LIBSTDCXX_FILE=$("$SYSROOT_GCC" -print-file-name=libsupc++.a)
|
||||
LIBC_FILE=$("$SYSROOT_GCC" -print-file-name=libc.a)
|
||||
|
||||
if [[ "$LIBSTDCXX_FILE" != "libsupc++.a" ]]; then
|
||||
SYSROOT_HAS_LIBSTDCXX=1
|
||||
echo "$TAG libsupc++.a found, libstdc++-v3 is already built"
|
||||
fi
|
||||
|
||||
if [[ "$LIBC_FILE" != "libc.a" ]]; then
|
||||
CAN_BUILD_LIBSTDCXX=1
|
||||
[[ "$SYSROOT_HAS_LIBSTDCXX" != "1" ]] && \
|
||||
echo "$TAG libc.a found, we can build libstdc++-v3"
|
||||
else
|
||||
echo "$TAG libc.a not found, we cannot build libstdc++-v3"
|
||||
fi
|
||||
else
|
||||
echo "$TAG After installing the libc, rebuild here for libstdc++-v3"
|
||||
fi
|
||||
|
||||
if [[ "$SYSROOT_GCC_VERSION" = "$VERSION" ]]; then
|
||||
if [[ "$SYSROOT_HAS_LIBSTDCXX" = "1" ]]; then
|
||||
echo "$TAG GCC $VERSION with libstdc++-v3 already there; skipping rebuild"
|
||||
mkdir -p build
|
||||
touch build/giteapc-skip-rebuild.txt
|
||||
exit 0
|
||||
elif [[ "$CAN_BUILD_LIBSTDCXX" != "1" ]]; then
|
||||
echo "$TAG Cannot build libstdc++-v3 yet; skipping rebuild until next time"
|
||||
mkdir -p build
|
||||
touch build/giteapc-skip-rebuild.txt
|
||||
exit 0
|
||||
else
|
||||
echo "$TAG We will proceed with the second stage and build libstdc++-v3"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Aggressive parameter to avoid rebuilds
|
||||
|
||||
if [[ ! -z "$ACCEPT_ANY" ]]; then
|
||||
if command -v sh-elf-gcc >/dev/null 2>&1; then
|
||||
echo "$TAG sh-elf-gcc in PATH and ACCEPT_ANY is set, skipping build"
|
||||
exit 0
|
||||
fi
|
||||
if [[ ! -z "$ACCEPT_ANY" && ! -z "$SYSROOT_GCC_VERSION" ]]; then
|
||||
echo "$TAG GCC $VERSION already available; skipping rebuild as per ACCEPT_ANY"
|
||||
mkdir -p build
|
||||
touch build/giteapc-skip-rebuild.txt
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Download archive
|
||||
[[ -e "build/giteapc-skip-rebuild.txt" ]] && rm build/giteapc-skip-rebuild.txt
|
||||
|
||||
#---
|
||||
# Get sources
|
||||
#---
|
||||
|
||||
if [[ -f "$ARCHIVE" ]]; then
|
||||
echo "$TAG Found $ARCHIVE, skipping download"
|
||||
else
|
||||
echo "$TAG Downloading $URL..."
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl $URL -o $ARCHIVE
|
||||
curl $URL -L -o $ARCHIVE
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
wget -q --show-progress $URL -O $ARCHIVE
|
||||
else
|
||||
|
@ -44,31 +86,79 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
# Extract archive
|
||||
# Extract archive (OpenBSD-compliant version)
|
||||
if [[ -d "${ARCHIVE%.tar.*}" ]]; then
|
||||
echo "$TAG Found ${ARCHIVE%.tar.*}, skipping extraction"
|
||||
else
|
||||
echo "$TAG Extracting $ARCHIVE..."
|
||||
unxz -c < $ARCHIVE | tar -xf -
|
||||
|
||||
echo "$TAG Extracting $ARCHIVE..."
|
||||
tar -xJf $ARCHIVE
|
||||
if [[ "$VERSION" = "11.1.0" ]]; then
|
||||
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
|
||||
elif [[ "$VERSION" = "14.1.0" ]]; then
|
||||
echo "$TAG Applying patches/gcc-14.1.0-libgcc-use-soft-fp.patch..."
|
||||
patch -u -N -p0 < patches/gcc-14.1.0-libgcc-use-soft-fp.patch
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create build folder
|
||||
# Download prerequisites
|
||||
cd gcc-$VERSION
|
||||
./contrib/download_prerequisites
|
||||
cd ..
|
||||
|
||||
[[ -d "build" ]] && rm -rf build
|
||||
mkdir build
|
||||
#---
|
||||
# Configure
|
||||
#---
|
||||
|
||||
# Configure. GCC does not support make uninstall so we install in this
|
||||
# directory and later symlink executables to $PREFIX/bin.
|
||||
|
||||
PREFIX="$(pwd)"
|
||||
# We install in the sysroot and then symlink to the PREFIX folder in the path.
|
||||
|
||||
# Symlink as, ld, ar and ranlib, which gcc will not find by itself (we renamed
|
||||
# them from sh3eb-elf-* to sh-elf-* with --program-prefix).
|
||||
mkdir -p sh3eb-elf/bin
|
||||
ln -sf $(command -v sh-elf-as) sh3eb-elf/bin/as
|
||||
ln -sf $(command -v sh-elf-ld) sh3eb-elf/bin/ld
|
||||
ln -sf $(command -v sh-elf-ar) sh3eb-elf/bin/ar
|
||||
ln -sf $(command -v sh-elf-ranlib) sh3eb-elf/bin/ranlib
|
||||
mkdir -p "$SYSROOT/sh3eb-elf/bin"
|
||||
for TOOL in as ld ar ranlib; do
|
||||
if ! command -v sh-elf-$TOOL >/dev/null 2>&1; then
|
||||
echo "error: sh-elf-$TOOL not found in PATH!" >&2
|
||||
exit 1
|
||||
fi
|
||||
ln -sf $(command -v sh-elf-$TOOL) "$SYSROOT/sh3eb-elf/bin/$TOOL"
|
||||
done
|
||||
|
||||
cd build
|
||||
# OpenBSD apparently installs these in /usr/local
|
||||
if [[ $(uname) == "OpenBSD" ]]; then
|
||||
EXTRA_ARGS="--with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local"
|
||||
else
|
||||
EXTRA_ARGS=
|
||||
fi
|
||||
|
||||
echo "$TAG Configuring gcc..."
|
||||
run_quietly giteapc-configure.log \
|
||||
../gcc-$VERSION/configure --prefix="$PREFIX" --target=sh3eb-elf --with-multilib-list=m3,m4-nofpu --enable-languages=c,c++ --without-headers --with-newlib --program-prefix=sh-elf- --enable-libssp --enable-lto
|
||||
# In libstdc++-v3 mode, don't reconfigure to avoid recompiling
|
||||
if [[ "$SYSROOT_GCC_VERSION" = "$VERSION" && "$SYSROOT_HAS_LIBSTDCXX" != "1" && "$CAN_BUILD_LIBSTDCXX" = "1" ]]; then
|
||||
touch build/giteapc-build-libstdcxx.txt
|
||||
elif [[ "$SYSROOT_GCC_VERSION" != "$VERSION" ]]; then
|
||||
echo "$TAG Configuring gcc..."
|
||||
[[ -d build ]] && rm -rf build
|
||||
mkdir build
|
||||
|
||||
cd build
|
||||
run_quietly giteapc-configure.log \
|
||||
../gcc-$VERSION/configure \
|
||||
--prefix="$SYSROOT" \
|
||||
--target="sh3eb-elf" \
|
||||
--with-multilib-list="m3,m4-nofpu" \
|
||||
--enable-languages="c,c++" \
|
||||
--without-headers \
|
||||
--program-prefix="sh-elf-" \
|
||||
--enable-libssp \
|
||||
--enable-lto \
|
||||
--enable-clocale="generic" \
|
||||
--enable-libstdcxx-allocator \
|
||||
--disable-threads \
|
||||
--disable-libstdcxx-verbose \
|
||||
--enable-cxx-flags="-fno-exceptions" \
|
||||
$EXTRA_ARGS
|
||||
cd ..
|
||||
else
|
||||
echo "$TAG GCC already built, can't build libstdc++-v3; skipping!"
|
||||
touch build/giteapc-skip-rebuild.txt
|
||||
exit 0
|
||||
fi
|
||||
|
|
4
giteapc-config-clean.make
Normal file
4
giteapc-config-clean.make
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Clean the build products after install
|
||||
CONFIG_CLEAN=1
|
||||
|
||||
export CONFIG_CLEAN
|
|
@ -2,7 +2,7 @@
|
|||
# giteapc: depends=Lephenixnoir/sh-elf-binutils
|
||||
|
||||
PREFIX ?= $(GITEAPC_PREFIX)
|
||||
VERSION = 10.2.0
|
||||
VERSION = 14.1.0
|
||||
|
||||
-include giteapc-config.make
|
||||
|
||||
|
|
39
install.sh
39
install.sh
|
@ -1,24 +1,33 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
# Avoid rebuilds of the same version
|
||||
[[ ! -d build ]] && exit 0
|
||||
[[ -e "build/giteapc-skip-rebuild.txt" ]] && exit 0
|
||||
|
||||
source util.sh
|
||||
PREFIX="$1"
|
||||
|
||||
cd build
|
||||
echo "$TAG Installing to local folder..."
|
||||
run_quietly giteapc-install.log \
|
||||
make install-strip-gcc install-strip-target-libgcc
|
||||
|
||||
if [[ -e "giteapc-build-libstdcxx.txt" ]]; then
|
||||
echo "$TAG Installing libstdc++-v3 to the SuperH sysroot..."
|
||||
run_quietly giteapc-install-libstdcxx.log \
|
||||
$MAKE_COMMAND -j"$cores" install-strip-target-libstdc++-v3
|
||||
else
|
||||
echo "$TAG Installing GCC to the SuperH sysroot..."
|
||||
run_quietly giteapc-install.log \
|
||||
$MAKE_COMMAND install-strip-gcc install-strip-target-libgcc
|
||||
|
||||
# Symbolic link executables to $PREFIX/bin
|
||||
echo "$TAG Symlinking sysroot binaries to $PREFIX/bin..."
|
||||
mkdir -p "$PREFIX/bin"
|
||||
for f in "$SYSROOT/bin"/*; do
|
||||
ln -sf "$f" "$PREFIX/${f#$SYSROOT/}"
|
||||
done
|
||||
fi
|
||||
|
||||
cd ..
|
||||
|
||||
# Symbolic link executables to $PREFIX/bin
|
||||
echo "$TAG Symlinking binaries..."
|
||||
for x in bin/*; do
|
||||
ln -sf "$(pwd)/$x" "$PREFIX/$x"
|
||||
done
|
||||
|
||||
# Cleanup build files
|
||||
echo "$TAG Cleaning up build files..."
|
||||
rm -rf gcc-*/ gcc-*.tar.*
|
||||
rm -rf build/
|
||||
# Cleanup build files after installing libstdc++
|
||||
if [[ ! -z "$CONFIG_CLEAN" && -e "build/giteapc-build-libstdcxx.txt" ]]; then
|
||||
echo "$TAG Cleaning up build files..."
|
||||
rm -rf gcc-*/ gcc-*.tar.* build/
|
||||
fi
|
||||
|
|
65
patches/gcc-11.1.0-libstdc++-v3-skip-dlopen.patch
Normal file
65
patches/gcc-11.1.0-libstdc++-v3-skip-dlopen.patch
Normal file
|
@ -0,0 +1,65 @@
|
|||
# Building libstdc++-v3 for a bare-bones compiler is somewhat in a gray area
|
||||
# since we don't have a full hosted system to target. From a version of GCC to
|
||||
# the next this might break in minor ways.
|
||||
#
|
||||
# Here, the issue is the reliance on a dlopen() check which cannot be
|
||||
# completed because we don't have link tests. The intent of the configure
|
||||
# script is to skip it for cross-compilers, which is materialized by the check
|
||||
# for --with-newlib (which is somewhat abused to mean "no libc").
|
||||
#
|
||||
# However, building with --with-newlib is not quite right since we have our
|
||||
# own libc and fails due to it enabling small newlib-specific bits of code
|
||||
# that don't compile with the fxlibc.
|
||||
#
|
||||
# Instead, we disable the test when --without-headers is specified, which is
|
||||
# the case in our configuration. This extra condition is already part of the
|
||||
# upstreamed source in GCC 12.1.0, so this is basically a backport. We also
|
||||
# backport disabling the GLIBCXX_CROSSCONFIG which would block the build.
|
||||
#
|
||||
# Explanations about the gray area:
|
||||
# <https://gcc.gnu.org/legacy-ml/gcc/2008-03/msg00515.html>
|
||||
# Commit introducing this test in GCC 12.1.0:
|
||||
# <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=68c2e9e9234cb301e9e81792cad233a41e797792>
|
||||
# GCC bug motivating the commit:
|
||||
# <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103866>
|
||||
|
||||
--- gcc-11.1.0/libstdc++-v3/configure.ac 2021-04-27 12:00:16.000000000 +0200
|
||||
+++ gcc-11.1.0/libstdc++-v3/configure2.ac 2022-08-15 22:53:21.730140593 +0200
|
||||
@@ -90,7 +90,7 @@
|
||||
GLIBCXX_CONFIGURE
|
||||
|
||||
# Libtool setup.
|
||||
-if test "x${with_newlib}" != "xyes" && test "x${with_avrlibc}" != "xyes"; then
|
||||
+if test "x${with_newlib}" != "xyes" && test "x${with_avrlibc}" != "xyes" && test "x${with_headers}" != "xno"; then
|
||||
AC_LIBTOOL_DLOPEN
|
||||
fi
|
||||
AM_PROG_LIBTOOL
|
||||
@@ -353,7 +353,7 @@
|
||||
|
||||
AC_DEFINE(HAVE_ICONV)
|
||||
AC_DEFINE(HAVE_MEMALIGN)
|
||||
- else
|
||||
+ elif test "x${with_headers}" != "xno"; then
|
||||
GLIBCXX_CROSSCONFIG
|
||||
fi
|
||||
|
||||
--- gcc-11.1.0/libstdc++-v3/configure 2022-08-15 22:37:29.043460208 +0200
|
||||
+++ gcc-11.1.0/libstdc++-v3/configure2 2022-08-15 22:37:03.403459840 +0200
|
||||
@@ -5903,7 +5903,7 @@
|
||||
|
||||
|
||||
# Libtool setup.
|
||||
-if test "x${with_newlib}" != "xyes" && test "x${with_avrlibc}" != "xyes"; then
|
||||
+if test "x${with_newlib}" != "xyes" && test "x${with_avrlibc}" != "xyes" && test "x${with_headers}" != "xno"; then
|
||||
enable_dlopen=yes
|
||||
|
||||
|
||||
@@ -29266,7 +29266,7 @@
|
||||
|
||||
$as_echo "#define HAVE_MEMALIGN 1" >>confdefs.h
|
||||
|
||||
- else
|
||||
+ elif test "x${with_headers}" != "xno"; then
|
||||
|
||||
# Base decisions on target environment.
|
||||
case "${host}" in
|
97
patches/gcc-14.1.0-libgcc-use-soft-fp.patch
Normal file
97
patches/gcc-14.1.0-libgcc-use-soft-fp.patch
Normal file
|
@ -0,0 +1,97 @@
|
|||
--- gcc-14.1.0/libgcc/config.host 2024-07-05 12:40:14.186620944 +0200
|
||||
+++ gcc-14.1.0/libgcc/config.host 2024-07-05 12:40:59.419954141 +0200
|
||||
@@ -1401,7 +1401,7 @@
|
||||
md_unwind_header=s390/tpf-unwind.h
|
||||
;;
|
||||
sh-*-elf* | sh[12346l]*-*-elf*)
|
||||
- tmake_file="$tmake_file sh/t-sh t-crtstuff-pic t-fdpbit"
|
||||
+ tmake_file="$tmake_file sh/t-sh t-crtstuff-pic t-softfp-sfdf t-softfp"
|
||||
extra_parts="$extra_parts crt1.o crti.o crtn.o crtbeginS.o crtendS.o \
|
||||
libic_invalidate_array_4-100.a \
|
||||
libic_invalidate_array_4-200.a \
|
||||
--- /dev/null 2024-06-26 21:19:11.279977120 +0200
|
||||
+++ gcc-14.1.0/libgcc/config/sh/sfp-machine.h 2024-07-05 12:42:07.016620609 +0200
|
||||
@@ -0,0 +1,83 @@
|
||||
+/* Software floating-point machine description for SuperH.
|
||||
+
|
||||
+ Copyright (C) 2016-2024 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/>. */
|
||||
+
|
||||
+#define _FP_W_TYPE_SIZE 32
|
||||
+#define _FP_W_TYPE unsigned long
|
||||
+#define _FP_WS_TYPE signed long
|
||||
+#define _FP_I_TYPE long
|
||||
+
|
||||
+#define _FP_MUL_MEAT_S(R,X,Y) \
|
||||
+ _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
|
||||
+#define _FP_MUL_MEAT_D(R,X,Y) \
|
||||
+ _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
|
||||
+#define _FP_MUL_MEAT_Q(R,X,Y) \
|
||||
+ _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
|
||||
+
|
||||
+#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(S,R,X,Y)
|
||||
+#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
|
||||
+#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
|
||||
+
|
||||
+#define _FP_NANFRAC_B _FP_QNANBIT_B
|
||||
+#define _FP_NANFRAC_H _FP_QNANBIT_H
|
||||
+#define _FP_NANFRAC_S _FP_QNANBIT_S
|
||||
+#define _FP_NANFRAC_D _FP_QNANBIT_D, 0
|
||||
+#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0
|
||||
+
|
||||
+/* The type of the result of a floating point comparison. This must
|
||||
+ match __libgcc_cmp_return__ in GCC for the target. */
|
||||
+typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
|
||||
+#define CMPtype __gcc_CMPtype
|
||||
+
|
||||
+#define _FP_NANSIGN_B 0
|
||||
+#define _FP_NANSIGN_H 0
|
||||
+#define _FP_NANSIGN_S 0
|
||||
+#define _FP_NANSIGN_D 0
|
||||
+#define _FP_NANSIGN_Q 0
|
||||
+
|
||||
+#define _FP_KEEPNANFRACP 0
|
||||
+#define _FP_QNANNEGATEDP 0
|
||||
+
|
||||
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
|
||||
+ do { \
|
||||
+ R##_s = _FP_NANSIGN_##fs; \
|
||||
+ _FP_FRAC_SET_##wc(R,_FP_NANFRAC_##fs); \
|
||||
+ R##_c = FP_CLS_NAN; \
|
||||
+ } while (0)
|
||||
+
|
||||
+#define _FP_TININESS_AFTER_ROUNDING 1
|
||||
+
|
||||
+#define __LITTLE_ENDIAN 1234
|
||||
+#define __BIG_ENDIAN 4321
|
||||
+
|
||||
+#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
+#define __BYTE_ORDER __BIG_ENDIAN
|
||||
+#else
|
||||
+#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
+#endif
|
||||
+
|
||||
+/* Define ALIASNAME as a strong alias for NAME. */
|
||||
+# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
|
||||
+# define _strong_alias(name, aliasname) \
|
||||
+ extern __typeof (name) aliasname __attribute__ ((alias (#name)));
|
18
uninstall.sh
18
uninstall.sh
|
@ -3,12 +3,16 @@
|
|||
source util.sh
|
||||
PREFIX="$1"
|
||||
|
||||
# Remove symlinks
|
||||
echo "$TAG Removing symlinks to binaries..."
|
||||
for x in bin/*; do
|
||||
rm "$PREFIX/$x"
|
||||
echo "$TAG Removing symlinks to $PREFIX/bin..."
|
||||
TOOLS="c++ cpp g++ gcc gcc-ar gcc-nm gcc-ranlib gcov gcov-dump gcov-tool \
|
||||
lto-dump"
|
||||
|
||||
for t in $TOOLS; do
|
||||
[[ -L "$PREFIX/bin/sh-elf-$t" ]] && rm "$PREFIX/bin/sh-elf-$t"
|
||||
done
|
||||
for l in "$PREFIX"/bin/sh3eb-elf-gcc-*; do
|
||||
[[ -L "$l" ]] && rm "$l"
|
||||
done
|
||||
|
||||
# Remove local files
|
||||
echo "$TAG Removing installed files..."
|
||||
rm -rf bin/ include/ lib/ libexec/ share/
|
||||
echo "$TAG Other files are managed by the fxSDK's SuperH sysroot"
|
||||
echo "$TAG Uninstall Lephenixnoir/fxsdk to clean up the sysroot"
|
||||
|
|
16
util.sh
16
util.sh
|
@ -1,5 +1,21 @@
|
|||
TAG="<sh-elf-gcc>"
|
||||
|
||||
if command -v gmake >/dev/null 2>&1; then
|
||||
MAKE_COMMAND=gmake
|
||||
else
|
||||
MAKE_COMMAND=make
|
||||
fi
|
||||
|
||||
if ! command -v fxsdk >/dev/null 2>&1; then
|
||||
echo "$TAG error: fxSDK is not installed"
|
||||
exit 1
|
||||
elif ! fxsdk path sysroot >/dev/null 2>&1; then
|
||||
echo "$TAG error: need fxSDK ≥ 2.9 with 'path' command"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SYSROOT="$(fxsdk path sysroot)"
|
||||
|
||||
run_quietly() {
|
||||
out="$1"
|
||||
shift 1
|
||||
|
|
Loading…
Add table
Reference in a new issue