160 lines
5.4 KiB
Bash
160 lines
5.4 KiB
Bash
# Maintainer: Fabien Chouteau <chouteau@adacore.com>
|
|
# Based on mingw-w64-arm-none-eabi-gcc
|
|
|
|
_realname=gcc
|
|
_target=riscv64-unknown-elf
|
|
|
|
pkgbase=mingw-w64-${_target}-${_realname}
|
|
pkgname=("${MINGW_PACKAGE_PREFIX}-${_target}-${_realname}")
|
|
pkgver=15.1.0
|
|
pkgrel=2
|
|
pkgdesc='GNU Tools for RISC-V Embedded Processors - GCC (mingw-w64)'
|
|
arch=('any')
|
|
mingw_arch=('mingw64' 'ucrt64' 'clang64')
|
|
url='https://www.gnu.org/software/gcc/gcc.html'
|
|
msys2_references=(
|
|
"cpe: cpe:/a:gnu:gcc"
|
|
)
|
|
license=('spdx:GPL-3.0-or-later')
|
|
groups=("${MINGW_PACKAGE_PREFIX}-${_target}-toolchain")
|
|
depends=(
|
|
"${MINGW_PACKAGE_PREFIX}-${_target}-binutils"
|
|
"${MINGW_PACKAGE_PREFIX}-${_target}-newlib"
|
|
"${MINGW_PACKAGE_PREFIX}-gmp"
|
|
"${MINGW_PACKAGE_PREFIX}-isl"
|
|
"${MINGW_PACKAGE_PREFIX}-libwinpthread"
|
|
"${MINGW_PACKAGE_PREFIX}-mpc"
|
|
"${MINGW_PACKAGE_PREFIX}-mpfr"
|
|
"${MINGW_PACKAGE_PREFIX}-zlib"
|
|
"${MINGW_PACKAGE_PREFIX}-zstd"
|
|
)
|
|
makedepends=(
|
|
"${MINGW_PACKAGE_PREFIX}-cc"
|
|
"${MINGW_PACKAGE_PREFIX}-autotools"
|
|
)
|
|
options=('!emptydirs' '!strip')
|
|
source=("https://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/gcc-${pkgver}.tar.xz")
|
|
sha256sums=('e2b09ec21660f01fecffb715e0120265216943f038d0e48a9868713e54f06cea')
|
|
|
|
prepare() {
|
|
cd "${srcdir}"/gcc-${pkgver}
|
|
|
|
mkdir gcc-build-${MSYSTEM}
|
|
mkdir gcc-build-nano-${MSYSTEM}
|
|
}
|
|
|
|
_build_gcc() {
|
|
local _languages=$1 # Comma separated list of languages support to build
|
|
|
|
if [[ ${CC} == clang ]]; then
|
|
CFLAGS+=" -w"
|
|
CXXFLAGS+=" -w"
|
|
fi
|
|
|
|
declare -a _extra_config
|
|
if [[ ${CC} == clang ]]; then
|
|
_extra_config+=("--disable-win32-utf8-manifest")
|
|
fi
|
|
|
|
local _GCC_LDFLAGS="${LDFLAGS} -Wl,--disable-dynamicbase,--image-base=0x400000"
|
|
../configure \
|
|
--prefix=${MINGW_PREFIX} \
|
|
--target=${_target} \
|
|
--with-native-system-header-dir=${MINGW_PREFIX}/include \
|
|
--libexecdir=${MINGW_PREFIX}/lib \
|
|
--enable-languages=${_languages} \
|
|
--enable-plugins \
|
|
--disable-decimal-float \
|
|
--disable-libffi \
|
|
--disable-libgomp \
|
|
--disable-libmudflap \
|
|
--disable-libquadmath \
|
|
--disable-libssp \
|
|
--disable-libstdcxx-pch \
|
|
--disable-nls \
|
|
--disable-shared \
|
|
--disable-threads \
|
|
--disable-tls \
|
|
--disable-libada \
|
|
--with-gnu-as \
|
|
--with-gnu-ld \
|
|
--with-system-zlib \
|
|
--with-newlib \
|
|
--with-headers=${MINGW_PREFIX}/${_target}/include \
|
|
--with-python-dir=share/gcc-${_target} \
|
|
--with-gmp \
|
|
--with-mpfr \
|
|
--with-mpc \
|
|
--with-isl \
|
|
--with-libelf \
|
|
--enable-gnu-indirect_function \
|
|
--enable-multilib \
|
|
--with-host-libstdcxx="-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm" \
|
|
--enable-linker-plugin-flags='LDFLAGS=-static-libstdc++\ -static-libgcc\ '"${LDFLAGS// /\\ }"'\ -Wl,--stack,12582912' \
|
|
"${_extra_config[@]}" \
|
|
LDFLAGS="${_GCC_LDFLAGS}"
|
|
|
|
make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
|
|
}
|
|
|
|
build() {
|
|
local _languages="c,c++"
|
|
|
|
cd "${srcdir}"/gcc-${pkgver}/gcc-build-${MSYSTEM}
|
|
|
|
export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
|
|
export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
|
|
_build_gcc ${_languages}
|
|
|
|
# Build libstdc++ without exceptions support (the 'nano' variant)
|
|
cd "${srcdir}"/gcc-${pkgver}/gcc-build-nano-${MSYSTEM}
|
|
|
|
export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'
|
|
export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -fno-exceptions'
|
|
# Only C and C++ are required for the nano build
|
|
_build_gcc "c,c++"
|
|
}
|
|
|
|
package() {
|
|
cd "${srcdir}"/gcc-${pkgver}/gcc-build-${MSYSTEM}
|
|
|
|
make DESTDIR="${pkgdir}" install
|
|
|
|
cd "${srcdir}"/gcc-${pkgver}/gcc-build-nano-${MSYSTEM}
|
|
|
|
mkdir "${pkgdir}"/nano-install-${MSYSTEM}
|
|
|
|
make DESTDIR="${pkgdir}/nano-install-${MSYSTEM}" install
|
|
|
|
cd "${pkgdir}"${MINGW_PREFIX}
|
|
|
|
# we need only libstdc nano files
|
|
multilibs=`ls "${pkgdir}"/nano-install-${MSYSTEM}${MINGW_PREFIX}/${_target}/lib/ | grep ^rv`
|
|
echo "copy libstdc++_nano.a for each of:" ${multilibs}
|
|
for multilib in ${multilibs[@]}; do
|
|
echo "Listing ABIs for:" ${multilib}
|
|
echo "in" "${pkgdir}"/nano-install-${MSYSTEM}${MINGW_PREFIX}/${_target}/lib/${multilib}/
|
|
abis=`ls "${pkgdir}"/nano-install-${MSYSTEM}${MINGW_PREFIX}/${_target}/lib/${multilib}/`
|
|
echo ${multilib} " ABI(s):" ${abis}
|
|
for abi in ${abis[@]}; do
|
|
dir=${multilib}/${abi}
|
|
from_dir="${pkgdir}"/nano-install-${MSYSTEM}${MINGW_PREFIX}/${_target}/lib/"$dir"
|
|
to_dir=${_target}/lib/"$dir"
|
|
|
|
cp -f "$from_dir"/libstdc++.a "$to_dir"/libstdc++_nano.a
|
|
cp -f "$from_dir"/libsupc++.a "$to_dir"/libsupc++_nano.a
|
|
done
|
|
done
|
|
rm -r "${pkgdir}"/nano-install-${MSYSTEM}
|
|
|
|
# strip target binaries
|
|
find lib/gcc/${_target}/${pkgver} ${_target}/lib -type f -and \( -name \*.a -or -name \*.o \) -exec ${_target}-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc '{}' \;
|
|
|
|
# strip host binaries
|
|
find bin/ lib/gcc/${_target}/${pkgver} -type f -and \( -executable \) -exec strip '{}' \;
|
|
|
|
# Remove files that conflict with host gcc package
|
|
rm -r share/man/man7
|
|
rm -r share/info
|
|
}
|