Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/musl:master commit in: sys-libs/libcxx/, sys-libs/libcxx/files/
Date: Mon, 21 Sep 2015 08:46:01
Message-Id: 1442825373.b5eb2ede092b2d059d6e1d7799c4adfbc4b19978.blueness@gentoo
1 commit: b5eb2ede092b2d059d6e1d7799c4adfbc4b19978
2 Author: Chloe Kudryavtsev <chloe.kudryavtsev <AT> gmail <DOT> com>
3 AuthorDate: Sat Sep 19 07:32:17 2015 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Mon Sep 21 08:49:33 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=b5eb2ede
7
8 Fix LibC++ Under Musl
9
10 - Musl does not define locale-specific versions of functions (*_l)
11 - This may be because musl only supports UTF-8 at the moment
12 - This patch creates macros that redirect the *_l functions used to
13 their non-localized variants.
14 - Also, remove checks against GLIBC's version (EMSCRIPTEN) and
15 __GLIBC_PREREQ (based on vvavrychuk's 3.4.2 patch).
16
17 TODO: think about other LIBCs that might have confusing breakages due to
18 last change.
19
20 sys-libs/libcxx/Manifest | 6 +
21 sys-libs/libcxx/files/Makefile | 38 +++++
22 .../files/libcxx-3.7.0-musl-compatibility.patch | 70 ++++++++
23 sys-libs/libcxx/files/prepare_snapshot.sh | 16 ++
24 sys-libs/libcxx/libcxx-3.7.0-r99.ebuild | 176 +++++++++++++++++++++
25 sys-libs/libcxx/metadata.xml | 15 ++
26 6 files changed, 321 insertions(+)
27
28 diff --git a/sys-libs/libcxx/Manifest b/sys-libs/libcxx/Manifest
29 new file mode 100644
30 index 0000000..5ddeeee
31 --- /dev/null
32 +++ b/sys-libs/libcxx/Manifest
33 @@ -0,0 +1,6 @@
34 +AUX Makefile 874 SHA256 ba99d3b7b98ed88a64f8370ba2d90e245f8e5ea9bfe302382ef8eeded0ec00b4 SHA512 96eef2e897075bc7d9fc799ce6c54f6a33ee917efd5666376ac578cb16e15d965205630dbd076f92a3a7091d58ecc235e37bc327c211bf3594244981f089135f WHIRLPOOL 0680b69fdc46c0d6fac01fc2fa0b93ff62d167a03b3ce1cc80fbe57ff04356f5ab4e71f0daec517e629697d5e34f295b66e8263f7506eaa347a500b27442933d
35 +AUX libcxx-3.7.0-musl-compatibility.patch 2673 SHA256 9671760510032749208f4eacc3b1cea1757f1e7485d6449e23b2d3b69a75f62d SHA512 f42d465880087c67f782d004729b2a75574afb752961339d7501a3d4767964b5476a071d02fb610894ff4a24631ad60ac335434abe5a0643b41dcdb70ac8638e WHIRLPOOL 4da05e7820e6e813ef029efb9a8fc136d2f5c669809cc609d9e29cb56e9e8990678797a23110dec4b4e765180aa064587e04dd090aafda1eb8b8a751e935f701
36 +AUX prepare_snapshot.sh 427 SHA256 9ebf22257a2e296dee41a56b0a721cd1ba459c620009ca8422ba812515ff726f SHA512 ebac2a467f8b1dfb68f1dc46a35f8294d1cf74b70be2a008217fa13b3366ddf4a9f2ebbe611cd63824f42305c5c0304aac2f46386b2956c9e07d82d5d984b435 WHIRLPOOL 232a60d6a22f50c424ec9cf6f325bbb4e8e96815ba9dffdad0a5b1b872b19d20126d316ced71956978eb5ce098f72584d21104c14e232330b3893a73e4c3c358
37 +DIST libcxx-3.7.0.src.tar.xz 994580 SHA256 c18f3c8333cd7e678c1424a57fe5e25efe740ca7caf62ac67152b4723f3ad08e SHA512 e71d04efa0fafab129a97ca6f4fd7b5f185258de7455c7a25d0964f459bc6068c69c5d67199f6d7cd3541bdce630106cbaf3b7099e4737dddbdd57c77a3fe054 WHIRLPOOL 26672e3f6e0772504e7ee174c37e5fc20079c730ac8bd0d2563d5415ca9589360aa3be42a8aac15eb5a63c69227bd4911aa822b158b9a35e3d74ec0d71bb1300
38 +EBUILD libcxx-3.7.0-r99.ebuild 5444 SHA256 caf6ad314fdbdf86e9290bbcbb1b7619b215afbcee279d3dac9b67278aae36da SHA512 d17bc205320ec01c3546e99289d9923c1dc65214c49762f6fa41d498727c5e5cd658fe665c87b657ad41bc2c07640cd1b7fa907d6a30d9fa87e8d3fd61bbc703 WHIRLPOOL 0825e0cd24aebcfbe2bb23e5c1b3aba04fd65ea0a966b72c186f2ef736328b2a129eb7087e234d2ea88ddc30ab397630002a63bb898c0d76e67f16a19b58c714
39 +MISC metadata.xml 558 SHA256 c9fe7077a8c7f767d7cdbe154d85dd344fb86ea246b16613242c70a40f3e1ef2 SHA512 3f324c4959a7c9f2613b29928957fd010b35c6e9c1601f0296e7e8b7c8d59a3c27c5c04fef87ac825f2f7bb07553bc617c4405e1e22847dc8db3e7a1ebb21f50 WHIRLPOOL 3ade5e3852afcd533c89ce0aeead55101f23d1b31825718bfccd60fac485961df617c93962be4c60333a21335dcd6bb5630c8002fe06f456c4e177c14d434455
40
41 diff --git a/sys-libs/libcxx/files/Makefile b/sys-libs/libcxx/files/Makefile
42 new file mode 100644
43 index 0000000..029e729
44 --- /dev/null
45 +++ b/sys-libs/libcxx/files/Makefile
46 @@ -0,0 +1,38 @@
47 +CXXFLAGS+=-std=c++11 -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \
48 + -Wpadded -Wstrict-aliasing=2 -Wstrict-overflow=4
49 +
50 +SRCDIR=..
51 +LIB=libc++
52 +STATIC=libc++.a
53 +MAJOR=1
54 +MINOR=0
55 +SHEXT?=.so
56 +SHLIB=$(LIB)$(SHEXT).$(MAJOR).$(MINOR)
57 +SONAME=$(LIB)$(SHEXT).$(MAJOR)
58 +
59 +SRC=$(wildcard $(SRCDIR)/src/*.cpp)
60 +OBJ=$(SRC:$(SRCDIR)/src/%.cpp=%.o)
61 +SOBJ=$(SRC:$(SRCDIR)/src/%.cpp=%.So)
62 +
63 +
64 +%.So: $(SRCDIR)/src/%.cpp
65 + $(CXX) -I$(SRCDIR)/include $(CPPFLAGS) $(CXXFLAGS) -fPIC -nostdinc++ -c $< -o $@
66 +
67 +%.o: $(SRCDIR)/src/%.cpp
68 + $(CXX) -I$(SRCDIR)/include $(CPPFLAGS) $(CXXFLAGS) -nostdinc++ -c $< -o $@
69 +
70 +$(STATIC): $(OBJ)
71 + $(AR) cr $@ $^
72 +
73 +static: $(STATIC)
74 +
75 +$(SHLIB): $(SOBJ)
76 + $(CXX) -fPIC -nodefaultlibs $(CXXFLAGS) $(LDFLAGS) -shared -Wl,-soname,$(SONAME) -o $@ $^ $(LIBS)
77 +
78 +$(SONAME): $(SHLIB)
79 + ln -s $< $@
80 +
81 +$(LIB)$(SHEXT): $(SONAME)
82 + ln -s $< $@
83 +
84 +shared: $(SHLIB) $(SONAME) $(LIB)$(SHEXT)
85
86 diff --git a/sys-libs/libcxx/files/libcxx-3.7.0-musl-compatibility.patch b/sys-libs/libcxx/files/libcxx-3.7.0-musl-compatibility.patch
87 new file mode 100644
88 index 0000000..5e223bf
89 --- /dev/null
90 +++ b/sys-libs/libcxx/files/libcxx-3.7.0-musl-compatibility.patch
91 @@ -0,0 +1,70 @@
92 +diff -Naur libcxx-3.7.0.src.orig/include/__config libcxx-3.7.0.src/include/__config
93 +--- libcxx-3.7.0.src.orig/include/__config 2015-07-17 00:58:59.000000000 +0000
94 ++++ libcxx-3.7.0.src/include/__config 2015-09-19 07:56:55.295497669 +0000
95 +@@ -355,14 +355,10 @@
96 + #define _LIBCPP_HAS_QUICK_EXIT
97 + #elif defined(__linux__)
98 + #include <features.h>
99 +-#if __GLIBC_PREREQ(2, 15)
100 + #define _LIBCPP_HAS_QUICK_EXIT
101 +-#endif
102 +-#if __GLIBC_PREREQ(2, 17)
103 + #define _LIBCPP_HAS_C11_FEATURES
104 + #endif
105 + #endif
106 +-#endif
107 +
108 + #if (__has_feature(cxx_noexcept))
109 + # define _NOEXCEPT noexcept
110 +diff -Naur libcxx-3.7.0.src.orig/include/locale libcxx-3.7.0.src/include/locale
111 +--- libcxx-3.7.0.src.orig/include/locale 2015-09-19 08:02:51.101497669 +0000
112 ++++ libcxx-3.7.0.src/include/locale 2015-09-19 07:24:18.635497669 +0000
113 +@@ -11,6 +11,15 @@
114 + #ifndef _LIBCPP_LOCALE
115 + #define _LIBCPP_LOCALE
116 +
117 ++// musl doesn't define _l (with locale) variants of functions, as it only supports UTF-8.
118 ++// we can simply make macros that will call the non-localated ones if we're using musl, or rather not-using something that has the _l ones.
119 ++// couldn't find anything glibc #defines when it creates strtoull_l (that it doesn't undefine a few lines later), so let's test against glibc and glibc-likes.
120 ++// almost all glibc-likes define __GNU_LIBRARY__ for compatibility
121 ++#ifndef __GNU_LIBRARY__
122 ++#define strtoull_l(A, B, C, LOC) strtoull(A,B,C)
123 ++#define strtoll_l(A, B, C, LOC) strtoll(A,B,C)
124 ++#endif
125 ++
126 + /*
127 + locale synopsis
128 +
129 +diff -Naur libcxx-3.7.0.src.orig/src/locale.cpp libcxx-3.7.0.src/src/locale.cpp
130 +--- libcxx-3.7.0.src.orig/src/locale.cpp 2015-07-06 15:39:36.000000000 +0000
131 ++++ libcxx-3.7.0.src/src/locale.cpp 2015-09-19 07:59:59.979497669 +0000
132 +@@ -1012,11 +1012,10 @@
133 + return low;
134 + }
135 +
136 +-#ifdef __EMSCRIPTEN__
137 ++// we want this either way
138 + extern "C" const unsigned short ** __ctype_b_loc();
139 + extern "C" const int ** __ctype_tolower_loc();
140 + extern "C" const int ** __ctype_toupper_loc();
141 +-#endif
142 +
143 + #ifdef _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
144 + const ctype<char>::mask*
145 +@@ -1122,12 +1121,10 @@
146 + #elif defined(_AIX)
147 + return (const unsigned int *)__lc_ctype_ptr->obj->mask;
148 + #else
149 +- // Platform not supported: abort so the person doing the port knows what to
150 +- // fix
151 +-# warning ctype<char>::classic_table() is not implemented
152 +- printf("ctype<char>::classic_table() is not implemented\n");
153 +- abort();
154 +- return NULL;
155 ++// not sure any other libc like this exists, but there is no way to differentiate musl as of right now
156 ++// to be fair, with the change above, this should always work
157 ++// also, #warning is a gcc extension
158 ++ return (const unsigned long *)*__ctype_b_loc();
159 + #endif
160 + }
161 + #endif
162
163 diff --git a/sys-libs/libcxx/files/prepare_snapshot.sh b/sys-libs/libcxx/files/prepare_snapshot.sh
164 new file mode 100755
165 index 0000000..3de5a97
166 --- /dev/null
167 +++ b/sys-libs/libcxx/files/prepare_snapshot.sh
168 @@ -0,0 +1,16 @@
169 +#!/bin/sh
170 +VERSION=$(date +%Y%m%d)
171 +BASE_VERSION="0.0"
172 +PACKAGE="libcxx-${BASE_VERSION}_p${VERSION}"
173 +
174 +svn co http://llvm.org/svn/llvm-project/libcxx/trunk ${PACKAGE}
175 +
176 +find "${PACKAGE}" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
177 +find "${PACKAGE}" -type d -name '.git' -prune -print0 | xargs -0 rm -rf
178 +
179 +tar cJf ${PACKAGE}.tar.xz ${PACKAGE}
180 +rm -rf ${PACKAGE}/
181 +
182 +echo "Tarball: \"${PACKAGE}.tar.xz\""
183 +
184 +echo "** all done **"
185
186 diff --git a/sys-libs/libcxx/libcxx-3.7.0-r99.ebuild b/sys-libs/libcxx/libcxx-3.7.0-r99.ebuild
187 new file mode 100644
188 index 0000000..a557266
189 --- /dev/null
190 +++ b/sys-libs/libcxx/libcxx-3.7.0-r99.ebuild
191 @@ -0,0 +1,176 @@
192 +# Copyright 1999-2015 Gentoo Foundation
193 +# Distributed under the terms of the GNU General Public License v2
194 +# $Id$
195 +
196 +EAPI=5
197 +
198 +ESVN_REPO_URI="http://llvm.org/svn/llvm-project/libcxx/trunk"
199 +
200 +[ "${PV%9999}" != "${PV}" ] && SCM="subversion" || SCM=""
201 +
202 +inherit ${SCM} flag-o-matic toolchain-funcs multilib multilib-minimal
203 +
204 +DESCRIPTION="New implementation of the C++ standard library, targeting C++11"
205 +HOMEPAGE="http://libcxx.llvm.org/"
206 +if [ "${PV%9999}" = "${PV}" ] ; then
207 + SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz"
208 + S="${WORKDIR}/${P}.src"
209 +else
210 + SRC_URI=""
211 +fi
212 +
213 +LICENSE="|| ( UoI-NCSA MIT )"
214 +SLOT="0"
215 +if [ "${PV%9999}" = "${PV}" ] ; then
216 + KEYWORDS="~amd64 ~mips ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux"
217 +else
218 + KEYWORDS=""
219 +fi
220 +IUSE="elibc_glibc +libcxxrt +static-libs test"
221 +
222 +RDEPEND="libcxxrt? ( >=sys-libs/libcxxrt-0.0_p20130725[static-libs?,${MULTILIB_USEDEP}] )
223 + !libcxxrt? ( >=sys-devel/gcc-4.7:=[cxx] )"
224 +DEPEND="${RDEPEND}
225 + test? ( sys-devel/clang )
226 + app-arch/xz-utils"
227 +
228 +DOCS=( CREDITS.TXT )
229 +
230 +pkg_setup() {
231 + if ! use libcxxrt ; then
232 + ewarn "You have disabled USE=libcxxrt. This will build ${PN} against"
233 + ewarn "libsupc++. Please note that this is not well supported."
234 + ewarn "In particular, static linking will not work."
235 + fi
236 + if [[ $(gcc-version) < 4.7 ]] && [[ $(tc-getCXX) != *clang++* ]] ; then
237 + eerror "${PN} needs to be built with clang++ or gcc-4.7 or later."
238 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
239 + die
240 + fi
241 +}
242 +
243 +src_prepare() {
244 + cp -f "${FILESDIR}/Makefile" lib/ || die
245 + multilib_copy_sources
246 +}
247 +
248 +src_unpack() {
249 + unpack ${A}
250 + cd ${S}
251 + epatch "${FILESDIR}/${PN}-3.7.0-musl-compatibility.patch"
252 +}
253 +
254 +src_configure() {
255 + export LIBS="-lpthread -lrt -lc -lgcc_s"
256 + if use libcxxrt ; then
257 + append-cppflags -DLIBCXXRT "-I${EPREFIX}/usr/include/libcxxrt/"
258 + LIBS="-lcxxrt ${LIBS}"
259 + cp "${EPREFIX}/usr/include/libcxxrt/"*.h "${S}/include"
260 + else
261 + # Very hackish, see $HOMEPAGE
262 + # If someone has a clever idea, please share it!
263 + local includes="$(echo | ${CHOST}-g++ -Wp,-v -x c++ - -fsyntax-only 2>&1 | grep -C 2 '#include.*<...>' | tail -n 2 | sed -e 's/^ /-I/' | tr '\n' ' ')"
264 + local libcxx_gcc_dirs="$(echo | ${CHOST}-g++ -Wp,-v -x c++ - -fsyntax-only 2>&1 | grep -C 2 '#include.*<...>' | tail -n 2 | tr '\n' ' ')"
265 + append-cppflags -D__GLIBCXX__ ${includes}
266 + LIBS="-lsupc++ ${LIBS}"
267 + local libsupcxx_includes="cxxabi.h bits/c++config.h bits/os_defines.h bits/cpu_defines.h bits/cxxabi_tweaks.h bits/cxxabi_forced.h"
268 + for i in ${libsupcxx_includes} ; do
269 + local found=""
270 + [ -d "${S}/include/$(dirname ${i})/" ] || mkdir -p "${S}/include/$(dirname ${i})"
271 + for j in ${libcxx_gcc_dirs} ; do
272 + if [ -f "${j}/${i}" ] ; then
273 + cp "${j}/${i}" "${S}/include/$(dirname ${i})/" || die
274 + found=yes
275 + fi
276 + done
277 + [ -n "${found}" ] || die "Header not found: ${i}"
278 + done
279 + fi
280 +
281 + tc-export AR CC CXX
282 +
283 + append-ldflags "-Wl,-z,defs" # make sure we are not underlinked
284 +}
285 +
286 +multilib_src_compile() {
287 + cd "${BUILD_DIR}/lib" || die
288 + emake shared
289 + use static-libs && emake static
290 +}
291 +
292 +# Tests fail for now, if anybody is able to fix them, help is very welcome.
293 +multilib_src_test() {
294 + cd "${BUILD_DIR}/test"
295 + LD_LIBRARY_PATH="${BUILD_DIR}/lib:${LD_LIBRARY_PATH}" \
296 + CC="clang++ $(get_abi_CFLAGS) ${CXXFLAGS}" \
297 + HEADER_INCLUDE="-I${BUILD_DIR}/include" \
298 + SOURCE_LIB="-L${BUILD_DIR}/lib" \
299 + LIBS="-lm $(usex libcxxrt -lcxxrt "")" \
300 + ./testit || die
301 + # TODO: fix link against libsupc++
302 +}
303 +
304 +# Usage: deps
305 +gen_ldscript() {
306 + local output_format
307 + output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
308 + [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
309 +
310 + cat <<-END_LDSCRIPT
311 +/* GNU ld script
312 + Include missing dependencies
313 +*/
314 +${output_format}
315 +GROUP ( $@ )
316 +END_LDSCRIPT
317 +}
318 +
319 +gen_static_ldscript() {
320 + if use libcxxrt ; then
321 + # Move it first.
322 + mv "${ED}/usr/$(get_libdir)/libc++.a" "${ED}/usr/$(get_libdir)/libc++_static.a" || die
323 +
324 + # Generate libc++.a ldscript for inclusion of its dependencies so that
325 + # clang++ -stdlib=libc++ -static works out of the box.
326 + local deps="${EPREFIX}/usr/$(get_libdir)/libc++_static.a ${EPREFIX}/usr/$(get_libdir)/libcxxrt.a"
327 + # On Linux/glibc it does not link without libpthread or libdl. It is
328 + # fine on FreeBSD.
329 + use elibc_glibc && deps="${deps} ${EPREFIX}/usr/$(get_libdir)/libpthread.a ${EPREFIX}/usr/$(get_libdir)/libdl.a"
330 +
331 + gen_ldscript "${deps}" > "${ED}/usr/$(get_libdir)/libc++.a"
332 + fi
333 + # TODO: Generate a libc++.a ldscript when building against libsupc++
334 +}
335 +
336 +gen_shared_ldscript() {
337 + if use libcxxrt ; then
338 + mv "${ED}/usr/$(get_libdir)/libc++.so" "${ED}/usr/$(get_libdir)/libc++_shared.so" || die
339 + local deps="${EPREFIX}/usr/$(get_libdir)/libc++_shared.so ${EPREFIX}/usr/$(get_libdir)/libcxxrt.so"
340 + gen_ldscript "${deps}" > "${ED}/usr/$(get_libdir)/libc++.so"
341 + fi
342 + # TODO: Generate the linker script for other confiurations too.
343 +}
344 +
345 +multilib_src_install() {
346 + cd "${BUILD_DIR}/lib"
347 + if use static-libs ; then
348 + dolib.a libc++.a
349 + gen_static_ldscript
350 + fi
351 + dolib.so libc++.so*
352 + gen_shared_ldscript
353 +}
354 +
355 +multilib_src_install_all() {
356 + einstalldocs
357 + insinto /usr/include/c++/v1
358 + doins -r include/*
359 +}
360 +
361 +pkg_postinst() {
362 + elog "This package (${PN}) is mainly intended as a replacement for the C++"
363 + elog "standard library when using clang."
364 + elog "To use it, instead of libstdc++, use:"
365 + elog " clang++ -stdlib=libc++"
366 + elog "to compile your C++ programs."
367 +}
368
369 diff --git a/sys-libs/libcxx/metadata.xml b/sys-libs/libcxx/metadata.xml
370 new file mode 100644
371 index 0000000..578f810
372 --- /dev/null
373 +++ b/sys-libs/libcxx/metadata.xml
374 @@ -0,0 +1,15 @@
375 +<?xml version="1.0" encoding="UTF-8"?>
376 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
377 +<pkgmetadata>
378 + <herd>bsd</herd>
379 + <!-- BSD is here because the plan is to have libc++ as the standard C++
380 + library with clang. A llvm herd would make a lot of sense here too -->
381 + <maintainer>
382 + <email>aballier@g.o</email>
383 + <name>Alexis Ballier</name>
384 + </maintainer>
385 + <use>
386 + <flag name="libcxxrt">Build on top of <pkg>sys-libs/libcxxrt</pkg> instead of gcc's libsupc++ (avoids depending on gcc).</flag>
387 + </use>
388 +</pkgmetadata>
389 +