# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/sys-devel/llvm/llvm-3.2.ebuild,v 1.5 2013/02/02 23:41:54 mgorny Exp $ EAPI=5 # pypy gives me around 1700 unresolved tests due to open file limit # being exceeded. probably GC does not close them fast enough. PYTHON_COMPAT=( python{2_5,2_6,2_7} ) inherit cmake-utils eutils flag-o-matic multilib python-r1 toolchain-funcs pax-utils DESCRIPTION="Low Level Virtual Machine" HOMEPAGE="http://llvm.org/" SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.gz !doc? ( http://dev.gentoo.org/~voyageur/distfiles/${P}-manpages.tar.bz2 ) compiler-rt? ( http://llvm.org/releases/${PV}/compiler-rt-${PV}.src.tar.gz )" LICENSE="UoI-NCSA" SLOT="0" KEYWORDS="~amd64 ~arm ~ppc ~x86 ~amd64-fbsd ~x86-fbsd ~x64-freebsd ~amd64-linux ~x86-linux" IUSE="compiler-rt debug doc gold +libffi multitarget test vim-syntax" DEPEND="dev-lang/perl >=sys-devel/make-3.79 >=sys-devel/flex-2.5.4 >=sys-devel/bison-1.875d || ( >=sys-devel/gcc-3.0 >=sys-devel/gcc-apple-4.2.1 ) || ( >=sys-devel/binutils-2.18 >=sys-devel/binutils-apple-3.2.3 ) doc? ( dev-python/sphinx ) gold? ( >=sys-devel/binutils-2.22[cxx] ) libffi? ( virtual/pkgconfig virtual/libffi ) test? ( compiler-rt? ( =sys-devel/clang-${PV} ) ) ${PYTHON_DEPS}" RDEPEND="dev-lang/perl libffi? ( virtual/libffi ) vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )" # Fails to build due to 'argument unused during compilation' warnings # from clang. REQUIRED_USE="test? ( !compiler-rt )" S=${WORKDIR}/${P}.src pkg_setup() { # need to check if the active compiler is ok broken_gcc=" 3.2.2 3.2.3 3.3.2 4.1.1 " broken_gcc_x86=" 3.4.0 3.4.2 " broken_gcc_amd64=" 3.4.6 " gcc_vers=$(gcc-fullversion) if [[ ${broken_gcc} == *" ${version} "* ]] ; then elog "Your version of gcc is known to miscompile llvm." elog "Check http://www.llvm.org/docs/GettingStarted.html for" elog "possible solutions." die "Your currently active version of gcc is known to miscompile llvm" fi if [[ ${CHOST} == i*86-* && ${broken_gcc_x86} == *" ${version} "* ]] ; then elog "Your version of gcc is known to miscompile llvm on x86" elog "architectures. Check" elog "http://www.llvm.org/docs/GettingStarted.html for possible" elog "solutions." die "Your currently active version of gcc is known to miscompile llvm" fi if [[ ${CHOST} == x86_64-* && ${broken_gcc_amd64} == *" ${version} "* ]]; then elog "Your version of gcc is known to miscompile llvm in amd64" elog "architectures. Check" elog "http://www.llvm.org/docs/GettingStarted.html for possible" elog "solutions." die "Your currently active version of gcc is known to miscompile llvm" fi } src_prepare() { sed -e "/ActiveLibDir = ActivePrefix/s/lib/$(get_libdir)\/${P}/" \ -i tools/llvm-config/llvm-config.cpp || die "llvm-config sed failed" epatch "${FILESDIR}"/${PN}-3.2-nodoctargz.patch epatch "${FILESDIR}"/${PN}-3.0-PPC_macro.patch epatch "${FILESDIR}"/${PN}-3.2-cmake-soversion.patch # User patches epatch_user } src_configure() { # build with a suitable Python version python_export_best if use libffi; then local ffi_flags=$(pkg-config --cflags libffi) fi # sadly, cmake doesn't seem to have host autodetection local target if use amd64 || use x86; then target=X86 elif use arm; then target=ARM elif use ppc; then target=PowerPC else die "No target set for arch ${ARCH}. Please report." fi if use multitarget; then target=all else target+=';CppBackend' fi local libdir=$(get_libdir) local mycmakeargs=( -DBUILD_SHARED_LIBS=ON -DLLVM_LIBDIR_SUFFIX=${libdir#lib} -DFFI_INCLUDE_DIR=${ffi_flags#-I} -DLLVM_TARGETS_TO_BUILD="${target}" $(cmake-utils_use libffi LLVM_ENABLE_FFI) $(cmake-utils_use debug LLVM_ENABLE_ASSERTIONS) $(use gold && echo -DLLVM_BINUTILS_INCDIR="${EPREFIX}"/usr/include) # tests have multiple targets, so it is easier to build them all $(cmake-utils_use test LLVM_BUILD_TESTS) # compiler-rt is built as an external project $(use compiler-rt && echo -DLLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR="${WORKDIR}"/compiler-rt-${PV}.src) ) # asan tests require clang... if use compiler-rt && use test; then ln -s "${EROOT}"/usr/bin/clang \ "${WORKDIR}"/compiler-rt-${PV}.src/lib/asan/tests/clang || die fi cmake-utils_src_configure } src_compile() { cmake-utils_src_compile use doc && emake -C docs -f Makefile.sphinx man html cd "${BUILD_DIR}" || die pax-mark m bin/lli if use test; then pax-mark m unittests/ExecutionEngine/JIT/Gentoo/JITTests pax-mark m unittests/ExecutionEngine/MCJIT/Gentoo/MCJITTests pax-mark m unittests/Support/Gentoo/SupportTests fi } src_test() { cmake-utils_src_make check } src_install() { cmake-utils_src_install # Bundled, likely needed for tests only. rm "${ED}"/usr/$(get_libdir)/libgtest* || die if use compiler-rt; then # AddressSanitizer symbolizer (currently separate) python_foreach_impl python_doscript \ "${WORKDIR}"/compiler-rt-${PV}.src/lib/asan/scripts/asan_symbolize.py fi if use doc; then doman docs/_build/man/*.1 dohtml -r docs/_build/html/ else doman "${WORKDIR}"/${P}-manpages/*.1 fi if use vim-syntax; then insinto /usr/share/vim/vimfiles/syntax doins utils/vim/*.vim fi }