Subject: [alpine-aports] [PATCH 1/3] testing/binutils-cross-bare-metal: New aport

From: Marian Buschsieweke <[email-masked]>
Date: Sat, 5 May 2018 12:53:09 +0200

Tools necessary to build programs for embedded targets
http://www.gnu.org/software/binutils

Subpackages are: binutils-arm-none-eabi, binutils-avr, binutils-xtensa-lx106-elf
---
 testing/binutils-cross-bare-metal/APKBUILD    | 89 +++++++++++++++++++
 .../binutils-ld-fix-static-linking.patch      | 46 ++++++++++
 2 files changed, 135 insertions(+)
 create mode 100644 testing/binutils-cross-bare-metal/APKBUILD
 create mode 100644 testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch

diff --git a/testing/binutils-cross-bare-metal/APKBUILD b/testing/binutils-cross-bare-metal/APKBUILD
new file mode 100644
index 0000000000..c9c63ac5a9
--- /dev/null
+++ b/testing/binutils-cross-bare-metal/APKBUILD
@@ -0,0 +1,89 @@
+# Maintainer: Marian Buschsieweke <[email-masked]>
+# Based on binutils-avr
+_pkgbase=binutils
+_targets="arm-none-eabi avr xtensa-lx106-elf"
+pkgname="$_pkgbase-cross-bare-metal"
+pkgver=2.30
+pkgrel=0
+pkgdesc="Tools necessary to build programs for embedded targets"
+url="http://www.gnu.org/software/${_pkgbase}/"
+makedepends="gettext libtool autoconf automake bison zlib-dev"
+arch="all"
+license="GPL2 GPL3+ LGPL2 BSD"
+for target in $_targets; do
+	targetnorm="${target//-/_}"
+	subpackages="${_pkgbase}-${target}:${targetnorm} ${subpackages}"
+done
+source="http://ftp.gnu.org/gnu/${_pkgbase}/${_pkgbase}-${pkgver}.tar.bz2
+	binutils-ld-fix-static-linking.patch"
+
+builddir="$srcdir/${_pkgbase}-$pkgver"
+_workingdir="$srcdir/${_pkgbase}-build"
+
+build() {
+	for target in $_targets; do
+		workingdir="${srcdir}/build-${target}"
+		mkdir "$workingdir"
+		cd "$workingdir"
+		"$builddir"/configure \
+			--target=${target} \
+			--build="$CBUILD" \
+			--host="$CHOST" \
+			--prefix=/usr/lib \
+			--bindir=/usr/bin \
+			--libdir=/usr/lib/${target} \
+			--infodir=/deleteme/info \
+			--htmldir=/deleteme/html \
+			--pdfdir=/deleteme/pdf \
+			--mandir=/deleteme/man \
+			--disable-nls \
+			--enable-plugins \
+			--enable-interwork \
+			--with-system-zlib \
+			|| return 1
+		make tooldir=/usr
+	done
+}
+
+check() {
+	for target in $_targets; do
+		workingdir="${srcdir}/build-${target}"
+		cd "$workingdir"
+		make check
+	done
+}
+
+package() {
+	mkdir -p "${pkgdir}"
+}
+
+install_subpkg() {
+	workingdir="${srcdir}/build-${target}"
+	cd "$workingdir"
+	make install DESTDIR="$subpkgdir"
+	rm -rf "$subpkgdir"/deleteme
+	for bin in ar as nm objcopy objdump ranlib strip readelf; do
+		rm -f "$subpkgdir"/usr/bin/"$bin"
+	done
+}
+
+arm_none_eabi() {
+	target="${subpkgname#${_pkgbase}-}"
+	pkgdesc="Tools necessary to build programs for platform ${target}"
+	install_subpkg
+}
+
+avr() {
+	target="${subpkgname#${_pkgbase}-}"
+	pkgdesc="Tools necessary to build programs for platform ${target}"
+	install_subpkg
+}
+
+xtensa_lx106_elf() {
+	target="${subpkgname#${_pkgbase}-}"
+	pkgdesc="Tools necessary to build programs for platform ${target}"
+	install_subpkg
+}
+
+sha512sums="c3ce91aa20f058ec589bf18c722bf651331b394db6378900cc813cc0eea3a331a96584d5ae090630b627369510397dccc9edfcd43d4aeefc99579f277a05c72c  binutils-2.30.tar.bz2
+ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49  binutils-ld-fix-static-linking.patch"
diff --git a/testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch b/testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch
new file mode 100644
index 0000000000..bc5d762656
--- /dev/null
+++ b/testing/binutils-cross-bare-metal/binutils-ld-fix-static-linking.patch
@@ -0,0 +1,46 @@
+This fixes static linking for our hardened toolchain
+diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
+index e8126cb..9532bfb 100644
+--- a/ld/scripttempl/elf.sc
++++ b/ld/scripttempl/elf.sc
+@@ -235,8 +235,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
+ if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
+   SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
+   SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
+-  CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors"
+-  DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors"
++  CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors"
++  DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors"
+ else
+   SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
+   SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
+@@ -270,15 +270,14 @@ CTOR=".ctors        ${CONSTRUCTING-0} :
+        doesn't matter which directory crtbegin.o
+        is in.  */
+ 
+-    KEEP (*crtbegin.o(.ctors))
+-    KEEP (*crtbegin?.o(.ctors))
++    KEEP (*crtbegin*.o(.ctors))
+ 
+     /* We don't want to include the .ctor section from
+        the crtend.o file until after the sorted ctors.
+        The .ctor section from the crtend file contains the
+        end of ctors marker and it must be last */
+ 
+-    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
++    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
+     KEEP (*(SORT(.ctors.*)))
+     KEEP (*(.ctors))
+     ${CONSTRUCTING+${CTOR_END}}
+@@ -286,9 +285,8 @@ CTOR=".ctors        ${CONSTRUCTING-0} :
+ DTOR=".dtors        ${CONSTRUCTING-0} :
+   {
+     ${CONSTRUCTING+${DTOR_START}}
+-    KEEP (*crtbegin.o(.dtors))
+-    KEEP (*crtbegin?.o(.dtors))
+-    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
++    KEEP (*crtbegin*.o(.dtors))
++    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
+     KEEP (*(SORT(.dtors.*)))
+     KEEP (*(.dtors))
+     ${CONSTRUCTING+${DTOR_END}}
-- 
2.17.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Marian Buschsieweke <[email-masked]>
Date: Sat, 5 May 2018 12:53:10 +0200

The GNU Compiler Collection for embedded ARM targets
http://gcc.gnu.org

This package is heavily based on the current Ubuntu LTS gcc-arm-none-eabi. It
seems that creating a reliable cross toolchain for embedded ARM that does
not create binaries with random run time errors is some kind of dark magic the
Ubuntu guys got right.
---
 .../0001-gcc-gfdl-build.patch                 | 38 ++++++++
 .../0002-add-big-endian-support.patch         | 28 ++++++
 .../gcc-arm-none-eabi/0003-remove-armv8.patch | 74 ++++++++++++++++
 testing/gcc-arm-none-eabi/APKBUILD            | 86 +++++++++++++++++++
 4 files changed, 226 insertions(+)
 create mode 100644 testing/gcc-arm-none-eabi/0001-gcc-gfdl-build.patch
 create mode 100644 testing/gcc-arm-none-eabi/0002-add-big-endian-support.patch
 create mode 100644 testing/gcc-arm-none-eabi/0003-remove-armv8.patch
 create mode 100644 testing/gcc-arm-none-eabi/APKBUILD

diff --git a/testing/gcc-arm-none-eabi/0001-gcc-gfdl-build.patch b/testing/gcc-arm-none-eabi/0001-gcc-gfdl-build.patch
new file mode 100644
index 0000000000..811f9a96c3
--- /dev/null
+++ b/testing/gcc-arm-none-eabi/0001-gcc-gfdl-build.patch
@@ -0,0 +1,38 @@
+# DP: Build a dummy s-tm-texi without access to the texinfo sources
+# This patch was taken from gcc debian package
+
+--- src/gcc/Makefile.in
++++ src/gcc/Makefile.in
+@@ -2314,30 +2314,8 @@
+ # \r is not portable to Solaris tr, therefore we have a special
+ # case for ASCII.  We use \r for other encodings like EBCDIC.
+ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
+-	$(RUN_GEN) build/genhooks$(build_exeext) -d \
+-			$(srcdir)/doc/tm.texi.in > tmp-tm.texi
+-	case `echo X|tr X '\101'` in \
+-	  A) tr -d '\015' < tmp-tm.texi > tmp2-tm.texi ;; \
+-	  *) tr -d '\r' < tmp-tm.texi > tmp2-tm.texi ;; \
+-	esac
+-	mv tmp2-tm.texi tmp-tm.texi
+-	$(SHELL) $(srcdir)/../move-if-change tmp-tm.texi tm.texi
+-	@if cmp -s $(srcdir)/doc/tm.texi tm.texi; then \
+-	  $(STAMP) $@; \
+-	elif test $(srcdir)/doc/tm.texi -nt $(srcdir)/doc/tm.texi.in \
+-	  && ( test $(srcdir)/doc/tm.texi -nt $(srcdir)/target.def \
+-	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/c-family/c-target.def \
+-	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/common/common-target.def \
+-	  ); then \
+-	  echo >&2 ; \
+-	  echo You should edit $(srcdir)/doc/tm.texi.in rather than $(srcdir)/doc/tm.texi . >&2 ; \
+-	  false; \
+-	else \
+-	  echo >&2 ; \
+-	  echo Verify that you have permission to grant a GFDL license for all >&2 ; \
+-	  echo new text in tm.texi, then copy it to $(srcdir)/doc/tm.texi. >&2 ; \
+-	  false; \
+-	fi
++	cat $(srcdir)/doc/tm.texi.in > tmp-tm.texi
++	$(STAMP) $@
+ 
+ gimple-match.c: s-match gimple-match-head.c ; @true
+ generic-match.c: s-match generic-match-head.c ; @true
diff --git a/testing/gcc-arm-none-eabi/0002-add-big-endian-support.patch b/testing/gcc-arm-none-eabi/0002-add-big-endian-support.patch
new file mode 100644
index 0000000000..01357ee890
--- /dev/null
+++ b/testing/gcc-arm-none-eabi/0002-add-big-endian-support.patch
@@ -0,0 +1,28 @@
+--- src/gcc/config/arm/t-rmprofile
++++ src/gcc/config/arm/t-rmprofile
+@@ -52,6 +52,8 @@
+ MULTILIB_OPTIONS       += mfloat-abi=softfp/mfloat-abi=hard
+ MULTILIB_DIRNAMES      += softfp hard
+ 
++MULTILIB_OPTIONS       += mlittle-endian/mbig-endian
++MULTILIB_DIRNAMES      += le be
+ 
+ # Option combinations to build library with
+ 
+@@ -87,6 +89,8 @@
+ MULTILIB_REQUIRED      += mthumb/march=armv7/mfpu=vfpv3-d16/mfloat-abi=softfp
+ MULTILIB_REQUIRED      += mthumb/march=armv7/mfpu=vfpv3-d16/mfloat-abi=hard
+ 
++# ARMv7-R big endian
++MULTILIB_REQUIRED      += mthumb/march=armv7/mfpu=vfpv3-d16/mfloat-abi=hard/mbig-endian
+ 
+ # Matches
+ 
+@@ -168,6 +172,7 @@
+ MULTILIB_REUSE         += mthumb/march.armv7=march.armv7
+ MULTILIB_REUSE         += mthumb/march.armv7/mfpu.vfpv3-d16/mfloat-abi.softfp=march.armv7/mfpu.vfpv3-d16/mfloat-abi.softfp
+ MULTILIB_REUSE         += mthumb/march.armv7/mfpu.vfpv3-d16/mfloat-abi.hard=march.armv7/mfpu.vfpv3-d16/mfloat-abi.hard
++MULTILIB_REUSE         += mthumb/march.armv7/mfpu.vfpv3-d16/mfloat-abi.hard/mbig-endian=march.armv7/mfpu.vfpv3-d16/mfloat-abi.hard/mbig-endian
+ MULTILIB_REUSE         += mthumb/march.armv7/mfpu.vfpv3-d16/mfloat-abi.softfp=march.armv7/mfpu.fpv5-d16/mfloat-abi.softfp
+ MULTILIB_REUSE         += mthumb/march.armv7/mfpu.vfpv3-d16/mfloat-abi.hard=march.armv7/mfpu.fpv5-d16/mfloat-abi.hard
+ MULTILIB_REUSE         += mthumb/march.armv7/mfpu.vfpv3-d16/mfloat-abi.softfp=mthumb/march.armv7/mfpu.fpv5-d16/mfloat-abi.softfp
diff --git a/testing/gcc-arm-none-eabi/0003-remove-armv8.patch b/testing/gcc-arm-none-eabi/0003-remove-armv8.patch
new file mode 100644
index 0000000000..247204cb9e
--- /dev/null
+++ b/testing/gcc-arm-none-eabi/0003-remove-armv8.patch
@@ -0,0 +1,74 @@
+--- src/gcc/config/arm/t-rmprofile
++++ src/gcc/config/arm/t-rmprofile
+@@ -43,8 +43,8 @@
+ MULTILIB_OPTIONS       += mthumb
+ MULTILIB_DIRNAMES      += thumb
+ 
+-MULTILIB_OPTIONS       += march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7/march=armv8-m.base/march=armv8-m.main
+-MULTILIB_DIRNAMES      += v6-m v7-m v7e-m v7-ar v8-m.base v8-m.main
++MULTILIB_OPTIONS       += march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7
++MULTILIB_DIRNAMES      += v6-m v7-m v7e-m v7-ar
+ 
+ MULTILIB_OPTIONS       += mfpu=vfpv3-d16/mfpu=fpv4-sp-d16/mfpu=fpv5-sp-d16/mfpu=fpv5-d16
+ MULTILIB_DIRNAMES      += fpv3 fpv4-sp fpv5-sp fpv5
+@@ -64,9 +64,6 @@
+ # ARMv6-M
+ MULTILIB_REQUIRED      += mthumb/march=armv6s-m
+ 
+-# ARMv8-M Baseline
+-MULTILIB_REQUIRED      += mthumb/march=armv8-m.base
+-
+ # ARMv7-M
+ MULTILIB_REQUIRED      += mthumb/march=armv7-m
+ 
+@@ -77,13 +74,6 @@
+ MULTILIB_REQUIRED      += mthumb/march=armv7e-m/mfpu=fpv5-d16/mfloat-abi=softfp
+ MULTILIB_REQUIRED      += mthumb/march=armv7e-m/mfpu=fpv5-d16/mfloat-abi=hard
+ 
+-# ARMv8-M Mainline
+-MULTILIB_REQUIRED      += mthumb/march=armv8-m.main
+-MULTILIB_REQUIRED      += mthumb/march=armv8-m.main/mfpu=fpv5-d16/mfloat-abi=softfp
+-MULTILIB_REQUIRED      += mthumb/march=armv8-m.main/mfpu=fpv5-d16/mfloat-abi=hard
+-MULTILIB_REQUIRED      += mthumb/march=armv8-m.main/mfpu=fpv5-sp-d16/mfloat-abi=softfp
+-MULTILIB_REQUIRED      += mthumb/march=armv8-m.main/mfpu=fpv5-sp-d16/mfloat-abi=hard
+-
+ # ARMv7-R as well as ARMv7-A and ARMv8-A if aprofile was not specified
+ MULTILIB_REQUIRED      += mthumb/march=armv7
+ MULTILIB_REQUIRED      += mthumb/march=armv7/mfpu=vfpv3-d16/mfloat-abi=softfp
+@@ -106,8 +96,6 @@
+ MULTILIB_MATCHES       += march?armv7-m=mcpu?cortex-m3
+ MULTILIB_MATCHES       += march?armv7e-m=mcpu?cortex-m4
+ MULTILIB_MATCHES       += march?armv7e-m=mcpu?cortex-m7
+-MULTILIB_MATCHES       += march?armv8-m.base=mcpu?cortex-m23
+-MULTILIB_MATCHES       += march?armv8-m.main=mcpu?cortex-m33
+ MULTILIB_MATCHES       += march?armv7=mcpu?cortex-r4
+ MULTILIB_MATCHES       += march?armv7=mcpu?cortex-r4f
+ MULTILIB_MATCHES       += march?armv7=mcpu?cortex-r5
+@@ -140,17 +128,10 @@
+ 
+ # Arch Matches
+ MULTILIB_MATCHES       += march?armv6s-m=march?armv6-m
+-MULTILIB_MATCHES       += march?armv8-m.main=march?armv8-m.main+dsp
+ MULTILIB_MATCHES       += march?armv7=march?armv7-r
+ ifeq (,$(HAS_APROFILE))
+ MULTILIB_MATCHES       += march?armv7=march?armv7-a
+ MULTILIB_MATCHES       += march?armv7=march?armv7ve
+-MULTILIB_MATCHES       += march?armv7=march?armv8-a
+-MULTILIB_MATCHES       += march?armv7=march?armv8-a+crc
+-MULTILIB_MATCHES       += march?armv7=march?armv8.1-a
+-MULTILIB_MATCHES       += march?armv7=march?armv8.1-a+crc
+-MULTILIB_MATCHES       += march?armv7=march?armv8.2-a
+-MULTILIB_MATCHES       += march?armv7=march?armv8.2-a+fp16
+ endif
+ 
+ # FPU matches
+@@ -163,9 +144,6 @@
+ MULTILIB_MATCHES       += mfpu?vfpv3-d16=mfpu?vfpv4
+ MULTILIB_MATCHES       += mfpu?vfpv3-d16=mfpu?vfpv4-d16
+ MULTILIB_MATCHES       += mfpu?vfpv3-d16=mfpu?neon-vfpv4
+-MULTILIB_MATCHES       += mfpu?fpv5-d16=mfpu?fp-armv8
+-MULTILIB_MATCHES       += mfpu?fpv5-d16=mfpu?neon-fp-armv8
+-MULTILIB_MATCHES       += mfpu?fpv5-d16=mfpu?crypto-neon-fp-armv8
+ endif
+ 
+ 
diff --git a/testing/gcc-arm-none-eabi/APKBUILD b/testing/gcc-arm-none-eabi/APKBUILD
new file mode 100644
index 0000000000..81a629fd4c
--- /dev/null
+++ b/testing/gcc-arm-none-eabi/APKBUILD
@@ -0,0 +1,86 @@
+# Maintainer: Marian Buschsieweke <[email-masked]>
+pkgname=gcc-arm-none-eabi
+pkgver=6.3.1
+pkgrel=0
+pkgdesc="The GNU Compiler Collection for embedded ARM targets"
+url="http://gcc.gnu.org"
+depends="binutils-arm-none-eabi"
+makedepends="bash flex linux-headers gmp-dev mpfr-dev mpc1-dev zlib-dev isl-dev"
+arch="all"
+license="GPL LGPL"
+subpackages=""
+_ubuntusvnrev=253039
+source="https://launchpad.net/ubuntu/+archive/primary/+files/${pkgname}_${pkgver}+svn${_ubuntusvnrev}.orig.tar.xz
+	0001-gcc-gfdl-build.patch
+	0002-add-big-endian-support.patch
+	0003-remove-armv8.patch
+	"
+
+builddir="$srcdir/src"
+_workingdir="$builddir/build"
+_target="${pkgname#gcc-}"
+
+build() {
+	mkdir "$_workingdir" || return 1
+	cd "$_workingdir"
+
+	export CFLAGS_FOR_TARGET='-pipe'
+	export CXXFLAGS_FOR_TARGET='-pipe'
+
+	"$builddir"/configure\
+		--infodir=/deleteme/info \
+		--htmldir=/deleteme/html \
+		--pdfdir=/deleteme/pdf \
+		--mandir=/deleteme/man \
+		--enable-languages=c,c++,lto \
+		--enable-multilib \
+		--disable-decimal-float \
+		--disable-libffi \
+		--disable-libgomp \
+		--disable-libmudflap \
+		--disable-libquadmath \
+		--disable-libssp \
+		--disable-libstdcxx-pch \
+		--disable-nls \
+		--disable-shared \
+		--disable-threads \
+		--disable-tls \
+		--build="$CBUILD" \
+		--target="$_target" \
+		--with-system-zlib \
+		--with-gnu-as \
+		--with-gnu-ld \
+		--without-included-gettext \
+		--prefix=/usr/lib \
+		--bindir=/usr/bin \
+		--libexecdir=/usr/lib \
+		--libdir=/usr/lib \
+		--disable-libstdc++-v3 \
+		--host=$CHOST \
+		--with-headers=no \
+		--without-newlib \
+		--with-multilib-list=rmprofile \
+		AR_FOR_TARGET="$_target"-ar \
+		AS_FOR_TARGET="$_target"-as \
+		LD_FOR_TARGET="$_target"-ld \
+		NM_FOR_TARGET="$_target"-nm \
+		OBJDUMP_FOR_TARGET="$_target"-objdump \
+		RANLIB_FOR_TARGET="$_target"-ranlib \
+		READELF_FOR_TARGET="$_target"-readelf \
+		STRIP_FOR_TARGET="$_target"-strip \
+		|| return 1
+	make
+}
+
+package() {
+	cd "$_workingdir"
+	make install DESTDIR="$pkgdir" || return 1
+	rm -rf "$pkgdir"/deleteme
+	rm -f "$pkgdir"/usr/lib/libcc1.*
+	find "$pkgdir"/usr/lib -type f -name "*.a" -exec "/usr/bin/$_target-strip" --strip-debug '{}' \;
+}
+
+sha512sums="75665bc9e442f005cfefb40263e28a65cf49523e3119336cacf6ab61bdc04ba387a35e11343b943c4eb1ba143e02cbb85fcea6e71420c491bf9e9ed77b9c0d4c  gcc-arm-none-eabi_6.3.1+svn253039.orig.tar.xz
+c3ce7e50187769add364981576541b2bea86bdd9d1e5c9b084cd76d89243c5d01b0038b35c3679169d7dc5ee0620201511ff875104915e03b2952dc0827d279d  0001-gcc-gfdl-build.patch
+3362981b68597c82d5298d04aa1ff82352d29209db74d8109faa013a5f43744c4b625d4d2a179359cbf6007ac367a18612374499982f0a8161d2720453c86180  0002-add-big-endian-support.patch
+f96f93636a933eea337853a7db933eec7c9bd446c565054594406102727b4cfeb14e878224af53445345a812aca5ffcd946a0e56f4a3885b7ce7c06b2e5d64f0  0003-remove-armv8.patch"
-- 
2.17.0

