community/newlib: add missing nano.specs and syscalls for msp430-elf

For MSP430 no nano.specs is installed for the MSP430 toolchain. Likely
most MSP430 users only install the nano variant and don't build a full
fledged version of newlib. To ease packaging, for consistency, and also
in case some MSP430 users do want a full fledged newlib version,
stick with providing both versions but also provide a simple nano.specs
file to make using the nano variant possible.

Additionally, syscalls where disabled for msp430. The resulted in the
functions provided by the standard C lib such as puts() or printf()
to be defunct, as the hooks integrating with an RTOS such as RIOT
where never called. This patches newlib to also use syscalls with
MSP430.
This commit is contained in:
Marian Buschsieweke 2023-05-08 15:32:57 +02:00 committed by alice
parent a76cc42f1a
commit a431beac21
3 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,18 @@
By default newlib will disable syscalls for MPS430, which means defunct puts(),
printf(), etc. Since providing those is the main purpose of a standard c lib,
this makes little sense.
This enable syscalls again. With it, MCU operating systems such as RIOT can
provide functioning puts, printf(), read(), write(), etc.
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -781,6 +781,9 @@
default_newlib_io_long_long="yes"
newlib_cflags="${newlib_cflags} -Os -DPREFER_SIZE_OVER_SPEED -DSMALL_MEMORY"
;;
+ msp430*)
+ syscall_dir=syscalls
+ ;;
nios2*)
syscall_dir=
newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"

View File

@ -1,7 +1,7 @@
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=newlib
pkgver=4.3.0.20230120
pkgrel=0
pkgrel=1
pkgdesc="C standard library implementation intended for use on embedded systems"
url="https://www.sourceware.org/newlib/"
makedepends="texinfo"
@ -9,6 +9,9 @@ arch="aarch64 ppc64le x86_64 x86"
license="GPL-2.0-only AND LGPL-2.1-only AND 0BSD AND BSD-3-Clause AND GPL-3.0-only AND LGPL-3.0-only"
source="
https://sourceware.org/pub/newlib/newlib-$pkgver.tar.gz
msp430-elf-nano.specs
0001-msp430-enable-syscalls.patch
"
options="!check"
@ -151,6 +154,12 @@ _install_subpkg() {
cd "$builddir/build-$target"
make -j1 DESTDIR="$subpkgdir" install
rm -rf "$subpkgdir/deleteme"
# install custom nano specs, if existing
if [ -e "$srcdir/$target-nano.specs" ]; then
install -m 644 "$srcdir/$target-nano.specs" \
"$subpkgdir/usr/$target/lib/nano.specs"
fi
}
arm_none_eabi() {
@ -179,4 +188,6 @@ aarch64_none_elf() {
sha512sums="
4a06309d36c2255fef8fc8f2d133cafa850f1ed2eddfb27b5d45f5d16af69e0fca829a0b4c9b34af4ed3a28c6fcc929761e0ee823a4229f35c2853d432b5e7ef newlib-4.3.0.20230120.tar.gz
647b79e3cc6f3bb98b1263ebbf4b3efa4a4692fddc0df6491c726de2fa0ee46b05ab2ddf96c2c8c785f3cd6a442135ec97bf8df93a8f371d479ea46d03aa8a08 msp430-elf-nano.specs
268c44f8056067e03ee9914d04e8cfa2bb22764bb294b7d16dbfdd51c2e5ef0ad221037a86caafd20ab755b16b38519d61e27ffcd13239cbdbbfad421fa8cb60 0001-msp430-enable-syscalls.patch
"

View File

@ -0,0 +1,3 @@
%rename link nano_link
*link:
%(nano_link) %:replace-outfile(-lc -lc_nano) %:replace-outfile(-lg -lg_nano) %:replace-outfile(-lstdc++ -lstdc++_nano) %:replace-outfile(-lsupc++ -lsupc++_nano)