Mail archive
alpine-aports

[alpine-aports] [PATCH 4/6] testing/gcc-cross-embedded: New aport

From: Marian Buschsieweke <marian.buschsieweke_at_ovgu.de>
Date: Sun, 10 Mar 2019 10:01:23 +0100

Cross compilers for bare metal targets. This package contains the
subpackages gcc-arm-none-eabi, gcc-mips-mti-elf, and gcc-msp430-elf.
The bare metal ARM toolchain is tested and fully functional, the others
are a proof of concept and not tested (due to lack of hardware).
---
 testing/gcc-cross-embedded/APKBUILD | 166 ++++++++++++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 testing/gcc-cross-embedded/APKBUILD
diff --git a/testing/gcc-cross-embedded/APKBUILD b/testing/gcc-cross-embedded/APKBUILD
new file mode 100644
index 0000000000..1237e2b3d0
--- /dev/null
+++ b/testing/gcc-cross-embedded/APKBUILD
_at_@ -0,0 +1,166 @@
+# Maintainer: Marian Buschsieweke <marian.buschsieweke_at_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_at_outlook.com>
+# Contributor: Stefan Wagner <stw_at_bit-strickerei.de>
+# Contributor: Anatol Pomozov <anatol.pomozov_at_gmail.com>
+# Contributor: Martin Schmölzer <mschmoelzer_at_gmail.com>
+_pkgbase=gcc
+_targets="
+	arm-none-eabi
+	mips-mti-elf
+	msp430-elf
+	"
+pkgname="$_pkgbase-cross-embedded"
+pkgver=8.3.0
+pkgrel=0
+pkgdesc="The GNU Compiler Collection for embedded targets"
+url="http://gcc.gnu.org"
+depends="gcc"
+makedepends="bash linux-headers gmp-dev mpfr-dev mpc1-dev zlib-dev"
+arch="all"
+license="GPL-2.0 GPL-3.0-or-later LGPL-2.0"
+for target in $_targets; do
+	targetnorm="${target//-/_}"
+	subpackages="${_pkgbase}-${target}:${targetnorm} ${subpackages}"
+	makedepends="$makedepends binutils-$target newlib-$target-stage1"
+done
+
+_islver=0.20
+source="https://mirrors.kernel.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz
+	http://isl.gforge.inria.fr/isl-${_islver}.tar.bz2"
+
+options="!check"
+
+builddir="$srcdir/$_pkgbase-$pkgver"
+
+prepare() {
+	cd "$builddir"
+	# link isl for in-tree build
+	ln -s "$srcdir"/isl-"$_islver" isl
+
+	# 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() {
+	"$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,c++ \
+		--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-tls \
+		--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-multilib-list=rmprofile \
+		--with-newlib \
+		--with-system-zlib \
+		--with-pkgversion='Alpine Linux'
+	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'
+		_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'
+		_build_gcc
+	done
+}
+
+package() {
+	for target in $_targets; do
+		depends="$depends $_pkgbase-$target"
+	done
+	mkdir -p "${pkgdir}"
+}
+
+_install_subpkg() {
+	target="${subpkgname#${_pkgbase}-}"
+	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
+
+	# 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
+}
+
+sha512sums="1811337ae3add9680cec64968a2509d085b6dc5b6783fc1e8c295e3e47416196fd1a3ad8dfe7e10be2276b4f62c357659ce2902f239f60a8648548231b4b5802  gcc-8.3.0.tar.xz
+afe2e159b74646a26449268637403d271f9e3f6410d8cc1c9cffca41370c4357b165dea844db0c2a654591f954e54710dda650c8088abd4711406aa6302da950  isl-0.20.tar.bz2"
-- 
2.21.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Sun Mar 10 2019 - 10:01:23 UTC