---

---

From: Marian Buschsieweke <[email-masked]>
Date: Sat, 5 May 2018 12:53:11 +0200

A C standard library implementation intended for use on embedded ARM
http://www.sourceware.org/newlib/

Heavily based on Ubuntu's libnewlib-arm-none-abi for the current LTS
---
 testing/newlib-arm-none-eabi/APKBUILD         | 117 ++++++++++++++++++
 .../fix-include-paths-nano-specs.patch        |  13 ++
 2 files changed, 130 insertions(+)
 create mode 100644 testing/newlib-arm-none-eabi/APKBUILD
 create mode 100644 testing/newlib-arm-none-eabi/fix-include-paths-nano-specs.patch

diff --git a/testing/newlib-arm-none-eabi/APKBUILD b/testing/newlib-arm-none-eabi/APKBUILD
new file mode 100644
index 0000000000..d437ffe613
--- /dev/null
+++ b/testing/newlib-arm-none-eabi/APKBUILD
@@ -0,0 +1,117 @@
+# Maintainer: Marian Buschsieweke <[email-masked]>
+
+_realname=newlib
+_target="arm-none-eabi"
+pkgname="$_realname-$_target"
+pkgver=2.4.0.20160527
+pkgrel=0
+pkgdesc="A C standard library implementation intended for use on embedded ARM"
+url="http://www.sourceware.org/newlib/"
+makedepends="texinfo"
+depends="gcc-$_target binutils-$_target"
+arch="all"
+license="BSD"
+source="
+	http://archive.ubuntu.com/ubuntu/pool/universe/${_realname:0:1}/${_realname}/${_realname}_${pkgver}.orig.tar.xz
+	fix-include-paths-nano-specs.patch
+	"
+#source="ftp://sourceware.org/pub/${_realname}/${_realname}-${pkgver}.tar.gz"
+options="!check"
+
+builddir="$srcdir/$_realname-$pkgver"
+
+# This package installes two version of the newlib library to remain compatible
+# with projects expecting the GNU ARM Embedded Toolchain [1]. The nano version
+# appends the postix "_nano" to the libaries. The is not an arbitrary choice,
+# it matches the specs in "/usr/arm-none-eabi/lib/nano.specs", which is
+# part of the default newlib installation.
+# [1]: https://launchpad.net/gcc-arm-embedded/
+
+build() {
+	mkdir "${builddir}/build" "${builddir}/build-nano"
+	# nano version
+	cd "${builddir}/build-nano"
+	"$builddir"/configure \
+			--host=$CHOST \
+			--build=$CBUILD \
+			--target=$_target \
+			--prefix=/usr/lib \
+			--libdir=/usr/lib \
+			--infodir=/deleteme/info \
+			--mandir=/deleteme/man \
+			--htmldir=/deleteme/html \
+			--pdfdir=/deleteme/pdf \
+			--disable-newlib-supplied-syscalls \
+			--disable-nls \
+			--enable-newlib-reent-small \
+			--disable-newlib-fvwrite-in-streamio \
+			--disable-newlib-fseek-optimization \
+			--disable-newlib-wide-orient \
+			--enable-newlib-nano-malloc \
+			--disable-newlib-unbuf-stream-opt \
+			--enable-lite-exit \
+			--enable-newlib-global-atexit \
+			--enable-newlib-nano-formatted-io \
+			CC_FOR_TARGET="$_target"-gcc \
+			GCC_FOR_TARGET="$_target"-gcc \
+			AR_FOR_TARGET="$_target"-ar \
+			AS_FOR_TARGET="$_target"-as \
+			LD_FOR_TARGET="$_target"-ld \
+			NM_FOR_TARGET="$_target"-nm \
+			OBJDUMP_FOR_TARGET="$_target"-objdump \
+			RANLIB_FOR_TARGET="$_target"-ranlib \
+			READELF_FOR_TARGET="$_target"-readelf \
+			STRIP_FOR_TARGET="$_target"-strip \
+			CFLAGS="-Os -ffunction-sections -fdata-sections -fshort-wchar"
+	make
+
+	# regular version
+	cd "${builddir}/build"
+	"$builddir"/configure \
+			--host=$CHOST \
+			--target=$_target \
+			--prefix=/usr/lib \
+			--libdir=/usr/lib \
+			--infodir=/deleteme/info \
+			--mandir=/deleteme/man \
+			--htmldir=/deleteme/html \
+			--pdfdir=/deleteme/pdf \
+			--disable-newlib-supplied-syscalls \
+			--disable-nls \
+			--enable-newlib-io-long-long \
+			--enable-newlib-register-fini \
+			CC_FOR_TARGET="$_target"-gcc \
+			GCC_FOR_TARGET="$_target"-gcc \
+			AR_FOR_TARGET="$_target"-ar \
+			AS_FOR_TARGET="$_target"-as \
+			LD_FOR_TARGET="$_target"-ld \
+			NM_FOR_TARGET="$_target"-nm \
+			OBJDUMP_FOR_TARGET="$_target"-objdump \
+			RANLIB_FOR_TARGET="$_target"-ranlib \
+			READELF_FOR_TARGET="$_target"-readelf \
+			STRIP_FOR_TARGET="$_target"-strip \
+			CFLAGS="-O2 -ffunction-sections -fdata-sections -pipe"
+	make
+}
+
+package() {
+	# install nano version
+	cd "${builddir}/build-nano"
+	make -j1 DESTDIR="$pkgdir" install
+	# rename nano version libs
+	cd "${pkgdir}/usr/lib/$_target/lib"
+	for file in $(find . -regex ".*\(c\|g\|rdimon\)\.a"); do
+		mv "$file" "${file%.a}_nano.a"
+	done
+	mkdir -p "${pkgdir}/usr/lib/$_target/include/nano"
+	mv "${pkgdir}/usr/lib/$_target/include/newlib.h" \
+	   "${pkgdir}/usr/lib/$_target/include/nano/"
+
+	# install regular version
+	cd "${builddir}/build"
+	make -j1 DESTDIR="$pkgdir" install
+	rm -rf "${pkgdir}/deleteme"
+}
+
+sha512sums="91d07a67a4f0b4ce7774352c50c8906c0051ebe588ed30c2abfdf4105b3bbeb98433c8b61126e5e6c1891b0f5a5462f762383b6fc419ba993a02b2484f46a9cc  newlib_2.4.0.20160527.orig.tar.xz
+6a7daa621088f7a9c75787c73de34ea6e503ba8051e208b2b6dd03498384bda46a81c0572be7846a7a270e4c390aa8d418b55a73587dd9d212fc2f5d123782f3  fix-include-paths-nano-specs.patch"
diff --git a/testing/newlib-arm-none-eabi/fix-include-paths-nano-specs.patch b/testing/newlib-arm-none-eabi/fix-include-paths-nano-specs.patch
new file mode 100644
index 0000000000..f4ea97708f
--- /dev/null
+++ b/testing/newlib-arm-none-eabi/fix-include-paths-nano-specs.patch
@@ -0,0 +1,13 @@
+Index: newlib-2.4.0.20160527/libgloss/arm/elf-nano.specs
+===================================================================
+--- newlib-2.4.0.20160527.orig/libgloss/arm/elf-nano.specs
++++ newlib-2.4.0.20160527/libgloss/arm/elf-nano.specs
+@@ -3,7 +3,7 @@
+ %rename cpp		nano_cpp
+ 
+ *cpp:
+--isystem =/include/newlib-nano %(nano_cpp)
++-isystem /usr/include/newlib/nano %(nano_cpp)
+ 
+ *nano_libc:
+ -lc_nano
-- 
2.17.0

---