--- sys-libs/libcxx/libcxx-9999.ebuild.orig 2015-02-07 22:12:53.000000000 +0100 +++ sys-libs/libcxx/libcxx-9999.ebuild.orig 2015-02-08 00:26:14.000000000 +0100 @@ -13,7 +13,9 @@ DESCRIPTION="New implementation of the C++ standard library, targeting C++11" HOMEPAGE="http://libcxx.llvm.org/" if [ "${PV%9999}" = "${PV}" ] ; then - SRC_URI="mirror://gentoo/${P}.tar.xz" + SRC_URI="mirror://gentoo/${P}.src.tar.xz + http://llvm.org/releases/${PV}/${P}.src.tar.xz" + S="${WORKDIR}"/"${P}".src else SRC_URI="" fi @@ -21,14 +23,17 @@ LICENSE="|| ( UoI-NCSA MIT )" SLOT="0" if [ "${PV%9999}" = "${PV}" ] ; then - KEYWORDS="~amd64 ~mips ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux" + KEYWORDS="~amd64 ~mips ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~x64-macos ~x86-macos" else KEYWORDS="" fi -IUSE="elibc_glibc +libcxxrt static-libs test" +IUSE="elibc_glibc libsupc static-libs test" -RDEPEND="libcxxrt? ( >=sys-libs/libcxxrt-0.0_p20130725[static-libs?,${MULTILIB_USEDEP}] ) - !libcxxrt? ( >=sys-devel/gcc-4.7[cxx] )" +REQUIRED_USE="kernel_Darwin? ( !libsupc !static-libs )" +RDEPEND="!kernel_Darwin? ( + !libsupc? ( >=sys-libs/libcxxrt-0.0_p20130725[static-libs?,${MULTILIB_USEDEP}] ) + libsupc? ( >=sys-devel/gcc-4.7[cxx] ) ) + kernel_Darwin? ( sys-libs/libcxx-headers sys-libs/libcxxabi sys-devel/clang )" DEPEND="${RDEPEND} test? ( sys-devel/clang ) app-arch/xz-utils" @@ -36,8 +41,19 @@ DOCS=( CREDITS.TXT ) pkg_setup() { - if ! use libcxxrt ; then - ewarn "You have disabled USE=libcxxrt. This will build ${PN} against" + if [[ ${CHOST} == *darwin* ]] ; then + MY_CC=$(tc-getCC) + MY_CXX=$(tc-getCXX) + if [[ ${MY_CC} != *clang* || ${MY_CXX} != *clang++* ]] ; then + eerror "${PN} needs to be built with clang++. Please do not override" + eerror "CC ($MY_CC) and CXX ($MY_CXX)" + eerror "or point them at clang and eerror clang++ respectively." + die + fi + return + fi + if use libsupc ; then + ewarn "You have enabled USE=libsupc. This will build ${PN} against" ewarn "libsupc++. Please note that this is not well supported." ewarn "In particular, static linking will not work." fi @@ -50,12 +66,51 @@ src_prepare() { cp -f "${FILESDIR}/Makefile" lib/ || die + + if [[ ${CHOST} == *darwin* ]] ; then + epatch "${FILESDIR}"/${PN}-3.5.1-olddarwin.patch + + [[ "${CHOST##*-darwin}" -le 10 ]] && \ + epatch "${FILESDIR}"/${PN}-3.5.1-cmath-conv.patch + + # libc++abi needs stack unwinding functions provided by libSystem on + # Mac OS X >= 10.6. On < 10.6 they're in libgcc_s. So force link + # against that. Additionally, the crt1.o provided by our gcc-apple + # toolchain isn't universal. Since that's needed for linking any + # program on OS X < 10.7, universal support is effectively broken on + # those older OS Xes even if clang and libc++{,abi} were to support it. + # So we can just disable universal compilation. + gcc_s=gcc_s.1 + [[ "${CHOST##*-darwin}" -eq 9 ]] && gcc_s=gcc_s.10.5 + [[ "${CHOST##*-darwin}" -eq 8 ]] && gcc_s=gcc_s.10.4 + [[ "${CHOST##*-darwin}" -le 9 ]] && \ + sed -i -e "s,/usr/lib/libSystem.B.dylib,-lSystem -l${gcc_s},g" \ + -e "s,-arch i386 -arch x86_64,,g" \ + lib/buildit + + if [[ "${CHOST##*-darwin}" -le 8 ]] ; then + epatch "${FILESDIR}"/${PN}-3.5.1-availability.patch + epatch "${FILESDIR}"/${PN}-3.5.1-eprintf.patch + fi + + # fix library install names + sed -i \ + -e "s,/usr/lib/libc++abi\.dylib,${EPREFIX}/usr/lib/libc++abi.dylib,g" \ + -e "s,/usr/lib/libc++\.1\.dylib,${EPREFIX}/usr/lib/libc++.1.dylib,g" \ + lib/buildit + fi + multilib_copy_sources } src_configure() { + tc-export AR CC CXX + + # on Darwin we're all set + [[ ${CHOST} == *darwin* ]] && return + export LIBS="-lpthread -lrt -lc -lgcc_s" - if use libcxxrt ; then + if ! use libsupc ; then append-cppflags -DLIBCXXRT "-I${EPREFIX}/usr/include/libcxxrt/" LIBS="-lcxxrt ${LIBS}" cp "${EPREFIX}/usr/include/libcxxrt/"*.h "${S}/include" @@ -80,13 +135,16 @@ done fi - tc-export AR CC CXX - append-ldflags "-Wl,-z,defs" # make sure we are not underlinked } multilib_src_compile() { cd "${BUILD_DIR}/lib" || die + if [[ ${CHOST} == *darwin* ]] ; then + TRIPLE=-apple- ./buildit || die + return + fi + emake shared use static-libs && emake static } @@ -98,7 +156,7 @@ CC="clang++ $(get_abi_CFLAGS) ${CXXFLAGS}" \ HEADER_INCLUDE="-I${BUILD_DIR}/include" \ SOURCE_LIB="-L${BUILD_DIR}/lib" \ - LIBS="-lm $(usex libcxxrt -lcxxrt "")" \ + LIBS="-lm $(usex libsupc "" -lcxxrt)" \ ./testit || die # TODO: fix link against libsupc++ } @@ -119,7 +177,7 @@ } gen_static_ldscript() { - if use libcxxrt ; then + if ! use libsupc ; then # Move it first. mv "${ED}/usr/$(get_libdir)/libc++.a" "${ED}/usr/$(get_libdir)/libc++_static.a" || die @@ -136,7 +194,7 @@ } gen_shared_ldscript() { - if use libcxxrt ; then + if ! use libsupc ; then mv "${ED}/usr/$(get_libdir)/libc++.so" "${ED}/usr/$(get_libdir)/libc++_shared.so" || die local deps="${EPREFIX}/usr/$(get_libdir)/libc++_shared.so ${EPREFIX}/usr/$(get_libdir)/libcxxrt.so" gen_ldscript "${deps}" > "${ED}/usr/$(get_libdir)/libc++.so" @@ -146,6 +204,11 @@ multilib_src_install() { cd "${BUILD_DIR}/lib" + if [[ ${CHOST} == *darwin* ]] ; then + dolib.so libc++*dylib + return + fi + if use static-libs ; then dolib.a libc++.a gen_static_ldscript @@ -156,6 +219,9 @@ multilib_src_install_all() { einstalldocs + # libc++abi needs the libc++ headers and we need libc++abi so the headers + # are already installed + [[ ${CHOST} == *darwin* ]] && return insinto /usr/include/c++/v1 doins -r include/* }