summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-devel/clang')
-rw-r--r--sys-devel/clang/ChangeLog8
-rw-r--r--sys-devel/clang/clang-2.9.ebuild195
-rw-r--r--sys-devel/clang/files/clang-2.9-darwin-prefix.patch125
3 files changed, 327 insertions, 1 deletions
diff --git a/sys-devel/clang/ChangeLog b/sys-devel/clang/ChangeLog
index 466b36f64f87..89764e2f30fb 100644
--- a/sys-devel/clang/ChangeLog
+++ b/sys-devel/clang/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for sys-devel/clang
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/ChangeLog,v 1.35 2011/03/28 13:51:22 voyageur Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/ChangeLog,v 1.36 2011/04/07 09:32:03 voyageur Exp $
+
+*clang-2.9 (07 Apr 2011)
+
+ 07 Apr 2011; Bernard Cafarelli <voyageur@gentoo.org> +clang-2.9.ebuild,
+ +files/clang-2.9-darwin-prefix.patch:
+ Version bump, enable system-cxx-headers by default
28 Mar 2011; Bernard Cafarelli <voyageur@gentoo.org> -clang-2.7-r4.ebuild,
-files/clang-2.7-darwin-prefix.patch:
diff --git a/sys-devel/clang/clang-2.9.ebuild b/sys-devel/clang/clang-2.9.ebuild
new file mode 100644
index 000000000000..a3d5f72bbdd0
--- /dev/null
+++ b/sys-devel/clang/clang-2.9.ebuild
@@ -0,0 +1,195 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/clang-2.9.ebuild,v 1.1 2011/04/07 09:32:03 voyageur Exp $
+
+EAPI=3
+
+RESTRICT_PYTHON_ABIS="3.*"
+SUPPORT_PYTHON_ABIS="1"
+
+inherit eutils multilib python
+
+DESCRIPTION="C language family frontend for LLVM"
+HOMEPAGE="http://clang.llvm.org/"
+# Fetching LLVM as well: see http://llvm.org/bugs/show_bug.cgi?id=4840
+SRC_URI="http://llvm.org/releases/${PV}/llvm-${PV}.tgz
+ http://llvm.org/releases/${PV}/${P}.tgz"
+
+LICENSE="UoI-NCSA"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
+IUSE="alltargets debug +static-analyzer +system-cxx-headers test"
+
+# Note: for LTO support, clang will depend on binutils with gold plugins, and LLVM built after that - http://llvm.org/docs/GoldPlugin.html
+DEPEND="static-analyzer? ( dev-lang/perl )"
+RDEPEND="~sys-devel/llvm-${PV}[alltargets=]"
+
+S="${WORKDIR}/llvm-${PV}"
+
+src_prepare() {
+ mv "${WORKDIR}"/clang-${PV} "${S}"/tools/clang || die "clang source directory not found"
+
+ # Same as llvm doc patches
+ epatch "${FILESDIR}"/${PN}-2.7-fixdoc.patch
+
+ # Fix toolchain lookup for Darwin/Prefix.
+ epatch "${FILESDIR}"/${PN}-2.9-darwin-prefix.patch
+ sed -e "s|@GENTOO_PORTAGE_CHOST_ARCH@|${CHOST%%-darwin*}-darwin|g" \
+ -e "s|@GENTOO_PORTAGE_CHOST@|${CHOST}|g" \
+ -e "s|@GENTOO_PORTAGE_EPREFIX@|${EPREFIX}|g" \
+ -i tools/clang/lib/Driver/ToolChains.cpp \
+ || die "fixing toolchain lookup"
+
+ # multilib-strict
+ sed -e "/PROJ_headers/s#lib/clang#$(get_libdir)/clang#" \
+ -i tools/clang/lib/Headers/Makefile \
+ || die "clang Makefile failed"
+ # fix the static analyzer for in-tree install
+ sed -e 's/import ScanView/from clang \0/' \
+ -i tools/clang/tools/scan-view/scan-view \
+ || die "scan-view sed failed"
+ sed -e "/scanview.css\|sorttable.js/s#\$RealBin#${EPREFIX}/usr/share/${PN}#" \
+ -i tools/clang/tools/scan-build/scan-build \
+ || die "scan-build sed failed"
+ # Specify python version
+ python_convert_shebangs 2 tools/clang/tools/scan-view/scan-view
+
+ # From llvm src_prepare
+ einfo "Fixing install dirs"
+ sed -e 's,^PROJ_docsdir.*,PROJ_docsdir := $(PROJ_prefix)/share/doc/'${PF}, \
+ -e 's,^PROJ_etcdir.*,PROJ_etcdir := '"${EPREFIX}"'/etc/llvm,' \
+ -e 's,^PROJ_libdir.*,PROJ_libdir := $(PROJ_prefix)/'$(get_libdir)/llvm, \
+ -i Makefile.config.in || die "Makefile.config sed failed"
+
+ einfo "Fixing rpath"
+ sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \
+ -i Makefile.rules || die "rpath sed failed"
+}
+
+src_configure() {
+ local CONF_FLAGS="--enable-shared"
+
+ if use debug; then
+ CONF_FLAGS="${CONF_FLAGS} --disable-optimized"
+ einfo "Note: Compiling LLVM in debug mode will create huge and slow binaries"
+ # ...and you probably shouldn't use tmpfs, unless it can hold 900MB
+ else
+ CONF_FLAGS="${CONF_FLAGS} \
+ --enable-optimized \
+ --disable-assertions \
+ --disable-expensive-checks"
+ fi
+
+ # Setup the search path to include the Prefix includes
+ if use prefix ; then
+ CONF_FLAGS="${CONF_FLAGS} \
+ --with-c-include-dirs=${EPREFIX}/usr/include:/usr/include"
+ fi
+
+ if use alltargets; then
+ CONF_FLAGS="${CONF_FLAGS} --enable-targets=all"
+ else
+ CONF_FLAGS="${CONF_FLAGS} --enable-targets=host-only"
+ fi
+
+ if use amd64; then
+ CONF_FLAGS="${CONF_FLAGS} --enable-pic"
+ fi
+
+ # Skip llvm-gcc parts even if installed
+ CONF_FLAGS="${CONF_FLAGS} --with-llvmgccdir=/dev/null"
+
+ if use system-cxx-headers; then
+ # Try to get current gcc headers path
+ local CXX_PATH=$(gcc-config -X| cut -d: -f1 | sed 's,/include/g++-v4$,,')
+ CONF_FLAGS="${CONF_FLAGS} --with-c-include-dirs=/usr/include:${CXX_PATH}/include"
+ CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-root=${CXX_PATH}/include/g++-v4"
+ CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-arch=$CHOST"
+ if has_multilib_profile; then
+ CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-32bit-dir=32"
+ fi
+ fi
+
+ econf ${CONF_FLAGS} || die "econf failed"
+}
+
+src_compile() {
+ emake VERBOSE=1 KEEP_SYMBOLS=1 REQUIRES_RTTI=1 clang-only || die "emake failed"
+}
+
+src_test() {
+ cd "${S}"/test || die "cd failed"
+ emake site.exp || die "updating llvm site.exp failed"
+
+ cd "${S}"/tools/clang || die "cd clang failed"
+
+ echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
+ if ! emake -j1 VERBOSE=1 test; then
+ hasq test $FEATURES && die "Make test failed. See above for details."
+ hasq test $FEATURES || eerror "Make test failed. See above for details."
+ fi
+}
+
+src_install() {
+ cd "${S}"/tools/clang || die "cd clang failed"
+ emake KEEP_SYMBOLS=1 DESTDIR="${D}" install || die "install failed"
+
+ if use static-analyzer ; then
+ dobin tools/scan-build/ccc-analyzer
+ dosym ccc-analyzer /usr/bin/c++-analyzer
+ dobin tools/scan-build/scan-build
+
+ insinto /usr/share/${PN}
+ doins tools/scan-build/scanview.css
+ doins tools/scan-build/sorttable.js
+
+ cd tools/scan-view || die "cd scan-view failed"
+ dobin scan-view
+ install-scan-view() {
+ insinto "$(python_get_sitedir)"/clang
+ doins Reporter.py Resources ScanView.py startfile.py
+ touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py
+ }
+ python_execute_function install-scan-view
+ fi
+
+ # Fix install_names on Darwin. The build system is too complicated
+ # to just fix this, so we correct it post-install
+ if [[ ${CHOST} == *-darwin* ]] ; then
+ for lib in libclang.dylib ; do
+ ebegin "fixing install_name of $lib"
+ install_name_tool -id "${EPREFIX}"/usr/lib/llvm/${lib} \
+ "${ED}"/usr/lib/llvm/${lib}
+ eend $?
+ done
+ for f in usr/bin/{c-index-test,clang} usr/lib/llvm/libclang.dylib ; do
+ ebegin "fixing references in ${f##*/}"
+ install_name_tool \
+ -change "@rpath/libclang.dylib" \
+ "${EPREFIX}"/usr/lib/llvm/libclang.dylib \
+ -change "${S}"/Release/lib/libLLVM-${PV}.dylib \
+ "${EPREFIX}"/usr/lib/llvm/libLLVM-${PV}.dylib \
+ -change "${S}"/Release/lib/libclang.dylib \
+ "${EPREFIX}"/usr/lib/llvm/libclang.dylib \
+ "${ED}"/$f
+ eend $?
+ done
+ fi
+}
+
+pkg_postinst() {
+ python_mod_optimize clang
+ if use system-cxx-headers; then
+ elog "C++ headers search path is hardcoded to the active gcc profile one"
+ elog "If you change the active gcc profile, or update gcc to a new version,"
+ elog "you will have to remerge this package to update the search path"
+ else
+ elog "If clang++ fails to find C++ headers on your system,"
+ elog "you can remerge clang with USE=system-cxx-headers to use C++ headers"
+ elog "from the active gcc profile"
+ fi
+}
+
+pkg_postrm() {
+ python_mod_cleanup clang
+}
diff --git a/sys-devel/clang/files/clang-2.9-darwin-prefix.patch b/sys-devel/clang/files/clang-2.9-darwin-prefix.patch
new file mode 100644
index 000000000000..8f79e7f6f24e
--- /dev/null
+++ b/sys-devel/clang/files/clang-2.9-darwin-prefix.patch
@@ -0,0 +1,125 @@
+--- tools/clang/lib/Driver/ToolChains.cpp.orig 2011-03-21 22:29:27.000000000 +0100
++++ tools/clang/lib/Driver/ToolChains.cpp 2011-04-07 10:33:41.771314057 +0200
+@@ -139,7 +139,7 @@
+ GCCVersion[2] = 1;
+
+ // Set up the tool chain paths to match gcc.
+- ToolChainDir = "i686-apple-darwin";
++ ToolChainDir = "@GENTOO_PORTAGE_CHOST@";
+ ToolChainDir += llvm::utostr(DarwinVersion[0]);
+ ToolChainDir += "/";
+ ToolChainDir += llvm::utostr(GCCVersion[0]);
+@@ -149,10 +149,10 @@
+ ToolChainDir += llvm::utostr(GCCVersion[2]);
+
+ // Try the next major version if that tool chain dir is invalid.
+- std::string Tmp = "/usr/lib/gcc/" + ToolChainDir;
++ std::string Tmp = "@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/" + ToolChainDir;
+ bool Exists;
+ if (llvm::sys::fs::exists(Tmp, Exists) || Exists) {
+- std::string Next = "i686-apple-darwin";
++ std::string Next = "@GENTOO_PORTAGE_CHOST_ARCH@";
+ Next += llvm::utostr(DarwinVersion[0] + 1);
+ Next += "/";
+ Next += llvm::utostr(GCCVersion[0]);
+@@ -164,7 +164,7 @@
+ // Use that if it exists, otherwise hope the user isn't linking.
+ //
+ // FIXME: Drop dependency on gcc's tool chain.
+- Tmp = "/usr/lib/gcc/" + Next;
++ Tmp = "@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/" + Next;
+ if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
+ ToolChainDir = Next;
+ }
+@@ -177,7 +177,7 @@
+ Path += "/x86_64";
+ getFilePaths().push_back(Path);
+
+- Path = "/usr/lib/gcc/";
++ Path = "@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/";
+ Path += ToolChainDir;
+ Path += "/x86_64";
+ getFilePaths().push_back(Path);
+@@ -188,7 +188,7 @@
+ Path += ToolChainDir;
+ getFilePaths().push_back(Path);
+
+- Path = "/usr/lib/gcc/";
++ Path = "@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/";
+ Path += ToolChainDir;
+ getFilePaths().push_back(Path);
+
+@@ -197,7 +197,7 @@
+ Path += ToolChainDir;
+ getProgramPaths().push_back(Path);
+
+- Path = "/usr/libexec/gcc/";
++ Path = "@GENTOO_PORTAGE_EPREFIX@/usr/libexec/gcc/";
+ Path += ToolChainDir;
+ getProgramPaths().push_back(Path);
+
+@@ -300,14 +300,14 @@
+
+ // FIXME: Derive these correctly.
+ if (getArchName() == "x86_64") {
+- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
++ CmdArgs.push_back(Args.MakeArgString("-L@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/" + ToolChainDir +
+ "/x86_64"));
+ // Intentionally duplicated for (temporary) gcc bug compatibility.
+- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
++ CmdArgs.push_back(Args.MakeArgString("-L@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/" + ToolChainDir +
+ "/x86_64"));
+ }
+
+- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/" + ToolChainDir));
++ CmdArgs.push_back(Args.MakeArgString("-L@GENTOO_PORTAGE_EPREFIX@/usr/lib/" + ToolChainDir));
+
+ Tmp = getDriver().Dir + "/../lib/gcc/" + ToolChainDir;
+ bool Exists;
+@@ -316,18 +316,18 @@
+ Tmp = getDriver().Dir + "/../lib/gcc";
+ if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
+ CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
+- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir));
++ CmdArgs.push_back(Args.MakeArgString("-L@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/" + ToolChainDir));
+ // Intentionally duplicated for (temporary) gcc bug compatibility.
+- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir));
++ CmdArgs.push_back(Args.MakeArgString("-L@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/" + ToolChainDir));
+ Tmp = getDriver().Dir + "/../lib/" + ToolChainDir;
+ if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
+ CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
+ Tmp = getDriver().Dir + "/../lib";
+ if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
+ CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
+- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
++ CmdArgs.push_back(Args.MakeArgString("-L@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/" + ToolChainDir +
+ "/../../../" + ToolChainDir));
+- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
++ CmdArgs.push_back(Args.MakeArgString("-L@GENTOO_PORTAGE_EPREFIX@/usr/lib/gcc/" + ToolChainDir +
+ "/../../.."));
+ }
+
+@@ -416,22 +416,7 @@
+ P.eraseComponent(); // .../usr/bin -> ../usr
+ P.appendComponent("lib");
+ P.appendComponent("gcc");
+- switch (getTriple().getArch()) {
+- default:
+- assert(0 && "Invalid Darwin arch!");
+- case llvm::Triple::x86:
+- case llvm::Triple::x86_64:
+- P.appendComponent("i686-apple-darwin10");
+- break;
+- case llvm::Triple::arm:
+- case llvm::Triple::thumb:
+- P.appendComponent("arm-apple-darwin10");
+- break;
+- case llvm::Triple::ppc:
+- case llvm::Triple::ppc64:
+- P.appendComponent("powerpc-apple-darwin10");
+- break;
+- }
++ P.appendComponent("@GENTOO_PORTAGE_CHOST@");
+ P.appendComponent("4.2.1");
+
+ // Determine the arch specific GCC subdirectory.