Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-libs/klibc: klibc-2.0.2-r1.ebuild ChangeLog
Date: Thu, 26 Dec 2013 20:18:36
Message-Id: 20131226201833.98A392004C@flycatcher.gentoo.org
1 robbat2 13/12/26 20:18:33
2
3 Modified: ChangeLog
4 Added: klibc-2.0.2-r1.ebuild
5 Log:
6 Bug #461982: Make it possible to build with custom-cflags, but not by default, as klibc is closer to kernel ABI than userspace.
7
8 (Portage version: 2.2.7/cvs/Linux x86_64, unsigned Manifest commit)
9
10 Revision Changes Path
11 1.96 dev-libs/klibc/ChangeLog
12
13 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/klibc/ChangeLog?rev=1.96&view=markup
14 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/klibc/ChangeLog?rev=1.96&content-type=text/plain
15 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/klibc/ChangeLog?r1=1.95&r2=1.96
16
17 Index: ChangeLog
18 ===================================================================
19 RCS file: /var/cvsroot/gentoo-x86/dev-libs/klibc/ChangeLog,v
20 retrieving revision 1.95
21 retrieving revision 1.96
22 diff -p -w -b -B -u -u -r1.95 -r1.96
23 --- ChangeLog 26 Dec 2013 19:40:02 -0000 1.95
24 +++ ChangeLog 26 Dec 2013 20:18:33 -0000 1.96
25 @@ -1,6 +1,12 @@
26 # ChangeLog for dev-libs/klibc
27 # Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
28 -# $Header: /var/cvsroot/gentoo-x86/dev-libs/klibc/ChangeLog,v 1.95 2013/12/26 19:40:02 robbat2 Exp $
29 +# $Header: /var/cvsroot/gentoo-x86/dev-libs/klibc/ChangeLog,v 1.96 2013/12/26 20:18:33 robbat2 Exp $
30 +
31 +*klibc-2.0.2-r1 (26 Dec 2013)
32 +
33 + 26 Dec 2013; Robin H. Johnson <robbat2@g.o> +klibc-2.0.2-r1.ebuild:
34 + Bug #461982: Make it possible to build with custom-cflags, but not by default,
35 + as klibc is closer to kernel ABI than userspace.
36
37 26 Dec 2013; Robin H. Johnson <robbat2@g.o> klibc-2.0.2.ebuild:
38 Bug #485482: Enable building on mixed 64-bit kernel + 32-bit userland; patch
39
40
41
42 1.1 dev-libs/klibc/klibc-2.0.2-r1.ebuild
43
44 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/klibc/klibc-2.0.2-r1.ebuild?rev=1.1&view=markup
45 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/klibc/klibc-2.0.2-r1.ebuild?rev=1.1&content-type=text/plain
46
47 Index: klibc-2.0.2-r1.ebuild
48 ===================================================================
49 # Copyright 1999-2013 Gentoo Foundation
50 # Distributed under the terms of the GNU General Public License v2
51 # $Header: /var/cvsroot/gentoo-x86/dev-libs/klibc/klibc-2.0.2-r1.ebuild,v 1.1 2013/12/26 20:18:33 robbat2 Exp $
52
53 # Robin H. Johnson <robbat2@g.o>, 12 Nov 2007:
54 # This still needs major work.
55 # But it is significently better than the previous version.
56 # In that it will now build on biarch systems, such as ppc64-32ul.
57
58 # NOTES:
59 # ======
60 # We need to bring in the kernel sources seperately
61 # Because they have to be configured in a way that differs from the copy in
62 # /usr/src/. The sys-kernel/linux-headers are too stripped down to use
63 # unfortunetly.
64 # This will be able to go away once the klibc author updates his code
65 # to build again the headers provided by the kernel's 'headers_install' target.
66
67 EAPI=5
68 K_TARBALL_SUFFIX="xz"
69
70 inherit eutils multilib toolchain-funcs flag-o-matic
71
72 DESCRIPTION="A minimal libc subset for use with initramfs."
73 HOMEPAGE="http://www.zytor.com/mailman/listinfo/klibc"
74 KV_MAJOR="3" KV_MINOR="x" KV_SUB="2"
75 PKV_EXTRA=""
76 if [[ ${PKV_EXTRA} ]]; then
77 if [[ ${KV_MAJOR} == 2 ]]; then
78 PKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_SUB}+1))-${PKV_EXTRA}"
79 else
80 PKV="${KV_MAJOR}.$((${KV_SUB}+1))-${PKV_EXTRA}"
81 fi
82 PATCH_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/patch-${PKV}.${K_TARBALL_SUFFIX}"
83 fi
84 if [[ ${KV_MAJOR} == 2 ]]; then
85 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_SUB}"
86 else
87 OKV="${KV_MAJOR}.${KV_SUB}"
88 fi
89 KERNEL_URI="
90 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.${K_TARBALL_SUFFIX}
91 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/linux-${OKV}.tar.${K_TARBALL_SUFFIX}"
92 SRC_URI="
93 mirror://kernel/linux/libs/klibc/${PV:0:3}/${P}.tar.${K_TARBALL_SUFFIX}
94 ${PATCH_URI}
95 ${KERNEL_URI}"
96
97 LICENSE="|| ( GPL-2 LGPL-2 )"
98 KEYWORDS="~alpha ~amd64 ~arm ~ia64 -mips ~ppc ~ppc64 ~sparc ~x86"
99 SLOT="0"
100 IUSE="debug test custom-cflags"
101
102 DEPEND="dev-lang/perl"
103 RDEPEND="${DEPEND}"
104
105 KS="${WORKDIR}/linux-${OKV}"
106
107 # Klibc has no PT_GNU_STACK support, so scanning for execstacks is moot
108 QA_EXECSTACK="*"
109 # Do not strip
110 RESTRICT="strip"
111
112 kernel_asm_arch() {
113 a="${1:${ARCH}}"
114 case ${a} in
115 # Merged arches
116 x86) echo i386 ;; # for build on x86 userspace & 64bit kernel
117 amd64) echo x86 ;;
118 ppc*) echo powerpc ;;
119 # Non-merged
120 alpha|arm|ia64|m68k|mips|sh|sparc*) echo ${1} ;;
121 *) die "TODO: Update the code for your asm-ARCH symlink" ;;
122 esac
123 }
124
125 # For a given Gentoo ARCH,
126 # specify the kernel defconfig most relevant
127 kernel_defconfig() {
128 a="${1:${ARCH}}"
129 # most, but not all arches have a sanely named defconfig
130 case ${a} in
131 ppc64) echo ppc64_defconfig ;;
132 ppc) echo pmac32_defconfig ;;
133 sh*) die "TODO: Your arch is not supported by the klibc ebuild. Please suggest a defconfig in a bug." ;;
134 *) echo defconfig ;;
135 esac
136 }
137
138 src_unpack() {
139 unpack linux-${OKV}.tar.${K_TARBALL_SUFFIX} ${P}.tar.${K_TARBALL_SUFFIX}
140 }
141
142 src_prepare() {
143 [[ ${PKV} ]] && EPATCH_OPTS="-d ${KS} -p1" epatch "${DISTDIR}"/patch-${PKV}.${K_TARBALL_SUFFIX}
144 cd "${S}"
145
146 # Symlink /usr/src/linux to ${S}/linux
147 ln -snf "${KS}" linux
148 #ln -snf "/usr" linux
149
150 # Build interp.o with EXTRA_KLIBCAFLAGS (.S source)
151 epatch "${FILESDIR}"/${PN}-1.4.11-interp-flags.patch
152
153 # Fix usage of -s, bug #201006
154 epatch "${FILESDIR}"/klibc-1.5.7-strip-fix-dash-s.patch
155 }
156
157 # klibc has it's own ideas of arches
158 # They reflect userspace strictly.
159 # This functions maps from a Gentoo ARCH, to an arch that klibc expects
160 # Look at klibc-${S}/usr/klibc/arch for a list of these arches
161 klibc_arch() {
162 a="${1:${ARCH}}"
163 case ${a} in
164 amd64) echo x86_64;;
165 mips) die 'TODO: Use the $ABI' ;;
166 x86) echo i386;;
167 *) echo ${a} ;;
168 esac
169 }
170
171 src_compile() {
172 local myargs="all"
173 local myARCH="${ARCH}" myABI="${ABI}"
174 # TODO: For cross-compiling
175 # You should set ARCH and ABI here
176 CC="$(tc-getCC)"
177 LD="$(tc-getLD)"
178 HOSTCC="$(tc-getBUILD_CC)"
179 HOSTLD="$(tc-getBUILD_LD)"
180 KLIBCARCH="$(klibc_arch ${ARCH})"
181 KLIBCASMARCH="$(kernel_asm_arch ${ARCH})"
182 libdir="$(get_libdir)"
183 # This should be the defconfig corresponding to your userspace!
184 # NOT your kernel. PPC64-32ul would choose 'ppc' for example.
185 defconfig=$(kernel_defconfig ${ARCH})
186 unset ABI ARCH # Unset these, because they interfere
187 unset KBUILD_OUTPUT # we are using a private copy
188
189 cd "${KS}"
190 emake ${defconfig} CC="${CC}" HOSTCC="${HOSTCC}" ARCH="${KLIBCASMARCH}" || die "No defconfig"
191 if [[ "${KLIBCARCH/arm}" != "${KLIBCARCH}" ]] && \
192 [[ "${CHOST/eabi}" != "${CHOST}" ]]; then
193 # The delete and insert are seperate statements
194 # so that they are reliably used.
195 sed -i \
196 -e '/CONFIG_AEABI/d' \
197 -e '1iCONFIG_AEABI=y' \
198 -e '/CONFIG_OABI_COMPAT/d' \
199 -e '1iCONFIG_OABI_COMPAT=y' \
200 "${KS}"/.config \
201 "${S}"/defconfig
202 fi
203 emake prepare CC="${CC}" HOSTCC="${HOSTCC}" ARCH="${KLIBCASMARCH}" || die "Failed to prepare kernel sources for header usage"
204
205 cd "${S}"
206
207 use debug && myargs="${myargs} V=1"
208 use test && myargs="${myargs} test"
209 append-ldflags -z noexecstack
210
211 emake \
212 EXTRA_KLIBCAFLAGS="-Wa,--noexecstack" \
213 EXTRA_KLIBCLDFLAGS="-z noexecstack" \
214 HOSTLDFLAGS="-z noexecstack" \
215 HOSTCC="${HOSTCC}" CC="${CC}" \
216 HOSTLD="${HOSTLD}" LD="${LD}" \
217 INSTALLDIR="/usr/${libdir}/klibc" \
218 KLIBCARCH=${KLIBCARCH} \
219 KLIBCASMARCH=${KLIBCASMARCH} \
220 SHLIBDIR="/${libdir}" \
221 libdir="/usr/${libdir}" \
222 mandir="/usr/share/man" \
223 T="${T}" \
224 $(use custom-cflags || echo SKIP_)HOSTCFLAGS="${CFLAGS}" \
225 $(use custom-cflags || echo SKIP_)HOSTLDFLAGS="${LDFLAGS}" \
226 ${myargs} || die "Compile failed!"
227
228 #SHLIBDIR="/${libdir}" \
229
230 ARCH="${myARCH}" ABI="${myABI}"
231 }
232
233 src_install() {
234 local myargs
235 local myARCH="${ARCH}" myABI="${ABI}"
236 # TODO: For cross-compiling
237 # You should set ARCH and ABI here
238 CC="$(tc-getCC)"
239 HOSTCC="$(tc-getBUILD_CC)"
240 KLIBCARCH="$(klibc_arch ${ARCH})"
241 KLIBCASMARCH="$(kernel_asm_arch ${ARCH})"
242 libdir="$(get_libdir)"
243 # This should be the defconfig corresponding to your userspace!
244 # NOT your kernel. PPC64-32ul would choose 'ppc' for example.
245 defconfig=$(kernel_defconfig ${ARCH})
246
247 use debug && myargs="${myargs} V=1"
248
249 local klibc_prefix
250 if tc-is-cross-compiler ; then
251 klibc_prefix=$("${S}/klcc/${KLIBCARCH}-klcc" -print-klibc-prefix)
252 else
253 klibc_prefix=$("${S}/klcc/klcc" -print-klibc-prefix)
254 fi
255
256 unset ABI ARCH # Unset these, because they interfere
257 unset KBUILD_OUTPUT # we are using a private copy
258
259 emake \
260 EXTRA_KLIBCAFLAGS="-Wa,--noexecstack" \
261 EXTRA_KLIBCLDFLAGS="-z noexecstack" \
262 HOSTLDFLAGS="-z noexecstack" \
263 HOSTCC="${HOSTCC}" CC="${CC}" \
264 HOSTLD="${HOSTLD}" LD="${LD}" \
265 INSTALLDIR="/usr/${libdir}/klibc" \
266 INSTALLROOT="${D}" \
267 KLIBCARCH=${KLIBCARCH} \
268 KLIBCASMARCH=${KLIBCASMARCH} \
269 SHLIBDIR="/${libdir}" \
270 libdir="/usr/${libdir}" \
271 mandir="/usr/share/man" \
272 T="${T}" \
273 $(use custom-cflags || echo SKIP_)HOSTCFLAGS="${CFLAGS}" \
274 $(use custom-cflags || echo SKIP_)HOSTLDFLAGS="${LDFLAGS}" \
275 ${myargs} \
276 install || die "Install failed!"
277
278 #SHLIBDIR="/${libdir}" \
279
280 # klibc doesn't support prelinking, so we need to mask it
281 cat > "${T}/70klibc" <<-EOF
282 PRELINK_PATH_MASK="/usr/${libdir}/klibc"
283 EOF
284
285 doenvd "${T}"/70klibc
286
287 # Fix the permissions (bug #178053) on /usr/${libdir}/klibc/include
288 # Actually I have no idea, why the includes have those weird-ass permissions
289 # on a particular system, might be due to inherited permissions from parent
290 # directory
291 find "${D}"/usr/${libdir}/klibc/include | xargs chmod o+rX
292 find "${D}"/usr/${libdir}/klibc/include -type f \
293 \( -name '.install' -o -name '..install.cmd' \) -delete || die
294
295 # Hardlinks becoming copies
296 for x in gunzip zcat ; do
297 rm -f "${D}/${klibc_prefix}/bin/${x}"
298 dosym gzip "${klibc_prefix}/bin/${x}"
299 done
300
301 # Restore now, so we can use the tc- functions
302 ARCH="${myARCH}" ABI="${myABI}"
303 if ! tc-is-cross-compiler ; then
304 cd "${S}"
305 insinto /usr/share/aclocal
306 doins contrib/klibc.m4
307
308 dodoc README usr/klibc/CAVEATS
309 docinto gzip; dodoc usr/gzip/README
310 fi
311
312 # Fix up the symlink
313 # Mainly for merged arches
314 linkname="${D}/usr/${libdir}/klibc/include/asm"
315 if [ -L "${linkname}" ] && [ ! -e "${linkname}" ] ; then
316 ln -snf asm-${KLIBCASMARCH} "${linkname}"
317 fi
318 }
319
320 src_test() {
321 if ! tc-is-cross-compiler ; then
322 cd "${S}"/usr/klibc/tests
323 ALL_TESTS="$(ls *.c |sed 's,\.c$,,g')"
324 BROKEN_TESTS="fcntl fnmatch testrand48"
325 failed=0
326 for t in $ALL_TESTS ; do
327 if has $t $BROKEN_TESTS ; then
328 echo "=== $t SKIP"
329 else
330 echo -n "=== $t "
331 ./$t </dev/null >/dev/null
332 rc=$?
333 if [ $rc -eq 0 ]; then
334 echo PASS
335 else
336 echo FAIL
337 failed=1
338 fi
339 fi
340 done
341 [ $failed -ne 0 ] && die "Some tests failed."
342 fi
343 }