testing/gcc-cross-embedded: Add AVR

Add AVR as subpackage
parent 40f45860
Pipeline #71542 canceled with stages
in 19 seconds
......@@ -5,20 +5,24 @@
# Contributor: Stefan Wagner <stw@bit-strickerei.de>
# Contributor: Anatol Pomozov <anatol.pomozov@gmail.com>
# Contributor: Martin Schmölzer <mschmoelzer@gmail.com>
_targets="
_newlib_targets="
arm-none-eabi
mips-mti-elf
msp430-elf
riscv-none-elf
aarch64-none-elf
"
_other_targets="
avr
"
# or1k-elf fails to build on 32-bit architectures
case "$CARCH" in
x86_64|aarch64|ppc64le|mips64) _targets="$_targets or1k-elf"
x86_64|aarch64|ppc64le|mips64) _newlib_targets="$_newlib_targets or1k-elf"
esac
_targets="$_other_targets $_newlib_targets"
pkgname=gcc-cross-embedded
pkgver=10.2.0
pkgrel=2
pkgrel=3
pkgdesc="The GNU Compiler Collection for embedded targets"
url="http://gcc.gnu.org"
depends="gcc"
......@@ -26,11 +30,15 @@ makedepends="bash linux-headers gmp-dev mpfr-dev mpc1-dev zlib-dev isl-dev"
arch="all !s390x !mips !mips64" # fails on s390x and mips with error message:
# 'internal compiler error: Segmentation fault'
license="GPL-3.0-or-later"
for target in $_targets; do
targetnorm="${target//-/_}"
subpackages="gcc-$target:$targetnorm $subpackages"
makedepends="$makedepends binutils-$target newlib-$target-stage1"
for _target in $_targets; do
_targetnorm="${_target//-/_}"
subpackages="gcc-$_target:$_targetnorm $subpackages"
makedepends="$makedepends binutils-$_target"
done
for _target in $_newlib_targets; do
makedepends="$makedepends newlib-$_target-stage1"
done
makedepends="$makedepends"
source="https://mirrors.kernel.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz"
......@@ -48,20 +56,27 @@ prepare() {
}
_build_gcc() {
case "$target" in
case "$_target" in
# Support M and R architecture profiles for ARM
arm-none-eabi) _target_specific_flags="--with-multilib-list=rmprofile" ;;
*) _target_specific_flags="" ;;
arm-none-eabi)
_specific_flags="--with-multilib-list=rmprofile --with-newlib"
;;
avr)
_specific_flags="--with-avrlibc"
;;
*)
_specific_flags="--with-newlib"
;;
esac
msg "Running ./configure for $target"
msg "Running ./configure for $_target"
"$builddir"/configure \
--target=$target \
--target=$_target \
--prefix=/usr \
--with-sysroot=/usr/$target \
--with-sysroot=/usr/$_target \
--with-native-system-header-dir=/include \
--with-headers=/usr/$target/include \
--with-python-dir=share/gcc-$target \
--with-headers=/usr/$_target/include \
--with-python-dir=share/gcc-$_target \
--libexecdir=/usr/lib \
--infodir=/deleteme/info \
--htmldir=/deleteme/html \
......@@ -90,64 +105,78 @@ _build_gcc() {
--with-libelf \
--with-mpc \
--with-mpfr \
--with-newlib \
--with-system-zlib \
--with-pkgversion='Alpine Linux' \
$_target_specific_flags
$_specific_flags
msg "Running make for $target"
msg "Running make for $_target"
make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
}
build() {
for target in $_targets; do
# First: Build compilers not using newlib. The are build in only one flavor.
for _target in $_other_targets; do
_workingdir="$srcdir/build-$_target"
mkdir "$_workingdir"
cd "$_workingdir"
export CFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections -fno-exceptions'
export CXXFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections -fno-exceptions'
_build_gcc
done
# Second: Build compilers using newlib. They come in two flavors: The
# regular variant and the nano variant, which trades in features and speed
# for smaller size.
for _target in $_newlib_targets; do
# Build "regular" variant
workingdir="$srcdir/build-$target"
mkdir "$workingdir"
cd "$workingdir"
_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'
_build_gcc
# Rebuild without exceptions to generate nano variant of libstc++
workingdir="$srcdir/build-$target-nano"
mkdir "$workingdir"
cd "$workingdir"
export CFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections -fno-exceptions'
export CXXFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections -fno-exceptions'
_workingdir="$srcdir/build-$_target-nano"
mkdir "$_workingdir"
cd "$_workingdir"
export CFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections -fno-exceptions'
export CXXFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections -fno-exceptions'
_build_gcc
done
}
package() {
for target in $_targets; do
depends="$depends gcc-$target"
for _target in $_targets; do
depends="$depends gcc-$_target"
done
mkdir -p "$pkgdir"
}
_install_subpkg() {
target="${subpkgname#gcc-}"
pkgdesc="The GNU Compiler Collection for $target targets"
depends="$depends binutils-$target"
workingdir="$srcdir/build-$target"
cd "$workingdir"
_target="${subpkgname#gcc-}"
pkgdesc="The GNU Compiler Collection for $_target targets"
depends="$depends binutils-$_target"
_workingdir="$srcdir/build-$_target"
cd "$_workingdir"
make install DESTDIR="$subpkgdir" -j1
# install nano-variant into temporary folder to obtain libstdc++ from there
workingdir="$srcdir/build-$target-nano"
cd "$workingdir"
make install DESTDIR="$subpkgdir-nano" -j1
# Fetch libstdc++ from nano variant
multilibs=$($subpkgdir/usr/bin/$target-gcc -print-multi-lib 2>/dev/null)
for multilib in $multilibs; do
dir="${multilib%%;*}"
from_dir=$subpkgdir-nano/usr/$target/lib/$dir
to_dir=$subpkgdir/usr/$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
if [ "$1" == "newlib" ]; then
# install nano-variant into temporary folder to obtain libstdc++ from there
_workingdir="$srcdir/build-$_target-nano"
cd "$_workingdir"
make install DESTDIR="$subpkgdir-nano" -j1
# Fetch libstdc++ from nano variant
multilibs=$($subpkgdir/usr/bin/$_target-gcc -print-multi-lib 2>/dev/null)
for multilib in $multilibs; do
dir="${multilib%%;*}"
from_dir=$subpkgdir-nano/usr/$_target/lib/$dir
to_dir=$subpkgdir/usr/$_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
fi
# Delete documentation. (The user can use the host GCC doc instead)
rm -rf "$subpkgdir"/deleteme
......@@ -155,30 +184,34 @@ _install_subpkg() {
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 '{}' \;
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
_install_subpkg "newlib"
}
avr() {
_install_subpkg "other"
}
mips_mti_elf() {
_install_subpkg
_install_subpkg "newlib"
}
msp430_elf() {
_install_subpkg
_install_subpkg "newlib"
}
or1k_elf() {
_install_subpkg
_install_subpkg "newlib"
}
riscv_none_elf() {
_install_subpkg
_install_subpkg "newlib"
}
aarch64_none_elf() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment