1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-22 02:35:23 +03:00
aports/community/gcc-cross-embedded/APKBUILD
psykose e84e0c7f56 community/gcc-cross-embedded: add default targets for armv7
these are used downstream in postmarketos
2023-02-22 19:21:30 +01:00

197 lines
5.8 KiB
Text

# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Based upon Alpine's avr-gcc and Arch Linux's arm-none-eabi-gcc, to which
# the following people contributed:
# Contributor: Pedro Filipe <xpecex@outlook.com>
# Contributor: Stefan Wagner <stw@bit-strickerei.de>
# Contributor: Anatol Pomozov <anatol.pomozov@gmail.com>
# Contributor: Martin Schmölzer <mschmoelzer@gmail.com>
pkgname=gcc-cross-embedded
pkgver=12.2.0
pkgrel=8
pkgdesc="C compilers from the GNU Compiler Collection for embedded targets"
url="https://gcc.gnu.org/"
depends="gcc"
makedepends="bash linux-headers gmp-dev mpfr-dev mpc1-dev zlib-dev isl-dev python3"
arch="aarch64 armv7 ppc64le x86_64 x86"
license="GPL-3.0-or-later"
source="https://mirrors.kernel.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz
newlib-getentropy.patch"
options="!check"
builddir="$srcdir/gcc-$pkgver"
# classify targets as exotic or mainstream. Only build support for
# exotic targets on typical developer / CI hardware (x86_86, aarach64).
_targets_mainstream="
arm-none-eabi
riscv-none-elf
"
_targets_exotic="
msp430-elf
or1k-elf
aarch64-none-elf
"
# This specifies the supported RISC-V multilib ISA extensions.
# For more information on the syntax, see the comment in gcc/config/riscv/multilib-generator.
#
# The selected ISA extensions are modeled after the Debian package.
# See: https://salsa.debian.org/debian/gcc-riscv64-unknown-elf/-/blob/4a1de76060cb8721c06bcfb4c846bc82ee6b3fc3/debian/patches/0002-Add-more-multi-lib-for-rv32-and-rv64.patch
_riscv_multilib="rv32e-ilp32e--c;rv32ea-ilp32e--m;\
rv32em-ilp32e--c;rv32eac-ilp32e--;rv32emac-ilp32e--;\
rv32i-ilp32--c;rv32ia-ilp32--m;rv32im-ilp32--c;\
rv32if-ilp32f-rv32ifd-c;rv32iaf-ilp32f-rv32imaf,rv32iafc-d;\
rv32imf-ilp32f-rv32imfd-c;rv32iac-ilp32--;rv32imac-ilp32--;\
rv32imafc-ilp32f-rv32imafdc-;rv32ifd-ilp32d--c;rv32imfd-ilp32d--c;\
rv32iafd-ilp32d-rv32imafd,rv32iafdc-;rv32imafdc-ilp32d--;rv64i-lp64--c;\
rv64ia-lp64--m;rv64im-lp64--c;rv64if-lp64f-rv64ifd-c;\
rv64iaf-lp64f-rv64imaf,rv64iafc-d;rv64imf-lp64f-rv64imfd-c;\
rv64iac-lp64--;rv64imac-lp64--;rv64imafc-lp64f-rv64imafdc-;\
rv64ifd-lp64d--m,c;rv64iafd-lp64d-rv64imafd,rv64iafdc-;rv64imafdc-lp64d--"
case "$CARCH" in
x86_64|aarch64)
# support all targets on typical workstation / notebook / CI servers
_targets="$_targets_mainstream $_targets_exotic"
;;
*)
# support only mainstream targets on exotic hosts
_targets="$_targets_mainstream"
;;
esac
for target in $_targets; do
targetnorm="${target//-/_}"
subpackages="gcc-$target:$targetnorm $subpackages"
makedepends="$makedepends binutils-$target"
done
prepare() {
default_prepare
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
for dir in libiberty gcc; do
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" $dir/configure
done
}
_build_gcc() {
case "$target" in
# Support M and R architecture profiles for ARM
arm-none-eabi) _target_specific_flags="--with-multilib-list=rmprofile" ;;
riscv-none-elf) _target_specific_flags="--with-multilib-generator=$_riscv_multilib" ;;
*) _target_specific_flags="" ;;
esac
msg "Running ./configure for $target"
"$builddir"/configure \
--target=$target \
--prefix=/usr \
--with-sysroot=/usr/$target \
--with-native-system-header-dir=/include \
--with-headers=/usr/$target/include \
--with-python-dir=share/gcc-$target \
--libexecdir=/usr/lib \
--infodir=/deleteme/info \
--htmldir=/deleteme/html \
--pdfdir=/deleteme/pdf \
--mandir=/deleteme/man \
--enable-languages=c \
--enable-lto \
--enable-plugins \
--enable-gnu-indirect-function \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-nls \
--disable-shared \
--disable-threads \
--disable-werror \
--with-gmp \
--with-gnu-as \
--with-gnu-ld \
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
--with-isl \
--with-libelf \
--with-mpc \
--with-mpfr \
--with-newlib \
--with-system-zlib \
--with-pkgversion='Alpine Linux' \
$_target_specific_flags
msg "Running make for $target"
make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
}
build() {
for target in $_targets; do
# Build "regular" variant
workingdir="$srcdir/build-$target"
mkdir "$workingdir"
cd "$workingdir"
export CFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections'
export CXXFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections -fno-use-cxa-atexit'
_build_gcc
done
}
package() {
for target in $_targets; do
depends="$depends gcc-$target"
done
mkdir -p "$pkgdir"
}
_install_subpkg() {
target="${subpkgname#gcc-}"
pkgdesc="C compiler of the GNU Compiler Collection for $target targets"
depends="$depends binutils-$target"
workingdir="$srcdir/build-$target"
cd "$workingdir"
make install DESTDIR="$subpkgdir" -j1
# Delete documentation. (The user can use the host GCC doc instead)
rm -rf "$subpkgdir"/deleteme
# Delete libcc1.so*, which is already part of the host's gcc
rm -f "$subpkgdir"/usr/lib/libcc1.so*
# Strip libs using target binutils
find "$subpkgdir"/usr/lib -type f -name "*.a" -exec /usr/bin/$target-strip --strip-debug '{}' \;
# Strip executables using host binutils
find "$subpkgdir"/usr/bin -type f -executable -exec strip '{}' \;
}
arm_none_eabi() {
_install_subpkg
}
mips_mti_elf() {
_install_subpkg
}
msp430_elf() {
_install_subpkg
}
or1k_elf() {
_install_subpkg
}
riscv_none_elf() {
_install_subpkg
}
aarch64_none_elf() {
_install_subpkg
}
sha512sums="
e9e857bd81bf7a370307d6848c81b2f5403db8c7b5207f54bce3f3faac3bde63445684092c2bc1a2427cddb6f7746496d9fbbef05fbbd77f2810b2998f1f9173 gcc-12.2.0.tar.xz
52e45ba12be74ce6f740eff3a79e3da87c80b06275fd00b2a1193b052fd0891e7c4c09fd6a9c204a82178c135318d69db3e250f12c37eca72edb1e3c0b0be2db newlib-getentropy.patch
"