Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/newlib/
Date: Sat, 01 Jan 2022 01:42:54
Message-Id: 1641001323.16f3b7b366ebca1d4eb583f87071fac2cca371ac.vapier@gentoo
1 commit: 16f3b7b366ebca1d4eb583f87071fac2cca371ac
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jan 1 01:41:54 2022 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 1 01:42:03 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=16f3b7b3
7
8 sys-libs/newlib: version bump to 4.2.0.20211231
9
10 Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
11
12 sys-libs/newlib/Manifest | 1 +
13 sys-libs/newlib/newlib-4.2.0.20211231.ebuild | 154 +++++++++++++++++++++++++++
14 2 files changed, 155 insertions(+)
15
16 diff --git a/sys-libs/newlib/Manifest b/sys-libs/newlib/Manifest
17 index 2b71d80eb9bc..70c92629aba4 100644
18 --- a/sys-libs/newlib/Manifest
19 +++ b/sys-libs/newlib/Manifest
20 @@ -1 +1,2 @@
21 DIST newlib-4.1.0.tar.gz 18648429 BLAKE2B c4d4d734bceeacf05b75d450d4316392d0000266812f98f99cd3f9f0926ac9848e1dc145361827d1d6951edfe5f109923c982d9f284f927ffc5fd5e5edaf8be6 SHA512 6a24b64bb8136e4cd9d21b8720a36f87a34397fd952520af66903e183455c5cf19bb0ee4607c12a05d139c6c59382263383cb62c461a839f969d23d3bc4b1d34
22 +DIST newlib-4.2.0.20211231.tar.gz 18921589 BLAKE2B fb85a368d082e2b9005d5d295d6854eb7d0e351cfade6516e6a06b18656d9139d7629f55a6d5f63337c6bce511a2373e797bed96847f19941b26cacfb1c8d3bc SHA512 0c3efd7b74a6b8457a717cbb6aa6c5ff268eeaba375535465c6bd6502c3d32b54a9bc3ba7f2c6990f78e29152eee2f62acb39b674d24f9ddf440374a1ec9d2e8
23
24 diff --git a/sys-libs/newlib/newlib-4.2.0.20211231.ebuild b/sys-libs/newlib/newlib-4.2.0.20211231.ebuild
25 new file mode 100644
26 index 000000000000..a6ad7b9c65d1
27 --- /dev/null
28 +++ b/sys-libs/newlib/newlib-4.2.0.20211231.ebuild
29 @@ -0,0 +1,154 @@
30 +# Copyright 1999-2021 Gentoo Authors
31 +# Distributed under the terms of the GNU General Public License v2
32 +
33 +EAPI="7"
34 +
35 +inherit flag-o-matic toolchain-funcs
36 +
37 +if [[ ${PV} == "9999" ]] ; then
38 + EGIT_REPO_URI="https://sourceware.org/git/newlib-cygwin.git"
39 + inherit git-r3
40 +else
41 + SRC_URI="ftp://sourceware.org/pub/newlib/${P}.tar.gz"
42 + KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
43 +fi
44 +
45 +export CBUILD=${CBUILD:-${CHOST}}
46 +export CTARGET=${CTARGET:-${CHOST}}
47 +if [[ ${CTARGET} == ${CHOST} ]] ; then
48 + if [[ ${CATEGORY} == cross-* ]] ; then
49 + export CTARGET=${CATEGORY#cross-}
50 + fi
51 +fi
52 +
53 +DESCRIPTION="Newlib is a C library intended for use on embedded systems"
54 +HOMEPAGE="https://sourceware.org/newlib/"
55 +
56 +LICENSE="NEWLIB LIBGLOSS GPL-2"
57 +SLOT="0"
58 +IUSE="nls threads unicode headers-only nano"
59 +RESTRICT="strip"
60 +
61 +PATCHES=(
62 + "${FILESDIR}"/${PN}-3.3.0-no-nano-cxx.patch
63 +)
64 +
65 +NEWLIBBUILD="${WORKDIR}/build"
66 +NEWLIBNANOBUILD="${WORKDIR}/build.nano"
67 +NEWLIBNANOTMPINSTALL="${WORKDIR}/nano_tmp_install"
68 +
69 +# Adding -U_FORTIFY_SOURCE to counter the effect of Gentoo's
70 +# auto-addition of _FORTIFY_SOURCE at gcc site: bug #656018#c4
71 +# Currently newlib can't be built itself when _FORTIFY_SOURCE
72 +# is set.
73 +CFLAGS_FULL="-ffunction-sections -fdata-sections -U_FORTIFY_SOURCE"
74 +CFLAGS_NANO="-Os -ffunction-sections -fdata-sections -U_FORTIFY_SOURCE"
75 +
76 +pkg_setup() {
77 + # Reject newlib-on-glibc type installs
78 + if [[ ${CTARGET} == ${CHOST} ]] ; then
79 + case ${CHOST} in
80 + *-newlib|*-elf) ;;
81 + *) die "Use sys-devel/crossdev to build a newlib toolchain" ;;
82 + esac
83 + fi
84 +
85 + case ${CTARGET} in
86 + msp430*)
87 + if ver_test $(gcc-version ${CTARGET}) -lt 10.1; then
88 + # bug #717610
89 + die "gcc for ${CTARGET} has to be 10.1 or above"
90 + fi
91 + ;;
92 + esac
93 +}
94 +
95 +src_configure() {
96 + # TODO: we should fix this
97 + unset LDFLAGS
98 + CHOST=${CTARGET} strip-unsupported-flags
99 + CCASFLAGS_ORIG="${CCASFLAGS}"
100 + CFLAGS_ORIG="${CFLAGS}"
101 +
102 + local myconf=(
103 + # Disable legacy syscall stub code in newlib. These have been
104 + # moved to libgloss for a long time now, so the code in newlib
105 + # itself just gets in the way.
106 + --disable-newlib-supplied-syscalls
107 + )
108 + [[ ${CTARGET} == "spu" ]] \
109 + && myconf+=( --disable-newlib-multithread ) \
110 + || myconf+=( $(use_enable threads newlib-multithread) )
111 +
112 + mkdir -p "${NEWLIBBUILD}"
113 + cd "${NEWLIBBUILD}"
114 +
115 + export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
116 + export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
117 + ECONF_SOURCE=${S} \
118 + econf \
119 + $(use_enable unicode newlib-mb) \
120 + $(use_enable nls) \
121 + "${myconf[@]}"
122 +
123 + # Build newlib-nano beside newlib (original)
124 + # Based on https://tracker.debian.org/media/packages/n/newlib/rules-2.1.0%2Bgit20140818.1a8323b-2
125 + if use nano ; then
126 + mkdir -p "${NEWLIBNANOBUILD}" || die
127 + cd "${NEWLIBNANOBUILD}" || die
128 + export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
129 + export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
130 + ECONF_SOURCE=${S} \
131 + econf \
132 + $(use_enable unicode newlib-mb) \
133 + $(use_enable nls) \
134 + --enable-newlib-reent-small \
135 + --disable-newlib-fvwrite-in-streamio \
136 + --disable-newlib-fseek-optimization \
137 + --disable-newlib-wide-orient \
138 + --enable-newlib-nano-malloc \
139 + --disable-newlib-unbuf-stream-opt \
140 + --enable-lite-exit \
141 + --enable-newlib-global-atexit \
142 + --enable-newlib-nano-formatted-io \
143 + ${myconf}
144 + fi
145 +}
146 +
147 +src_compile() {
148 + export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
149 + export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
150 + emake -C "${NEWLIBBUILD}"
151 +
152 + if use nano ; then
153 + export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
154 + export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
155 + emake -C "${NEWLIBNANOBUILD}"
156 + fi
157 +}
158 +
159 +src_install() {
160 + cd "${NEWLIBBUILD}" || die
161 + emake -j1 DESTDIR="${D}" install
162 +
163 + if use nano ; then
164 + cd "${NEWLIBNANOBUILD}" || die
165 + emake -j1 DESTDIR="${NEWLIBNANOTMPINSTALL}" install
166 + # Rename nano lib* files to lib*_nano and move to the real ${D}
167 + local nanolibfiles=""
168 + nanolibfiles=$(find "${NEWLIBNANOTMPINSTALL}" -regex ".*/lib\(c\|g\|m\|rdimon\)\.a" -print)
169 + for f in ${nanolibfiles}; do
170 + local l="${f##${NEWLIBNANOTMPINSTALL}}"
171 + mv -v "${f}" "${D}/${l%%\.a}_nano.a" || die
172 + done
173 +
174 + # Move newlib-nano's version of newlib.h to newlib-nano/newlib.h
175 + mkdir -p "${D}/usr/${CTARGET}/include/newlib-nano" || die
176 + mv "${NEWLIBNANOTMPINSTALL}/usr/${CTARGET}/include/newlib.h" \
177 + "${D}/usr/${CTARGET}/include/newlib-nano/newlib.h" || die
178 + fi
179 +
180 + # minor hack to keep things clean
181 + rm -rf "${D}"/usr/share/info || die
182 + rm -rf "${D}"/usr/info || die
183 +}