diff options
8 files changed, 373 insertions, 235 deletions
diff --git a/sys-devel/llvm/ChangeLog b/sys-devel/llvm/ChangeLog index 42bb71cfef85..c7895b8cc3b8 100644 --- a/sys-devel/llvm/ChangeLog +++ b/sys-devel/llvm/ChangeLog @@ -1,6 +1,17 @@ # ChangeLog for sys-devel/llvm # Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-devel/llvm/ChangeLog,v 1.244 2015/06/05 14:48:25 voyageur Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-devel/llvm/ChangeLog,v 1.245 2015/06/09 16:54:50 mgorny Exp $ + + 09 Jun 2015; Michał Górny <mgorny@gentoo.org> + +files/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch, + +files/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch, + +files/cmake/0004-cmake-Do-not-install-libgtest.patch, +files/cmake/clang-0001 + -Install-clang-runtime-into-usr-lib-without-suffix.patch, + +files/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch, +fil + es/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi + .patch, llvm-9999.ebuild: + Switch the live ebuild to CMake, and few more improvements. Covered by bug + #456322. 05 Jun 2015; Bernard Cafarelli <voyageur@gentoo.org> llvm-3.6.1.ebuild, llvm-9999.ebuild: diff --git a/sys-devel/llvm/files/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch b/sys-devel/llvm/files/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch new file mode 100644 index 000000000000..3e57f0dcaa68 --- /dev/null +++ b/sys-devel/llvm/files/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch @@ -0,0 +1,36 @@ +From 2ec240a76253839cd1c5dc2e964f55698ae468fc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Mon, 8 Jun 2015 06:43:00 +0200 +Subject: [PATCH 2/4] cmake: Support overriding Sphinx HTML doc install + directory + +Provide ${PROJECT}_INSTALL_HTML variables (e.g. LLVM_INSTALL_HTML) to +override Sphinx HTML doc install directory. + +Fixes: https://llvm.org/bugs/show_bug.cgi?id=23780 +--- + cmake/modules/AddSphinxTarget.cmake | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/cmake/modules/AddSphinxTarget.cmake b/cmake/modules/AddSphinxTarget.cmake +index 045dc23..9c9c444 100644 +--- a/cmake/modules/AddSphinxTarget.cmake ++++ b/cmake/modules/AddSphinxTarget.cmake +@@ -53,8 +53,12 @@ function (add_sphinx_target builder project) + DESTINATION share/man/man1) + + elseif (builder STREQUAL html) +- install(DIRECTORY "${SPHINX_BUILD_DIR}" +- DESTINATION "share/doc/${project}") ++ string(TOUPPER "${project}" project_upper) ++ set(${project_upper}_INSTALL_HTML "share/doc/${project}/html" ++ CACHE STRING "HTML documentation install directory for ${project}") ++ ++ install(DIRECTORY "${SPHINX_BUILD_DIR}/" ++ DESTINATION "${${project_upper}_INSTALL_HTML}") + else() + message(WARNING Installation of ${builder} not supported) + endif() +-- +2.4.3 + diff --git a/sys-devel/llvm/files/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch b/sys-devel/llvm/files/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch new file mode 100644 index 000000000000..b1c74c69443f --- /dev/null +++ b/sys-devel/llvm/files/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch @@ -0,0 +1,32 @@ +From 4f7092ba05cccfeea7d26177d93f3d7a57d9bce2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Mon, 8 Jun 2015 14:29:03 +0200 +Subject: [PATCH 3/4] cmake: Add an ordering dep between HTML & man Sphinx + targets + +Add a dependency between HTML & manpage Sphinx targets to prevent two +instances of Sphinx from running in parallel, and therefore solves race +conditions reusing the same doctree directory. + +Fixes: https://llvm.org/bugs/show_bug.cgi?id=23781 +--- + docs/CMakeLists.txt | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt +index da27627..63309a6 100644 +--- a/docs/CMakeLists.txt ++++ b/docs/CMakeLists.txt +@@ -100,6 +100,9 @@ if (LLVM_ENABLE_SPHINX) + + if (${SPHINX_OUTPUT_MAN}) + add_sphinx_target(man llvm) ++ if (${SPHINX_OUTPUT_HTML}) ++ add_dependencies(docs-llvm-html docs-llvm-man) ++ endif() + endif() + + endif() +-- +2.4.3 + diff --git a/sys-devel/llvm/files/cmake/0004-cmake-Do-not-install-libgtest.patch b/sys-devel/llvm/files/cmake/0004-cmake-Do-not-install-libgtest.patch new file mode 100644 index 000000000000..92ca2e47e81b --- /dev/null +++ b/sys-devel/llvm/files/cmake/0004-cmake-Do-not-install-libgtest.patch @@ -0,0 +1,28 @@ +From d9f80393cfd4e586242ac3efd4e6ba6b49ce39ae Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Tue, 9 Jun 2015 11:58:52 +0200 +Subject: [PATCH 4/4] cmake: Do not install libgtest + +libgtest is an internal test dependency, and should not be installed to +the live system as a part of LLVM. +--- + utils/unittest/CMakeLists.txt | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/utils/unittest/CMakeLists.txt b/utils/unittest/CMakeLists.txt +index b34e22a..3fe5884 100644 +--- a/utils/unittest/CMakeLists.txt ++++ b/utils/unittest/CMakeLists.txt +@@ -41,6 +41,9 @@ if (PTHREAD_LIBRARY_PATH) + list(APPEND LIBS pthread) + endif() + ++# Delay building until the tests pull it in, and avoid installing it ++set(EXCLUDE_FROM_ALL ON) ++ + add_llvm_library(gtest + googletest/src/gtest-all.cc + +-- +2.4.3 + diff --git a/sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix.patch b/sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix.patch new file mode 100644 index 000000000000..904a72a358a9 --- /dev/null +++ b/sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix.patch @@ -0,0 +1,52 @@ +From b28503def986bcbc388a04be0d51cbe80bc59506 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Tue, 9 Jun 2015 12:11:50 +0200 +Subject: [PATCH] Install clang runtime into /usr/lib (without suffix) + +--- + lib/Driver/Driver.cpp | 3 +-- + lib/Frontend/CompilerInvocation.cpp | 3 +-- + lib/Headers/CMakeLists.txt | 2 +- + 3 files changed, 3 insertions(+), 5 deletions(-) + +diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp +index a04a1f8..418d46a 100644 +--- a/tools/clang/lib/Driver/Driver.cpp ++++ b/tools/clang//lib/Driver/Driver.cpp +@@ -66,8 +66,7 @@ Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple, + if (ClangResourceDir != "") { + llvm::sys::path::append(P, ClangResourceDir); + } else { +- StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX); +- llvm::sys::path::append(P, "..", Twine("lib") + ClangLibdirSuffix, "clang", ++ llvm::sys::path::append(P, "..", "lib", "clang", + CLANG_VERSION_STRING); + } + ResourceDir = P.str(); +diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp +index 9485767..0b9ecbd 100644 +--- a/tools/clang/lib/Frontend/CompilerInvocation.cpp ++++ b/tools/clang/lib/Frontend/CompilerInvocation.cpp +@@ -1053,8 +1053,7 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0, + if (ClangResourceDir != "") { + llvm::sys::path::append(P, ClangResourceDir); + } else { +- StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX); +- llvm::sys::path::append(P, "..", Twine("lib") + ClangLibdirSuffix, "clang", ++ llvm::sys::path::append(P, "..", "lib", "clang", + CLANG_VERSION_STRING); + } + +diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt +index 29a738e..3769d23 100644 +--- a/tools/clang/lib/Headers/CMakeLists.txt ++++ b/tools/clang/lib/Headers/CMakeLists.txt +@@ -93,4 +93,4 @@ set_target_properties(clang-headers PROPERTIES FOLDER "Misc") + install( + FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ +- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) ++ DESTINATION lib/clang/${CLANG_VERSION}/include) +-- +2.4.3 + diff --git a/sys-devel/llvm/files/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch b/sys-devel/llvm/files/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch new file mode 100644 index 000000000000..0b93deba0b58 --- /dev/null +++ b/sys-devel/llvm/files/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch @@ -0,0 +1,28 @@ +From d07632abe23d55eec2aae303a142a97765a77d32 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Tue, 9 Jun 2015 12:20:06 +0200 +Subject: [PATCH 2/2] cmake: Make CLANG_LIBDIR_SUFFIX overridable + +Make CLANG_LIBDIR_SUFFIX a cache variable so that it can be explicitly +overriden. It is used purely to find the LLVMgold.so plugin, so we want +to set it to native suffix. +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 357286b..647f976 100644 +--- a/tools/clang/CMakeLists.txt ++++ b/tools/clang/CMakeLists.txt +@@ -203,7 +203,7 @@ set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING + "Vendor-specific uti.") + + # The libdir suffix must exactly match whatever LLVM's configuration used. +-set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}") ++set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "") + + set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +-- +2.4.3 + diff --git a/sys-devel/llvm/files/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch b/sys-devel/llvm/files/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch new file mode 100644 index 000000000000..93538009d291 --- /dev/null +++ b/sys-devel/llvm/files/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch @@ -0,0 +1,25 @@ +From 8bd62a681744d3c31a0837c0f84f99ea4987e017 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Tue, 9 Jun 2015 12:17:57 +0200 +Subject: [PATCH] cmake: Install compiler-rt into /usr/lib (without suffix) + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0d8a880..5ae98a9 100644 +--- a/projects/compiler-rt/CMakeLists.txt ++++ b/projects/compiler-rt/CMakeLists.txt +@@ -52,7 +52,7 @@ if (NOT COMPILER_RT_STANDALONE_BUILD) + # Setup the paths where compiler-rt runtimes and headers should be stored. + set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}) + set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) +- set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}) ++ set(COMPILER_RT_INSTALL_PATH lib/clang/${CLANG_VERSION}) + option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests." + ${LLVM_INCLUDE_TESTS}) + option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered" +-- +2.4.3 + diff --git a/sys-devel/llvm/llvm-9999.ebuild b/sys-devel/llvm/llvm-9999.ebuild index 641b29a25196..90feb0a2ec9b 100644 --- a/sys-devel/llvm/llvm-9999.ebuild +++ b/sys-devel/llvm/llvm-9999.ebuild @@ -1,13 +1,14 @@ # Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-devel/llvm/llvm-9999.ebuild,v 1.110 2015/06/05 14:48:25 voyageur Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-devel/llvm/llvm-9999.ebuild,v 1.111 2015/06/09 16:54:50 mgorny Exp $ EAPI=5 +: ${CMAKE_MAKEFILE_GENERATOR:=ninja} PYTHON_COMPAT=( python2_7 pypy ) -inherit eutils flag-o-matic git-r3 multibuild multilib \ - multilib-minimal python-r1 toolchain-funcs pax-utils check-reqs +inherit check-reqs cmake-utils eutils flag-o-matic git-r3 multilib \ + multilib-minimal python-r1 toolchain-funcs pax-utils DESCRIPTION="Low Level Virtual Machine" HOMEPAGE="http://llvm.org/" @@ -18,9 +19,8 @@ EGIT_REPO_URI="http://llvm.org/git/llvm.git LICENSE="UoI-NCSA" SLOT="0/${PV}" KEYWORDS="" -IUSE="clang debug doc gold libedit +libffi multitarget ncurses ocaml python - +static-analyzer test xml video_cards_radeon - kernel_Darwin" +IUSE="clang debug doc gold libedit +libffi multitarget ncurses ocaml + python +static-analyzer test xml video_cards_radeon kernel_Darwin" COMMON_DEPEND=" sys-libs/zlib:0= @@ -36,7 +36,10 @@ COMMON_DEPEND=" libedit? ( dev-libs/libedit:0=[${MULTILIB_USEDEP}] ) libffi? ( >=virtual/libffi-3.0.13-r1:0=[${MULTILIB_USEDEP}] ) ncurses? ( >=sys-libs/ncurses-5.9-r3:5=[${MULTILIB_USEDEP}] ) - ocaml? ( dev-lang/ocaml:0= )" + ocaml? ( + dev-lang/ocaml:0= + dev-ml/findlib + dev-ml/ocaml-ctypes )" # configparser-3.2 breaks the build (3.3 or none at all are fine) DEPEND="${COMMON_DEPEND} dev-lang/perl @@ -64,11 +67,6 @@ PDEPEND="clang? ( =sys-devel/clang-${PV}-r100 )" REQUIRED_USE="${PYTHON_REQUIRED_USE} test? ( || ( $(python_gen_useflags 'python*') ) )" -# Some people actually override that in make.conf. That sucks since -# we need to run install per-directory, and ninja can't do that... -# so why did it call itself ninja in the first place? -CMAKE_MAKEFILE_GENERATOR=emake - pkg_pretend() { # in megs # !clang !debug !multitarget -O2 400 @@ -144,195 +142,172 @@ src_unpack() { } src_prepare() { - epatch "${FILESDIR}"/${PN}-3.7-nodoctargz.patch epatch "${FILESDIR}"/${PN}-3.5-gcc-4.9.patch - epatch "${FILESDIR}"/${PN}-3.6-gentoo-install.patch # Make ocaml warnings non-fatal, bug #537308 sed -e "/RUN/s/-warn-error A//" -i test/Bindings/OCaml/*ml || die + # Make it possible to override Sphinx HTML install dirs + # https://llvm.org/bugs/show_bug.cgi?id=23780 + epatch "${FILESDIR}"/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch + + # Prevent race conditions with parallel Sphinx runs + # https://llvm.org/bugs/show_bug.cgi?id=23781 + epatch "${FILESDIR}"/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch + + # Prevent installing libgtest + # https://llvm.org/bugs/show_bug.cgi?id=18341 + epatch "${FILESDIR}"/cmake/0004-cmake-Do-not-install-libgtest.patch + if use clang; then # Automatically select active system GCC's libraries, bugs #406163 and #417913 epatch "${FILESDIR}"/clang-3.5-gentoo-runtime-gcc-detection-v3.patch epatch "${FILESDIR}"/clang-3.6-gentoo-install.patch - fi - if use prefix && use clang; then - sed -i -e "/^CFLAGS /s@-Werror@-I${EPREFIX}/usr/include@" \ - projects/compiler-rt/make/platform/clang_*.mk || die - fi + sed -i -e "s^@EPREFIX@^${EPREFIX}^" \ + tools/clang/tools/scan-build/scan-build || die - local sub_files=( - Makefile.config.in - Makefile.rules - tools/llvm-config/llvm-config.cpp - ) - use clang && sub_files+=( - tools/clang/lib/Driver/Tools.cpp - tools/clang/tools/scan-build/scan-build - ) + # Install clang runtime into /usr/lib/clang + # https://llvm.org/bugs/show_bug.cgi?id=23792 + epatch "${FILESDIR}"/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix.patch + epatch "${FILESDIR}"/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch - # unfortunately ./configure won't listen to --mandir and the-like, so take - # care of this. - # note: we're setting the main libdir intentionally. - # where per-ABI is appropriate, we use $(GENTOO_LIBDIR) make. - einfo "Fixing install dirs" - sed -e "s,@libdir@,$(get_libdir),g" \ - -e "s,@PF@,${PF},g" \ - -e "s,@EPREFIX@,${EPREFIX},g" \ - -i "${sub_files[@]}" \ - || die "install paths sed failed" + # Make it possible to override CLANG_LIBDIR_SUFFIX + # (that is used only to find LLVMgold.so) + # https://llvm.org/bugs/show_bug.cgi?id=23793 + epatch "${FILESDIR}"/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch + fi # User patches epatch_user python_setup + + # Native libdir is used to hold LLVMgold.so + NATIVE_LIBDIR=$(get_libdir) } multilib_src_configure() { - # disable timestamps since they confuse ccache - local conf_flags=( - --disable-timestamps - --enable-keep-symbols - --enable-shared - --with-optimize-option= - $(tc-is-static-only && echo --disable-shared) - $(use_enable !debug optimized) - $(use_enable debug assertions) - $(use_enable debug expensive-checks) - $(use_enable libedit) - $(use_enable ncurses terminfo) - $(use_enable libffi) - ) - - # well, it's used only by clang executable c-index-test - if multilib_is_native_abi && use clang && use xml; then - conf_flags+=( XML2CONFIG="$(tc-getPKG_CONFIG) libxml-2.0" ) - else - conf_flags+=( ac_cv_prog_XML2CONFIG="" ) - fi - - local targets bindings + local targets if use multitarget; then - targets='all' + targets=all else - targets='host,cpp' - use video_cards_radeon && targets+=',r600' + targets='host;CppBackend' + use video_cards_radeon && targets+=';R600' fi - conf_flags+=( --enable-targets=${targets} ) - if multilib_is_native_abi; then - use gold && conf_flags+=( --with-binutils-include="${EPREFIX}"/usr/include/ ) - # extra commas don't hurt - use ocaml && bindings+=',ocaml' + local ffi_cflags ffi_ldflags + if use libffi; then + ffi_cflags=$(pkg-config --cflags-only-I libffi) + ffi_ldflags=$(pkg-config --libs-only-L libffi) fi - [[ ${bindings} ]] || bindings='none' - conf_flags+=( --enable-bindings=${bindings} ) + local libdir=$(get_libdir) + local mycmakeargs=( + "${mycmakeargs[@]}" + -DLLVM_LIBDIR_SUFFIX=${libdir#lib} - if use libffi; then - local CPPFLAGS=${CPPFLAGS} - append-cppflags "$(pkg-config --cflags libffi)" - fi + -DBUILD_SHARED_LIBS=ON + -DLLVM_ENABLE_TIMESTAMPS=OFF + -DLLVM_TARGETS_TO_BUILD="${targets}" + -DLLVM_BUILD_TESTS=$(usex test) - # Enable large file support, bug #550708 - append-lfs-flags - # llvm prefers clang over gcc, so we may need to force that - tc-export CC CXX + -DLLVM_ENABLE_FFI=$(usex libffi) + -DLLVM_ENABLE_TERMINFO=$(usex ncurses) + -DLLVM_ENABLE_ASSERTIONS=$(usex debug) - ECONF_SOURCE=${S} \ - econf "${conf_flags[@]}" -} + -DWITH_POLLY=OFF # TODO -set_makeargs() { - MAKEARGS=( - VERBOSE=1 - REQUIRES_RTTI=1 - GENTOO_LIBDIR=$(get_libdir) + -DLLVM_HOST_TRIPLE="${CHOST}" + + -DFFI_INCLUDE_DIR="${ffi_cflags#-I}" + -DFFI_LIBRARY_DIR="${ffi_ldflags#-L}" + + -DHAVE_HISTEDIT_H=$(usex libedit) ) - # for tests, we want it all! otherwise, we may use a little filtering... - # adding ONLY_TOOLS also disables unittest building... - if [[ ${EBUILD_PHASE_FUNC} != src_test ]]; then - local tools=( llvm-config ) - use clang && tools+=( clang ) - - if multilib_is_native_abi; then - tools+=( - opt llvm-as llvm-dis llc llvm-ar llvm-nm llvm-link lli - llvm-extract llvm-mc llvm-bcanalyzer llvm-diff macho-dump - llvm-objdump llvm-readobj llvm-rtdyld llvm-dwarfdump llvm-cov - llvm-size llvm-stress llvm-mcmarkup llvm-profdata - llvm-symbolizer obj2yaml yaml2obj lto bugpoint - ) + if ! multilib_is_native_abi || ! use ocaml; then + mycmakeargs+=( + -DOCAMLFIND=NO + ) + fi +# Note: go bindings have no CMake rules at the moment +# but let's kill the check in case they are introduced +# if ! multilib_is_native_abi || ! use go; then + mycmakeargs+=( + -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND + ) +# fi - # the build system runs explicitly specified tools in parallel, - # so we need to split it into two runs - if [[ ${1} != -1 ]]; then - # those require lto - tools+=( llvm-lto ) - use gold && tools+=( gold ) - - # those require clang :) - # we need to explicitly specify all its tools - # since we're passing BUILD_CLANG_ONLY - use clang && tools+=( - clang/tools/{clang-check,clang-format,extra} - ) - fi + if multilib_is_native_abi; then + mycmakeargs+=( + -DLLVM_BUILD_DOCS=ON + -DLLVM_ENABLE_DOXYGEN=OFF + -DLLVM_ENABLE_SPHINX=ON + -DSPHINX_OUTPUT_HTML=$(usex doc) + + -DLLVM_INSTALL_HTML="${EPREFIX}/usr/share/doc/${PF}/html" + ) + + if use clang; then + mycmakeargs+=( + -DCLANG_INSTALL_HTML="${EPREFIX}/usr/share/doc/${PF}/clang" + ) fi - MAKEARGS+=( - # filter tools + disable unittests implicitly - ONLY_TOOLS="${tools[*]}" + if use gold; then + mycmakeargs+=( + -DLLVM_BINUTILS_INCDIR="${EPREFIX}"/usr/include + ) + fi + else + if use clang; then + mycmakeargs+=( + # disable compiler-rt on non-native ABI because: + # 1. it fails to configure because of -m32 + # 2. it is shared between ABIs so no point building + # it multiple times + -DLLVM_EXTERNAL_COMPILER_RT_BUILD=OFF + -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_BUILD=OFF + ) + fi + fi - # this disables unittests & docs from clang - BUILD_CLANG_ONLY=YES + if use clang; then + mycmakeargs+=( + -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) + -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) + -DCLANG_LIBDIR_SUFFIX="${NATIVE_LIBDIR#lib}" ) + + # -- not needed when compiler-rt is built with host compiler -- + # cmake passes host C*FLAGS to compiler-rt build + # which is performed using clang, so we need to filter out + # some flags clang does not support + # (if you know some more flags that don't work, let us know) + #filter-flags -msahf -frecord-gcc-switches fi + + cmake-utils_src_configure } multilib_src_compile() { - local MAKEARGS - set_makeargs -1 - emake "${MAKEARGS[@]}" - - if multilib_is_native_abi; then - set_makeargs - emake -C tools "${MAKEARGS[@]}" + cmake-utils_src_compile - emake -C "${S}"/docs -f Makefile.sphinx man - use clang && emake -C "${S}"/tools/clang/docs/tools \ - BUILD_FOR_WEBSITE=1 DST_MAN_DIR="${T}"/ man - use doc && emake -C "${S}"/docs -f Makefile.sphinx html - fi - - if use debug; then - pax-mark m Debug+Asserts+Checks/bin/llvm-rtdyld - pax-mark m Debug+Asserts+Checks/bin/lli - pax-mark m Debug+Asserts+Checks/bin/lli-child-target - else - pax-mark m Release/bin/llvm-rtdyld - pax-mark m Release/bin/lli - pax-mark m Release/bin/lli-child-target + if use test; then + pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/Orc/OrcJITTests + pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/MCJIT/MCJITTests + pax-mark m "${BUILD_DIR}"/unittests/Support/SupportTests fi } multilib_src_test() { - local MAKEARGS - set_makeargs - - # build the remaining tools & unittests - emake "${MAKEARGS[@]}" - - pax-mark m unittests/ExecutionEngine/JIT/Release/JITTests - pax-mark m unittests/ExecutionEngine/MCJIT/Release/MCJITTests - pax-mark m unittests/Support/Release/SupportTests - # respect TMPDIR! local -x LIT_PRESERVES_TMP=1 - emake "${MAKEARGS[@]}" check - use clang && emake "${MAKEARGS[@]}" -C tools/clang test + local test_targets=( check ) + # clang tests won't work on non-native ABI because we skip compiler-rt + multilib_is_native_abi && use clang && test_targets+=( check-clang ) + cmake-utils_src_make "${test_targets[@]}" } src_install() { @@ -346,12 +321,16 @@ src_install() { ) if use clang; then - # note: magic applied below + # note: magic applied in multilib_src_install()! + CLANG_VERSION=3.7 + MULTILIB_CHOST_TOOLS+=( /usr/bin/clang /usr/bin/clang++ - /usr/bin/clang-${PV} - /usr/bin/clang++-${PV} + /usr/bin/clang-cl + /usr/bin/clang-${CLANG_VERSION} + /usr/bin/clang++-${CLANG_VERSION} + /usr/bin/clang-cl-${CLANG_VERSION} ) MULTILIB_WRAPPED_HEADERS+=( @@ -359,112 +338,59 @@ src_install() { ) fi + multilib-minimal_src_install } multilib_src_install() { - local MAKEARGS - set_makeargs - - local root=${D}/_${ABI} - - emake "${MAKEARGS[@]}" DESTDIR="${root}" install - multibuild_merge_root "${root}" "${D}" + cmake-utils_src_install - if ! multilib_is_native_abi; then - # Backwards compat, will be happily removed someday. - dosym "${CHOST}"-llvm-config /usr/bin/llvm-config.${ABI} - else + if multilib_is_native_abi; then # Install docs. - doman "${S}"/docs/_build/man/*.1 - use clang && doman "${T}"/clang.1 - use doc && dohtml -r "${S}"/docs/_build/html/ + #use doc && dohtml -r "${S}"/docs/_build/html/ # Symlink the gold plugin. if use gold; then - dodir /usr/${CHOST}/binutils-bin/lib/bfd-plugins - dosym ../../../../$(get_libdir)/LLVMgold.so \ - /usr/${CHOST}/binutils-bin/lib/bfd-plugins/LLVMgold.so + dodir "/usr/${CHOST}/binutils-bin/lib/bfd-plugins" + dosym "../../../../$(get_libdir)/LLVMgold.so" \ + "/usr/${CHOST}/binutils-bin/lib/bfd-plugins/LLVMgold.so" fi fi - # apply CHOST and PV to clang executables + # apply CHOST and CLANG_VERSION to clang executables # they're statically linked so we don't have to worry about the lib if use clang; then - local clang_tools=( clang clang++ ) + local clang_tools=( clang clang++ clang-cl ) local i - # append ${PV} and symlink back - # TODO: use alternatives.eclass? does that make any sense? - # maybe with USE=-clang on :0 and USE=clang on older - for i in "${clang_tools[@]}"; do - mv "${ED%/}/usr/bin/${i}"{,-${PV}} || die - dosym "${i}"-${PV} /usr/bin/${i} + # cmake gives us: + # - clang-X.Y + # - clang -> clang-X.Y + # - clang++, clang-cl -> clang + # we want to have: + # - clang-X.Y + # - clang++-X.Y, clang-cl-X.Y -> clang-X.Y + # - clang, clang++, clang-cl -> clang*-X.Y + # so we need to fix the two tools + for i in "${clang_tools[@]:1}"; do + rm "${ED%/}/usr/bin/${i}" || die + dosym "clang-${CLANG_VERSION}" "/usr/bin/${i}-${CLANG_VERSION}" + dosym "${i}-${CLANG_VERSION}" "/usr/bin/${i}" done # now prepend ${CHOST} and let the multilib-build.eclass symlink it if ! multilib_is_native_abi; then # non-native? let's replace it with a simple wrapper for i in "${clang_tools[@]}"; do - rm "${ED%/}/usr/bin/${i}-${PV}" || die + rm "${ED%/}/usr/bin/${i}-${CLANG_VERSION}" || die cat > "${T}"/wrapper.tmp <<-_EOF_ #!${EPREFIX}/bin/sh - exec "${i}-${PV}" $(get_abi_CFLAGS) "\${@}" + exec "${i}-${CLANG_VERSION}" $(get_abi_CFLAGS) "\${@}" _EOF_ - newbin "${T}"/wrapper.tmp "${i}-${PV}" + newbin "${T}"/wrapper.tmp "${i}-${CLANG_VERSION}" done fi fi - - # Fix install_names on Darwin. The build system is too complicated - # to just fix this, so we correct it post-install - local lib= f= odylib= ndylib= libpv=${PV} - if [[ ${CHOST} == *-darwin* ]] ; then - eval $(grep PACKAGE_VERSION= configure) - [[ -n ${PACKAGE_VERSION} ]] && libpv=${PACKAGE_VERSION} - libpvminor=${libpv%.[0-9]*} - for lib in lib{EnhancedDisassembly,LLVM-${libpv},LTO,profile_rt,clang}.dylib LLVMHello.dylib clang/${libpv}/lib/darwin/libclang_rt.asan_{osx,iossim}_dynamic.dylib; do - # libEnhancedDisassembly is Darwin10 only, so non-fatal - # + omit clang libs if not enabled - [[ -f ${ED}/usr/lib/${lib} ]] || continue - - ebegin "fixing install_name of $lib" - install_name_tool \ - -id "${EPREFIX}"/usr/lib/${lib} \ - "${ED}"/usr/lib/${lib} - eend $? - done - for f in "${ED}"/usr/bin/* "${ED}"/usr/lib/lib*.dylib "${ED}"/usr/lib/clang/${libpv}/lib/darwin/*.dylib ; do - # omit clang libs if not enabled - [[ -f "${f}" ]] || continue - - scanmacho -BF'%n#f' "${f}" | tr ',' '\n' | \ - while read odylib ; do - ndylib= - case ${odylib} in - */libclang.dylib) - ndylib="${EPREFIX}"/usr/lib/libclang.dylib - ;; - */libLLVM-${libpv}.dylib) - ndylib="${EPREFIX}"/usr/lib/libLLVM-${libpv}.dylib - ;; - */libLLVM-${libpvminor}.dylib) - ndylib="${EPREFIX}"/usr/lib/libLLVM-${libpvminor}.dylib - ;; - */libLTO.dylib) - ndylib="${EPREFIX}"/usr/lib/libLTO.dylib - ;; - esac - if [[ -n ${ndylib} ]] ; then - ebegin "fixing install_name reference to ${odylib} of ${f##*/}" - install_name_tool \ - -change "${odylib}" "${ndylib}" \ - "${f}" - eend $? - fi - done - done - fi } multilib_src_install_all() { |