summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-libs/newlib')
-rw-r--r--sys-libs/newlib/Manifest3
-rw-r--r--sys-libs/newlib/files/newlib-4.3.0.20230120-libc-arm-setjmp-gcc-backwards-compat.patch57
-rw-r--r--sys-libs/newlib/metadata.xml3
-rw-r--r--sys-libs/newlib/newlib-4.1.0-r2.ebuild (renamed from sys-libs/newlib/newlib-4.1.0-r1.ebuild)6
-rw-r--r--sys-libs/newlib/newlib-4.2.0.20211231-r1.ebuild154
-rw-r--r--sys-libs/newlib/newlib-4.3.0.20230120-r1.ebuild153
-rw-r--r--sys-libs/newlib/newlib-4.3.0.20230120-r2.ebuild155
-rw-r--r--sys-libs/newlib/newlib-4.4.0.20231231.ebuild154
-rw-r--r--sys-libs/newlib/newlib-9999.ebuild34
9 files changed, 699 insertions, 20 deletions
diff --git a/sys-libs/newlib/Manifest b/sys-libs/newlib/Manifest
index 2b71d80eb9bc..5797ec3a58bd 100644
--- a/sys-libs/newlib/Manifest
+++ b/sys-libs/newlib/Manifest
@@ -1 +1,4 @@
DIST newlib-4.1.0.tar.gz 18648429 BLAKE2B c4d4d734bceeacf05b75d450d4316392d0000266812f98f99cd3f9f0926ac9848e1dc145361827d1d6951edfe5f109923c982d9f284f927ffc5fd5e5edaf8be6 SHA512 6a24b64bb8136e4cd9d21b8720a36f87a34397fd952520af66903e183455c5cf19bb0ee4607c12a05d139c6c59382263383cb62c461a839f969d23d3bc4b1d34
+DIST newlib-4.2.0.20211231.tar.gz 18921589 BLAKE2B fb85a368d082e2b9005d5d295d6854eb7d0e351cfade6516e6a06b18656d9139d7629f55a6d5f63337c6bce511a2373e797bed96847f19941b26cacfb1c8d3bc SHA512 0c3efd7b74a6b8457a717cbb6aa6c5ff268eeaba375535465c6bd6502c3d32b54a9bc3ba7f2c6990f78e29152eee2f62acb39b674d24f9ddf440374a1ec9d2e8
+DIST newlib-4.3.0.20230120.tar.gz 8832922 BLAKE2B b5493f25e44049f4e1222698894e7e67756928062e05f5d16bcd52b2221e5c04a80a9e0cbc3fc6e92d67fe6b3813e06b6d3a6d39e8742e02b8f13ff84d809de1 SHA512 4a06309d36c2255fef8fc8f2d133cafa850f1ed2eddfb27b5d45f5d16af69e0fca829a0b4c9b34af4ed3a28c6fcc929761e0ee823a4229f35c2853d432b5e7ef
+DIST newlib-4.4.0.20231231.tar.gz 9022406 BLAKE2B 1df810c7776aa1fe2806682509ab45df642f5e80d6069b7c6ca513b3d820440fc73abdf7505d1f3149d0a07f0c5558a48620d2824f1698c2f1df5f6473105eb4 SHA512 ea3baa0b7c9175aae024f0b7d272be092ef2c07483239a99329203e18a44bc23093d29e0ffcbe14bc591f610f0829eacd646cabb06d1c34aa23239cb1b814b46
diff --git a/sys-libs/newlib/files/newlib-4.3.0.20230120-libc-arm-setjmp-gcc-backwards-compat.patch b/sys-libs/newlib/files/newlib-4.3.0.20230120-libc-arm-setjmp-gcc-backwards-compat.patch
new file mode 100644
index 000000000000..3eab820db787
--- /dev/null
+++ b/sys-libs/newlib/files/newlib-4.3.0.20230120-libc-arm-setjmp-gcc-backwards-compat.patch
@@ -0,0 +1,57 @@
+https://bugs.gentoo.org/891589
+https://sourceware.org/pipermail/newlib/2022/020035.html
+https://sourceware.org/git/?p=newlib-cygwin.git;a=commit;h=c6e601de84ea9f2be2b026c609cc3c1fe82a3103
+
+From c6e601de84ea9f2be2b026c609cc3c1fe82a3103 Mon Sep 17 00:00:00 2001
+From: "Victor L. Do Nascimento" <victor.donascimento@arm.com>
+Date: Fri, 3 Feb 2023 11:15:26 +0000
+Subject: [PATCH] libc: arm: Implement setjmp GCC backwards compatibility.
+
+When compiling Newlib for arm targets with GCC 12.1 onward, the
+passing of architecture extension information to the assembler is
+automatic, making the use of .fpu and .arch_extension directives
+in assembly files redundant.
+
+With older versions of GCC, however, these directives must be
+hard-coded into the `arm/setjmp.S' file to allow the assembly of
+instructions concerning the storage and subsequent reloading of the
+floating point registers to/from the jump buffer, respectively.
+
+This patch conditionally adds the `.fpu vfpxd' and `.arch_extension
+mve' directives based on compile-time preprocessor macros concerning
+GCC version and target architectural features, such that both the
+assembly and linking of setjmp.S succeeds for older versions of
+Newlib.
+--- a/newlib/libc/machine/arm/setjmp.S
++++ b/newlib/libc/machine/arm/setjmp.S
+@@ -64,6 +64,28 @@
+
+ .syntax unified
+
++/* GCC 12.1 and later will tell the assembler exactly which floating
++ point (or MVE) unit is required and we don't want to override
++ that. Conversely, older versions of the compiler don't pass this
++ information so we need to enable the VFP version that is most
++ appropriate. The choice here should support all suitable VFP
++ versions that the older toolchains can handle. */
++#if __GNUC__ && __GNUC__ < 12
++/* Ensure that FPU instructions are correctly compiled and, likewise,
++ the appropriate build attributes are added to the resulting object
++ file. Check whether the MVE extension is present and whether
++ we have support for hardware floating point-operations. VFPxd
++ covers all the cases we need in this file for hardware
++ floating-point and should be compatible with all required FPUs
++ that we need to support. */
++# if __ARM_FP
++ .fpu vfpxd
++# endif
++# if __ARM_FEATURE_MVE
++ .arch_extension mve
++# endif
++#endif
++
+ #if __ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM
+ /* ARMv6-M-like has to be implemented in Thumb mode. */
+
+--
+2.39.3
diff --git a/sys-libs/newlib/metadata.xml b/sys-libs/newlib/metadata.xml
index 5e314acbb2e9..0efee71c01f4 100644
--- a/sys-libs/newlib/metadata.xml
+++ b/sys-libs/newlib/metadata.xml
@@ -11,4 +11,7 @@
<use>
<flag name="nano">Build additional newlib-nano library</flag>
</use>
+<upstream>
+ <remote-id type="cpe">cpe:/a:newlib_project:newlib</remote-id>
+</upstream>
</pkgmetadata>
diff --git a/sys-libs/newlib/newlib-4.1.0-r1.ebuild b/sys-libs/newlib/newlib-4.1.0-r2.ebuild
index a5ec41db3c45..52f5c0cbde67 100644
--- a/sys-libs/newlib/newlib-4.1.0-r1.ebuild
+++ b/sys-libs/newlib/newlib-4.1.0-r2.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI="7"
@@ -10,7 +10,7 @@ if [[ ${PV} == "9999" ]] ; then
inherit git-r3
else
SRC_URI="ftp://sourceware.org/pub/newlib/${P}.tar.gz"
- KEYWORDS="~arm ~hppa ~m68k ~mips ~ppc ~ppc64 ~sparc ~x86"
+ KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
fi
export CBUILD=${CBUILD:-${CHOST}}
@@ -111,7 +111,7 @@ src_configure() {
--enable-lite-exit \
--enable-newlib-global-atexit \
--enable-newlib-nano-formatted-io \
- ${myconf}
+ "${myconf[@]}"
fi
}
diff --git a/sys-libs/newlib/newlib-4.2.0.20211231-r1.ebuild b/sys-libs/newlib/newlib-4.2.0.20211231-r1.ebuild
new file mode 100644
index 000000000000..17fd43c36734
--- /dev/null
+++ b/sys-libs/newlib/newlib-4.2.0.20211231-r1.ebuild
@@ -0,0 +1,154 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="7"
+
+inherit flag-o-matic toolchain-funcs
+
+if [[ ${PV} == "9999" ]] ; then
+ EGIT_REPO_URI="https://sourceware.org/git/newlib-cygwin.git"
+ inherit git-r3
+else
+ SRC_URI="ftp://sourceware.org/pub/newlib/${P}.tar.gz"
+ KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
+fi
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+
+DESCRIPTION="Newlib is a C library intended for use on embedded systems"
+HOMEPAGE="https://sourceware.org/newlib/"
+
+LICENSE="NEWLIB LIBGLOSS GPL-2"
+SLOT="0"
+IUSE="nls threads unicode headers-only nano"
+RESTRICT="strip"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-3.3.0-no-nano-cxx.patch
+)
+
+NEWLIBBUILD="${WORKDIR}/build"
+NEWLIBNANOBUILD="${WORKDIR}/build.nano"
+NEWLIBNANOTMPINSTALL="${WORKDIR}/nano_tmp_install"
+
+# Adding -U_FORTIFY_SOURCE to counter the effect of Gentoo's
+# auto-addition of _FORTIFY_SOURCE at gcc site: bug #656018#c4
+# Currently newlib can't be built itself when _FORTIFY_SOURCE
+# is set.
+CFLAGS_FULL="-ffunction-sections -fdata-sections -U_FORTIFY_SOURCE"
+CFLAGS_NANO="-Os -ffunction-sections -fdata-sections -U_FORTIFY_SOURCE"
+
+pkg_setup() {
+ # Reject newlib-on-glibc type installs
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ case ${CHOST} in
+ *-newlib|*-elf) ;;
+ *) die "Use sys-devel/crossdev to build a newlib toolchain" ;;
+ esac
+ fi
+
+ case ${CTARGET} in
+ msp430*)
+ if ver_test $(gcc-version ${CTARGET}) -lt 10.1; then
+ # bug #717610
+ die "gcc for ${CTARGET} has to be 10.1 or above"
+ fi
+ ;;
+ esac
+}
+
+src_configure() {
+ # TODO: we should fix this
+ unset LDFLAGS
+ CHOST=${CTARGET} strip-unsupported-flags
+ CCASFLAGS_ORIG="${CCASFLAGS}"
+ CFLAGS_ORIG="${CFLAGS}"
+
+ local myconf=(
+ # Disable legacy syscall stub code in newlib. These have been
+ # moved to libgloss for a long time now, so the code in newlib
+ # itself just gets in the way.
+ --disable-newlib-supplied-syscalls
+ )
+ [[ ${CTARGET} == "spu" ]] \
+ && myconf+=( --disable-newlib-multithread ) \
+ || myconf+=( $(use_enable threads newlib-multithread) )
+
+ mkdir -p "${NEWLIBBUILD}"
+ cd "${NEWLIBBUILD}"
+
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+ ECONF_SOURCE=${S} \
+ econf \
+ $(use_enable unicode newlib-mb) \
+ $(use_enable nls) \
+ "${myconf[@]}"
+
+ # Build newlib-nano beside newlib (original)
+ # Based on https://tracker.debian.org/media/packages/n/newlib/rules-2.1.0%2Bgit20140818.1a8323b-2
+ if use nano ; then
+ mkdir -p "${NEWLIBNANOBUILD}" || die
+ cd "${NEWLIBNANOBUILD}" || die
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+ ECONF_SOURCE=${S} \
+ econf \
+ $(use_enable unicode newlib-mb) \
+ $(use_enable 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 \
+ "${myconf[@]}"
+ fi
+}
+
+src_compile() {
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+ emake -C "${NEWLIBBUILD}"
+
+ if use nano ; then
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+ emake -C "${NEWLIBNANOBUILD}"
+ fi
+}
+
+src_install() {
+ cd "${NEWLIBBUILD}" || die
+ emake -j1 DESTDIR="${D}" install
+
+ if use nano ; then
+ cd "${NEWLIBNANOBUILD}" || die
+ emake -j1 DESTDIR="${NEWLIBNANOTMPINSTALL}" install
+ # Rename nano lib* files to lib*_nano and move to the real ${D}
+ local nanolibfiles=""
+ nanolibfiles=$(find "${NEWLIBNANOTMPINSTALL}" -regex ".*/lib\(c\|g\|m\|rdimon\|gloss\)\.a" -print)
+ for f in ${nanolibfiles}; do
+ local l="${f##${NEWLIBNANOTMPINSTALL}}"
+ mv -v "${f}" "${D}/${l%%\.a}_nano.a" || die
+ done
+
+ # Move newlib-nano's version of newlib.h to newlib-nano/newlib.h
+ mkdir -p "${ED}/usr/${CTARGET}/include/newlib-nano" || die
+ mv "${NEWLIBNANOTMPINSTALL}/${EPREFIX}/usr/${CTARGET}/include/newlib.h" \
+ "${ED}/usr/${CTARGET}/include/newlib-nano/newlib.h" || die
+ fi
+
+ # minor hack to keep things clean
+ rm -rf "${D}"/usr/share/info || die
+ rm -rf "${D}"/usr/info || die
+}
diff --git a/sys-libs/newlib/newlib-4.3.0.20230120-r1.ebuild b/sys-libs/newlib/newlib-4.3.0.20230120-r1.ebuild
new file mode 100644
index 000000000000..21ce7e99de7c
--- /dev/null
+++ b/sys-libs/newlib/newlib-4.3.0.20230120-r1.ebuild
@@ -0,0 +1,153 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="7"
+
+inherit flag-o-matic toolchain-funcs
+
+if [[ ${PV} == "9999" ]] ; then
+ EGIT_REPO_URI="https://sourceware.org/git/newlib-cygwin.git"
+ inherit git-r3
+else
+ SRC_URI="ftp://sourceware.org/pub/newlib/${P}.tar.gz"
+ KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
+fi
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+
+DESCRIPTION="Newlib is a C library intended for use on embedded systems"
+HOMEPAGE="https://sourceware.org/newlib/"
+
+LICENSE="NEWLIB LIBGLOSS GPL-2"
+SLOT="0"
+IUSE="nls threads unicode headers-only nano"
+RESTRICT="strip"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-3.3.0-no-nano-cxx.patch
+)
+
+NEWLIBBUILD="${WORKDIR}/build"
+NEWLIBNANOBUILD="${WORKDIR}/build.nano"
+NEWLIBNANOTMPINSTALL="${WORKDIR}/nano_tmp_install"
+
+CFLAGS_FULL="-ffunction-sections -fdata-sections"
+CFLAGS_NANO="-Os -ffunction-sections -fdata-sections"
+
+pkg_setup() {
+ # Reject newlib-on-glibc type installs
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ case ${CHOST} in
+ *-newlib|*-elf) ;;
+ *) die "Use sys-devel/crossdev to build a newlib toolchain" ;;
+ esac
+ fi
+
+ case ${CTARGET} in
+ msp430*)
+ if ver_test $(gcc-version ${CTARGET}) -lt 10.1; then
+ # bug #717610
+ die "gcc for ${CTARGET} has to be 10.1 or above"
+ fi
+ ;;
+ esac
+}
+
+src_configure() {
+ # TODO: we should fix this
+ unset LDFLAGS
+ CHOST=${CTARGET} strip-unsupported-flags
+ CCASFLAGS_ORIG="${CCASFLAGS}"
+ CFLAGS_ORIG="${CFLAGS}"
+
+ local myconf=(
+ # The top-level configure doesn't utilize this flag, but subdirs do,
+ # so autodetection for econf doesn't work. Add ourselves.
+ --disable-silent-rules
+ # Disable legacy syscall stub code in newlib. These have been
+ # moved to libgloss for a long time now, so the code in newlib
+ # itself just gets in the way.
+ --disable-newlib-supplied-syscalls
+ )
+ [[ ${CTARGET} == "spu" ]] \
+ && myconf+=( --disable-newlib-multithread ) \
+ || myconf+=( $(use_enable threads newlib-multithread) )
+
+ mkdir -p "${NEWLIBBUILD}"
+ cd "${NEWLIBBUILD}"
+
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+ ECONF_SOURCE=${S} \
+ econf \
+ $(use_enable unicode newlib-mb) \
+ $(use_enable nls) \
+ "${myconf[@]}"
+
+ # Build newlib-nano beside newlib (original)
+ # Based on https://tracker.debian.org/media/packages/n/newlib/rules-2.1.0%2Bgit20140818.1a8323b-2
+ if use nano ; then
+ mkdir -p "${NEWLIBNANOBUILD}" || die
+ cd "${NEWLIBNANOBUILD}" || die
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+ ECONF_SOURCE=${S} \
+ econf \
+ $(use_enable unicode newlib-mb) \
+ $(use_enable 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 \
+ "${myconf[@]}"
+ fi
+}
+
+src_compile() {
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+ emake -C "${NEWLIBBUILD}"
+
+ if use nano ; then
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+ emake -C "${NEWLIBNANOBUILD}"
+ fi
+}
+
+src_install() {
+ cd "${NEWLIBBUILD}" || die
+ emake DESTDIR="${D}" install
+
+ if use nano ; then
+ cd "${NEWLIBNANOBUILD}" || die
+ emake DESTDIR="${NEWLIBNANOTMPINSTALL}" install
+ # Rename nano lib* files to lib*_nano and move to the real ${D}
+ local nanolibfiles=""
+ nanolibfiles=$(find "${NEWLIBNANOTMPINSTALL}" -regex ".*/lib\(c\|g\|m\|rdimon\|gloss\)\.a" -print)
+ for f in ${nanolibfiles}; do
+ local l="${f##${NEWLIBNANOTMPINSTALL}}"
+ mv -v "${f}" "${D}/${l%%\.a}_nano.a" || die
+ done
+
+ # Move newlib-nano's version of newlib.h to newlib-nano/newlib.h
+ mkdir -p "${ED}/usr/${CTARGET}/include/newlib-nano" || die
+ mv "${NEWLIBNANOTMPINSTALL}/${EPREFIX}/usr/${CTARGET}/include/newlib.h" \
+ "${ED}/usr/${CTARGET}/include/newlib-nano/newlib.h" || die
+ fi
+
+ # minor hack to keep things clean
+ rm -rf "${D}"/usr/share/info || die
+ rm -rf "${D}"/usr/info || die
+}
diff --git a/sys-libs/newlib/newlib-4.3.0.20230120-r2.ebuild b/sys-libs/newlib/newlib-4.3.0.20230120-r2.ebuild
new file mode 100644
index 000000000000..2436fa048633
--- /dev/null
+++ b/sys-libs/newlib/newlib-4.3.0.20230120-r2.ebuild
@@ -0,0 +1,155 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="7"
+
+inherit flag-o-matic toolchain-funcs
+
+if [[ ${PV} == "9999" ]] ; then
+ EGIT_REPO_URI="https://sourceware.org/git/newlib-cygwin.git"
+ inherit git-r3
+else
+ SRC_URI="ftp://sourceware.org/pub/newlib/${P}.tar.gz"
+ KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
+fi
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+
+DESCRIPTION="Newlib is a C library intended for use on embedded systems"
+HOMEPAGE="https://sourceware.org/newlib/"
+
+LICENSE="NEWLIB LIBGLOSS GPL-2"
+SLOT="0"
+IUSE="nls threads unicode headers-only nano"
+RESTRICT="strip"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-3.3.0-no-nano-cxx.patch
+ "${FILESDIR}"/${P}-libc-arm-setjmp-gcc-backwards-compat.patch
+)
+
+NEWLIBBUILD="${WORKDIR}/build"
+NEWLIBNANOBUILD="${WORKDIR}/build.nano"
+NEWLIBNANOTMPINSTALL="${WORKDIR}/nano_tmp_install"
+
+CFLAGS_FULL="-ffunction-sections -fdata-sections"
+CFLAGS_NANO="-Os -ffunction-sections -fdata-sections"
+
+pkg_setup() {
+ # Reject newlib-on-glibc type installs
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ case ${CHOST} in
+ *-newlib|*-elf) ;;
+ *) die "Use sys-devel/crossdev to build a newlib toolchain" ;;
+ esac
+ fi
+
+ case ${CTARGET} in
+ msp430*)
+ if ver_test $(gcc-version ${CTARGET}) -lt 10.1; then
+ # bug #717610
+ die "gcc for ${CTARGET} has to be 10.1 or above"
+ fi
+ ;;
+ esac
+}
+
+src_configure() {
+ # TODO: we should fix this
+ unset LDFLAGS
+ CHOST=${CTARGET} strip-unsupported-flags
+ CCASFLAGS_ORIG="${CCASFLAGS}"
+ CFLAGS_ORIG="${CFLAGS}"
+
+ local myconf=(
+ # The top-level configure doesn't utilize this flag, but subdirs do,
+ # so autodetection for econf doesn't work. Add ourselves.
+ --disable-dependency-tracking
+ --disable-silent-rules
+ # Disable legacy syscall stub code in newlib. These have been
+ # moved to libgloss for a long time now, so the code in newlib
+ # itself just gets in the way.
+ --disable-newlib-supplied-syscalls
+ )
+ [[ ${CTARGET} == "spu" ]] \
+ && myconf+=( --disable-newlib-multithread ) \
+ || myconf+=( $(use_enable threads newlib-multithread) )
+
+ mkdir -p "${NEWLIBBUILD}"
+ cd "${NEWLIBBUILD}"
+
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+ ECONF_SOURCE=${S} \
+ econf \
+ $(use_enable unicode newlib-mb) \
+ $(use_enable nls) \
+ "${myconf[@]}"
+
+ # Build newlib-nano beside newlib (original)
+ # Based on https://tracker.debian.org/media/packages/n/newlib/rules-2.1.0%2Bgit20140818.1a8323b-2
+ if use nano ; then
+ mkdir -p "${NEWLIBNANOBUILD}" || die
+ cd "${NEWLIBNANOBUILD}" || die
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+ ECONF_SOURCE=${S} \
+ econf \
+ $(use_enable unicode newlib-mb) \
+ $(use_enable 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 \
+ "${myconf[@]}"
+ fi
+}
+
+src_compile() {
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+ emake -C "${NEWLIBBUILD}"
+
+ if use nano ; then
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+ emake -C "${NEWLIBNANOBUILD}"
+ fi
+}
+
+src_install() {
+ cd "${NEWLIBBUILD}" || die
+ emake DESTDIR="${D}" install
+
+ if use nano ; then
+ cd "${NEWLIBNANOBUILD}" || die
+ emake DESTDIR="${NEWLIBNANOTMPINSTALL}" install
+ # Rename nano lib* files to lib*_nano and move to the real ${D}
+ local nanolibfiles=""
+ nanolibfiles=$(find "${NEWLIBNANOTMPINSTALL}" -regex ".*/lib\(c\|g\|m\|rdimon\|gloss\)\.a" -print)
+ for f in ${nanolibfiles}; do
+ local l="${f##${NEWLIBNANOTMPINSTALL}}"
+ mv -v "${f}" "${D}/${l%%\.a}_nano.a" || die
+ done
+
+ # Move newlib-nano's version of newlib.h to newlib-nano/newlib.h
+ mkdir -p "${ED}/usr/${CTARGET}/include/newlib-nano" || die
+ mv "${NEWLIBNANOTMPINSTALL}/${EPREFIX}/usr/${CTARGET}/include/newlib.h" \
+ "${ED}/usr/${CTARGET}/include/newlib-nano/newlib.h" || die
+ fi
+
+ # minor hack to keep things clean
+ rm -rf "${D}"/usr/share/info || die
+ rm -rf "${D}"/usr/info || die
+}
diff --git a/sys-libs/newlib/newlib-4.4.0.20231231.ebuild b/sys-libs/newlib/newlib-4.4.0.20231231.ebuild
new file mode 100644
index 000000000000..d29d3f10e0d1
--- /dev/null
+++ b/sys-libs/newlib/newlib-4.4.0.20231231.ebuild
@@ -0,0 +1,154 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="8"
+
+inherit flag-o-matic toolchain-funcs
+
+if [[ ${PV} == "9999" ]] ; then
+ EGIT_REPO_URI="https://sourceware.org/git/newlib-cygwin.git"
+ inherit git-r3
+else
+ SRC_URI="https://sourceware.org/pub/newlib/${P}.tar.gz"
+ KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
+fi
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+
+DESCRIPTION="Newlib is a C library intended for use on embedded systems"
+HOMEPAGE="https://sourceware.org/newlib/"
+
+LICENSE="NEWLIB LIBGLOSS GPL-2"
+SLOT="0"
+IUSE="nls threads unicode headers-only nano"
+RESTRICT="strip"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-3.3.0-no-nano-cxx.patch
+)
+
+NEWLIBBUILD="${WORKDIR}/build"
+NEWLIBNANOBUILD="${WORKDIR}/build.nano"
+NEWLIBNANOTMPINSTALL="${WORKDIR}/nano_tmp_install"
+
+CFLAGS_FULL="-ffunction-sections -fdata-sections"
+CFLAGS_NANO="-Os -ffunction-sections -fdata-sections"
+
+pkg_setup() {
+ # Reject newlib-on-glibc type installs
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ case ${CHOST} in
+ *-newlib|*-elf) ;;
+ *) die "Use sys-devel/crossdev to build a newlib toolchain" ;;
+ esac
+ fi
+
+ case ${CTARGET} in
+ msp430*)
+ if ver_test $(gcc-version ${CTARGET}) -lt 10.1; then
+ # bug #717610
+ die "gcc for ${CTARGET} has to be 10.1 or above"
+ fi
+ ;;
+ esac
+}
+
+src_configure() {
+ # TODO: we should fix this
+ unset LDFLAGS
+ CHOST=${CTARGET} strip-unsupported-flags
+ CCASFLAGS_ORIG="${CCASFLAGS}"
+ CFLAGS_ORIG="${CFLAGS}"
+
+ local myconf=(
+ # The top-level configure doesn't utilize this flag, but subdirs do,
+ # so autodetection for econf doesn't work. Add ourselves.
+ --disable-dependency-tracking
+ --disable-silent-rules
+ # Disable legacy syscall stub code in newlib. These have been
+ # moved to libgloss for a long time now, so the code in newlib
+ # itself just gets in the way.
+ --disable-newlib-supplied-syscalls
+ )
+ [[ ${CTARGET} == "spu" ]] \
+ && myconf+=( --disable-newlib-multithread ) \
+ || myconf+=( $(use_enable threads newlib-multithread) )
+
+ mkdir -p "${NEWLIBBUILD}"
+ cd "${NEWLIBBUILD}"
+
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+ ECONF_SOURCE=${S} \
+ econf \
+ $(use_enable unicode newlib-mb) \
+ $(use_enable nls) \
+ "${myconf[@]}"
+
+ # Build newlib-nano beside newlib (original)
+ # Based on https://tracker.debian.org/media/packages/n/newlib/rules-2.1.0%2Bgit20140818.1a8323b-2
+ if use nano ; then
+ mkdir -p "${NEWLIBNANOBUILD}" || die
+ cd "${NEWLIBNANOBUILD}" || die
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+ ECONF_SOURCE=${S} \
+ econf \
+ $(use_enable unicode newlib-mb) \
+ $(use_enable 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 \
+ "${myconf[@]}"
+ fi
+}
+
+src_compile() {
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+ emake -C "${NEWLIBBUILD}"
+
+ if use nano ; then
+ export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+ export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+ emake -C "${NEWLIBNANOBUILD}"
+ fi
+}
+
+src_install() {
+ cd "${NEWLIBBUILD}" || die
+ emake DESTDIR="${D}" install
+
+ if use nano ; then
+ cd "${NEWLIBNANOBUILD}" || die
+ emake DESTDIR="${NEWLIBNANOTMPINSTALL}" install
+ # Rename nano lib* files to lib*_nano and move to the real ${D}
+ local nanolibfiles=""
+ nanolibfiles=$(find "${NEWLIBNANOTMPINSTALL}" -regex ".*/lib\(c\|g\|m\|rdimon\|gloss\)\.a" -print)
+ for f in ${nanolibfiles}; do
+ local l="${f##${NEWLIBNANOTMPINSTALL}}"
+ mv -v "${f}" "${D}/${l%%\.a}_nano.a" || die
+ done
+
+ # Move newlib-nano's version of newlib.h to newlib-nano/newlib.h
+ mkdir -p "${ED}/usr/${CTARGET}/include/newlib-nano" || die
+ mv "${NEWLIBNANOTMPINSTALL}/${EPREFIX}/usr/${CTARGET}/include/newlib.h" \
+ "${ED}/usr/${CTARGET}/include/newlib-nano/newlib.h" || die
+ fi
+
+ # minor hack to keep things clean
+ rm -rf "${D}"/usr/share/info || die
+ rm -rf "${D}"/usr/info || die
+}
diff --git a/sys-libs/newlib/newlib-9999.ebuild b/sys-libs/newlib/newlib-9999.ebuild
index a5ec41db3c45..d29d3f10e0d1 100644
--- a/sys-libs/newlib/newlib-9999.ebuild
+++ b/sys-libs/newlib/newlib-9999.ebuild
@@ -1,7 +1,7 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI="7"
+EAPI="8"
inherit flag-o-matic toolchain-funcs
@@ -9,8 +9,8 @@ if [[ ${PV} == "9999" ]] ; then
EGIT_REPO_URI="https://sourceware.org/git/newlib-cygwin.git"
inherit git-r3
else
- SRC_URI="ftp://sourceware.org/pub/newlib/${P}.tar.gz"
- KEYWORDS="~arm ~hppa ~m68k ~mips ~ppc ~ppc64 ~sparc ~x86"
+ SRC_URI="https://sourceware.org/pub/newlib/${P}.tar.gz"
+ KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
fi
export CBUILD=${CBUILD:-${CHOST}}
@@ -37,12 +37,8 @@ NEWLIBBUILD="${WORKDIR}/build"
NEWLIBNANOBUILD="${WORKDIR}/build.nano"
NEWLIBNANOTMPINSTALL="${WORKDIR}/nano_tmp_install"
-# Adding -U_FORTIFY_SOURCE to counter the effect of Gentoo's
-# auto-addition of _FORTIFY_SOURCE at gcc site: bug #656018#c4
-# Currently newlib can't be built itself when _FORTIFY_SOURCE
-# is set.
-CFLAGS_FULL="-ffunction-sections -fdata-sections -U_FORTIFY_SOURCE"
-CFLAGS_NANO="-Os -ffunction-sections -fdata-sections -U_FORTIFY_SOURCE"
+CFLAGS_FULL="-ffunction-sections -fdata-sections"
+CFLAGS_NANO="-Os -ffunction-sections -fdata-sections"
pkg_setup() {
# Reject newlib-on-glibc type installs
@@ -71,6 +67,10 @@ src_configure() {
CFLAGS_ORIG="${CFLAGS}"
local myconf=(
+ # The top-level configure doesn't utilize this flag, but subdirs do,
+ # so autodetection for econf doesn't work. Add ourselves.
+ --disable-dependency-tracking
+ --disable-silent-rules
# Disable legacy syscall stub code in newlib. These have been
# moved to libgloss for a long time now, so the code in newlib
# itself just gets in the way.
@@ -111,7 +111,7 @@ src_configure() {
--enable-lite-exit \
--enable-newlib-global-atexit \
--enable-newlib-nano-formatted-io \
- ${myconf}
+ "${myconf[@]}"
fi
}
@@ -129,23 +129,23 @@ src_compile() {
src_install() {
cd "${NEWLIBBUILD}" || die
- emake -j1 DESTDIR="${D}" install
+ emake DESTDIR="${D}" install
if use nano ; then
cd "${NEWLIBNANOBUILD}" || die
- emake -j1 DESTDIR="${NEWLIBNANOTMPINSTALL}" install
+ emake DESTDIR="${NEWLIBNANOTMPINSTALL}" install
# Rename nano lib* files to lib*_nano and move to the real ${D}
local nanolibfiles=""
- nanolibfiles=$(find "${NEWLIBNANOTMPINSTALL}" -regex ".*/lib\(c\|g\|m\|rdimon\)\.a" -print)
+ nanolibfiles=$(find "${NEWLIBNANOTMPINSTALL}" -regex ".*/lib\(c\|g\|m\|rdimon\|gloss\)\.a" -print)
for f in ${nanolibfiles}; do
local l="${f##${NEWLIBNANOTMPINSTALL}}"
mv -v "${f}" "${D}/${l%%\.a}_nano.a" || die
done
# Move newlib-nano's version of newlib.h to newlib-nano/newlib.h
- mkdir -p "${D}/usr/${CTARGET}/include/newlib-nano" || die
- mv "${NEWLIBNANOTMPINSTALL}/usr/${CTARGET}/include/newlib.h" \
- "${D}/usr/${CTARGET}/include/newlib-nano/newlib.h" || die
+ mkdir -p "${ED}/usr/${CTARGET}/include/newlib-nano" || die
+ mv "${NEWLIBNANOTMPINSTALL}/${EPREFIX}/usr/${CTARGET}/include/newlib.h" \
+ "${ED}/usr/${CTARGET}/include/newlib-nano/newlib.h" || die
fi
# minor hack to keep things clean