# Contributor: Travis Tilley # Maintainer: William Pitcock pkgname=llvm pkgver=3.6.0 pkgrel=2 pkgdesc="low level virtual machine compiler system" arch="x86 x86_64 armhf" url="http://llvm.org/" license="UOI-NCSA" depends="" depends_dev="perl" makedepends="$depends_dev cmake make flex bison groff musl-dev binutils-gold binutils-dev libffi-dev libxml2-dev libxml2-utils zlib-dev ncurses-dev python python-dev py-sphinx chrpath" install= subpackages="clang clang-doc:clang_doc $pkgname-dev $pkgname-doc $pkgname-libs" source="http://llvm.org/releases/$pkgver/llvm-$pkgver.src.tar.xz http://llvm.org/releases/$pkgver/cfe-$pkgver.src.tar.xz http://llvm.org/releases/$pkgver/clang-tools-extra-$pkgver.src.tar.xz http://llvm.org/releases/$pkgver/compiler-rt-$pkgver.src.tar.xz llvm-0001-fix-shared-build.patch llvm-0002-musl-triple.patch llvm-0003-musl-hacks.patch compiler-rt-0001-musl-no-dlvsym.patch compiler-rt-0002-musl-no-sanitizers.patch clang-0001-fix-stdint.h.patch clang-0002-fix-unwind-header.patch clang-0003-add-alpine-linux-distro.patch clang-0004-alpine-use-z-relro.patch clang-0005-alpine-hash-style-gnu.patch clang-0006-musl-alpine-triple.patch clang-0007-musl-dynamic-linker-paths.patch clang-0008-alpine-PIE-by-default.patch clang-0009-pass-host-triple-to-compiler-rt.patch " _builddir="$srcdir"/build _bootstrap_prefix="$srcdir"/bootstrap _srcdir="$srcdir"/"$pkgname-$pkgver.src" _srcdir_clang="$_srcdir"/tools/clang _srcdir_clang_extra="$_srcdir_clang"/tools/extra # _srcdir_polly="$_srcdir"/tools/polly _srcdir_compiler_rt="$_srcdir"/projects/compiler-rt # _srcdir_libcxx="$_srcdir"/projects/libcxx # get_libstdcxx_header_directories() { # echo | \ # g++ -Wp,-v -x c++ - -fsyntax-only 2>&1 | \ # grep '^ /' | \ # head -2 | \ # sed 's|^ *||g' | \ # tr '\n' ';' # } # dynamically link to libstdc++ rather than statically link to libsupc++ even # though that's all we need. If a program also needs to link against libstdc++, # it will provide its own copy of libsupc++ and this can lead to subtle problems. # NOTE: the define has changed name in the 3.7 tree to always be # LIBCXX_ABI_INCLUDE_PATHS, even when using libsupc++. # _cmake_libcxx_abi_flags="\ # -DLIBCXX_CXX_ABI=libstdc++ \ # -DLIBCXX_LIBSUPCXX_INCLUDE_PATHS=$(get_libstdcxx_header_directories) \ # " # _cmake_libcxx_flags="\ # ${_cmake_libcxx_abi_flags} \ # -DLIBCXX_HOST_TRIPLE=$CHOST \ # -DLIBCXX_TARGET_TRIPLE=$CBUILD \ # -DLIBCXX_ENABLE_ASSERTIONS=NO \ # " _cmake_flags="\ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_VERBOSE_MAKEFILE=NO \ " # the binutils include directory setting appears to be necessary in order to # build the LLVMGold plugin, even if the headers are in /usr/include and easily # detected. # auto-detection of both go and ocaml are explicitly disabled here, as they # currently do not compile. _cmake_common_flags="\ ${_cmake_flags} \ -DCOMPILER_RT_TEST_TARGET_TRIPLE=$CBUILD \ -DLLVM_DEFAULT_TARGET_TRIPLE=$CBUILD \ -DLLVM_HOST_TRIPLE=$CHOST \ -DFFI_INCLUDE_DIR=$(pkg-config --cflags-only-I libffi | sed 's|^-I||g') \ -DLIBXML2_INCLUDE_DIR=$(pkg-config --cflags-only-I libxml-2.0 | sed 's|^-I||g') \ -DLLVM_BINUTILS_INCDIR=/usr/include \ -DLLVM_ENABLE_ASSERTIONS=NO \ -DLLVM_ENABLE_FFI=YES \ -DLLVM_ENABLE_LIBCXX=NO \ -DLLVM_ENABLE_PIC=YES \ -DLLVM_ENABLE_ZLIB=YES \ -DLLVM_ENABLE_RTTI=YES \ -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND \ -DOCAMLFIND=OCAMLFIND-NOTFOUND \ -DCLANG_BUILD_EXAMPLES=NO \ -DLLVM_BUILD_EXAMPLES=NO \ -DLLVM_INCLUDE_EXAMPLES=NO \ " # attempt to build the bootstrap compiler as quickly as is sane. unfortunately, # there is no way to turn off ObjC support. we can, however, disable building # ARCMT (automatic reference counting migration tool), the static analyzer, and # documentation. also, since we're using the cmake build and not autotools, the # tests aren't automatically built (targets for testing are emitted, just not # built as part of the default target). _cmake_bootstrap_flags="\ ${_cmake_common_flags} \ -DCMAKE_INSTALL_PREFIX=${_bootstrap_prefix} \ -DLLVM_TARGETS_TO_BUILD=host \ -DBUILD_SHARED_LIBS=NO \ -DCLANG_ENABLE_ARCMT=NO \ -DCLANG_ENABLE_STATIC_ANALYZER=NO \ -DCLANG_INCLUDE_DOCS=NO \ -DLLVM_ENABLE_CXX1Y=NO \ -DLLVM_ENABLE_SPHINX=NO \ -DLLVM_ENABLE_TERMINFO=NO \ -DLLVM_INCLUDE_DOCS=NO \ -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_BUILD=NO \ " # setting compiler-rt to compile as if it were an external build allows it to # use the freshly built clang to compile, rather than the bootstrap compiler. # NOTE: there appears to be an issue building compiler-rt as an external project # and using ninja as the build tool, so stick to good old fashioned makefiles. _cmake_final_flags="\ ${_cmake_common_flags} \ -DCMAKE_INSTALL_PREFIX=/usr \ -DLLVM_TARGETS_TO_BUILD=all \ -DLLVM_BUILD_EXTERNAL_COMPILER_RT=YES \ -DBUILD_SHARED_LIBS=YES \ -DLLVM_BUILD_DOCS=YES \ -DLLVM_ENABLE_CXX1Y=YES \ -DLLVM_ENABLE_SPHINX=YES \ -DLLVM_ENABLE_TERMINFO=YES \ -DLIBCLANG_BUILD_STATIC=YES \ " prepare() { msg "Preparing LLVM project sources..." mv "$srcdir"/cfe-$pkgver.src \ "$_srcdir_clang" || return 1 mv "$srcdir"/clang-tools-extra-$pkgver.src \ "$_srcdir_clang_extra" || return 1 # TODO: polly requires isl 0.14.x # mv "$srcdir"/polly-$pkgver.src \ # "$_srcdir_polly" || return 1 mv "$srcdir"/compiler-rt-$pkgver.src \ "$_srcdir_compiler_rt" || return 1 # mv "$srcdir"/libcxx-$pkgver.src \ # "$_srcdir_libcxx" || return 1 msg "Patching LLVM core..." cd "$_srcdir" || return 1 update_config_sub || return 1 sed -i -e '/case "\${UNAME_MACHINE}:\${UNAME_SYSTEM}:\${UNAME_RELEASE}:\${UNAME_VERSION}" in/i \' \ -e 'if [ x != "x$CBUILD" ]; then echo "$CBUILD"; exit; fi' \ ./autoconf/config.guess || return 1 for i in $source; do case $i in llvm-*.patch) msg "Applying $i..." patch -s -p1 -N -i "$srcdir"/$i || return 1 ;; esac done msg "Patching clang..." cd "$_srcdir_clang" || return 1 # FIXME: I have never seen these tests pass on any system, be it vanilla clang # or patched, musl or glibc, autoconf or cmake. It fails on alpine, gentoo, # and ubuntu. rm ./test/Driver/lto.c for i in $source; do case $i in clang-*.patch) msg "Applying $i..." patch -s -p1 -N -i "$srcdir"/$i || return 1 ;; esac done msg "Patching compiler-rt..." cd "$_srcdir_compiler_rt" || return 1 for i in $source; do case $i in compiler-rt-*.patch) msg "Applying $i..." patch -s -p1 -N -i "$srcdir"/$i || return 1 ;; esac done # msg "Patching libc++..." # cd "$_srcdir_libcxx" || return 1 # for i in $source; do # case $i in # libcxx-*.patch) # msg "Applying $i..." # patch -s -p1 -N -i "$srcdir"/$i || return 1 # ;; # esac # done } build() { # These flag settings are added to the existing cmake build flags rather # than replacing them, so we clear them out here to remove any abuild set # flags. For a Release build, the default flags will be "-O3 -NDEBUG". # -fno-devirtualize is added here because, to quote the fedora spec file, # "gcc has scary template-related bugs". the flag is removed post-bootstrap. CFLAGS="" CXXFLAGS="-fno-devirtualize" LDFLAGS="" : ${CC:=$(which gcc)} : ${CXX:=$(which g++)} # The cmake logic appears to use the result of config.guess in a few places # even though we override the various triple settings manually. export CBUILD # to the tweaked config.guess just to be safe. export CBUILD mkdir -p "$_builddir" cd "$_builddir" msg "Compiling bootstrap compiler" cmake -G "Unix Makefiles" -Wno-dev ${_cmake_bootstrap_flags} \ -DCMAKE_C_COMPILER="${CC}" \ -DCMAKE_CXX_COMPILER="${CXX}" \ -DCMAKE_C_FLAGS="${CFLAGS}" \ -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \ "${_srcdir}" || return 1 make || return 1 make install || return 1 CFLAGS="" CXXFLAGS="" CC="${_bootstrap_prefix}/bin/clang" CXX="${_bootstrap_prefix}/bin/clang++" cd .. rm -rf "$_builddir" mkdir -p "$_builddir" cd "$_builddir" msg "Compiling final compiler" cmake -G "Unix Makefiles" -Wno-dev ${_cmake_final_flags} \ -DCMAKE_C_COMPILER="${CC}" \ -DCMAKE_CXX_COMPILER="${CXX}" \ -DCMAKE_C_FLAGS="${CFLAGS}" \ -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \ "${_srcdir}" || return 1 make || return 1 make check-llvm || return 1 make check-clang || return 1 # 27 failures, all related to clang-tidy # make check-clang-tools || return 1 make check-compiler-rt || return 1 # 172 test failures, so it's not included # make check-libcxx || return 1 } package() { cd "$_builddir" make DESTDIR="$pkgdir" install rm "$pkgdir"/usr/lib/LLVMHello.so file "$pkgdir"/usr/lib/*.so | awk -F: '$2~/ELF/{print $1}' | xargs -r chrpath -d file "$pkgdir"/usr/bin/* | awk -F: '$2~/ELF/{print $1}' | xargs -r chrpath -d } clang() { pkgdesc="A C language family front-end for LLVM" mkdir -p "$subpkgdir"/usr/bin \ "$subpkgdir"/usr/lib "$subpkgdir"/usr/share/clang "$subpkgdir"/usr/include mv "$pkgdir"/usr/bin/*clang* \ "$subpkgdir"/usr/bin/ || return 1 mv "$pkgdir"/usr/lib/clang \ "$pkgdir"/usr/lib/libclang* \ "$pkgdir"/usr/lib/libmodernize* \ "$subpkgdir"/usr/lib/ || return 1 mv "$pkgdir"/usr/include/clang "$pkgdir"/usr/include/clang-c \ "$subpkgdir"/usr/include/ || return 1 cp -r "$_srcdir"/tools/clang/tools/scan-build "$subpkgdir"/usr/share/clang/scan-build cp -r "$_srcdir"/tools/clang/tools/scan-view "$subpkgdir"/usr/share/clang/scan-view ln -s /usr/share/clang/scan-build/scan-build "$subpkgdir"/usr/bin/scan-build ln -s /usr/share/clang/scan-view/scan-view "$subpkgdir"/usr/bin/scan-view } clang_doc() { pkgdesc="clang documentation" mkdir -p "$subpkgdir"/usr/share/doc/ || return 1 mv "$pkgdir"/usr/share/doc/clang "$subpkgdir"/usr/share/doc/ || return 1 } libs() { pkgdesc="LLVM shared libraries" mkdir -p "$subpkgdir"/usr/lib/ mv "$pkgdir"/usr/lib/*.so "$subpkgdir"/usr/lib/ } md5sums="f1e14e949f8df3047c59816c55278cec llvm-3.6.0.src.tar.xz e3012065543dc6ab8a9842b09616b78d cfe-3.6.0.src.tar.xz 85a170713a0b15a728b0cfd7b63c546c clang-tools-extra-3.6.0.src.tar.xz cc36dbcafe43406083e98bc9e74f8054 compiler-rt-3.6.0.src.tar.xz dd8e9953b54b2f783cdf111e31adf9ce llvm-0001-fix-shared-build.patch 1a9472a91fa50f3a844ad21d33242aa2 llvm-0002-musl-triple.patch 3254a34a4c87ed5e6d4730972f7807ed llvm-0003-musl-hacks.patch 5c0fbb582bbd9c6e6999830c720ea5be compiler-rt-0001-musl-no-dlvsym.patch 3ae77dfa18a7ac0a787e34f599d5c71d compiler-rt-0002-musl-no-sanitizers.patch 4f964e4a6ed8de0a9ee55f94fb8d1a64 clang-0001-fix-stdint.h.patch ee28027eff24641b13ae19a04746fd6a clang-0002-fix-unwind-header.patch e61b007324f9ab08b13ae0a249400ee1 clang-0003-add-alpine-linux-distro.patch fe5108b7c78d4493200f84d9f39f70ac clang-0004-alpine-use-z-relro.patch 2b39912685835682633c4d11aa39f400 clang-0005-alpine-hash-style-gnu.patch eafaf62d4938aa34d1902c46288f5f35 clang-0006-musl-alpine-triple.patch 0f206f7c8a29263d19bda41b48ec4ae8 clang-0007-musl-dynamic-linker-paths.patch f3537e99223c975bbc4abef21f7ced7f clang-0008-alpine-PIE-by-default.patch 0ae0c5939c27750c52b39158fbc7a7a9 clang-0009-pass-host-triple-to-compiler-rt.patch" sha256sums="b39a69e501b49e8f73ff75c9ad72313681ee58d6f430bfad4d81846fe92eb9ce llvm-3.6.0.src.tar.xz be0e69378119fe26f0f2f74cffe82b7c26da840c9733fe522ed3c1b66b11082d cfe-3.6.0.src.tar.xz 3aa949ba82913490a75697287d9ee8598c619fae0aa6bb8fddf0095ff51bc812 clang-tools-extra-3.6.0.src.tar.xz 7f49fb79e5adcdce7dddaf973f1db130228dfb19e37a99a7f5365a6948b26b11 compiler-rt-3.6.0.src.tar.xz d6d425bfc40908158fdee6160dd43f3804c320efec8637207196deccae7bae63 llvm-0001-fix-shared-build.patch 67fed034e986b60e71d1fb546ca36529972c03e0b370f8e01b34f183ce6920e5 llvm-0002-musl-triple.patch 0b49b6914999140ee6f8084b7506d1933860d73332ea8e3d4e4096f4bb6f1510 llvm-0003-musl-hacks.patch 82c38857bcbfd96e857299d0db7070b5f09d2edb3a32fb9d2e26a51a27e5f86a compiler-rt-0001-musl-no-dlvsym.patch 124d9f48a0127747073c2ed36aadfd0cc747f580978f9c0ce329632190afc200 compiler-rt-0002-musl-no-sanitizers.patch 4212f7a2de9544545aa88b0061f32e01962813e8271650e6f452de7eee5a4895 clang-0001-fix-stdint.h.patch 443305f3ac60502a210339d1bf28e1f2b79cb4dd1274ba4458da354b7a2f529a clang-0002-fix-unwind-header.patch a958600c5fc8a67fb59266e0f7759b7ec959042358470f802f9b3385fb0cac9b clang-0003-add-alpine-linux-distro.patch d08fb6de8aae75439b38a945773ddfe77e0f0d0f01ef03c3d087a8dbdfa01a7f clang-0004-alpine-use-z-relro.patch 624a99a4f8354e9179b8d7705c0f0db9368f074023ccf3a2186235c49050b6be clang-0005-alpine-hash-style-gnu.patch 88f60113909a57c3ae428e219d8e81d0355aa102c34d853db3b19627d8724608 clang-0006-musl-alpine-triple.patch 069e5974573d1f6efc784cf4e3027f2197c50319a5787cffff825f3253c525dd clang-0007-musl-dynamic-linker-paths.patch 2512ede893e2af8d7b3df4f490427b77af726b06336e84a74169d427f69ff438 clang-0008-alpine-PIE-by-default.patch ec0c2014d455040499f599dc3d690fb92e54baf6058605be5f25c2c845629cfe clang-0009-pass-host-triple-to-compiler-rt.patch" sha512sums="ca492b7d86333f05930dc849c7a8beff981da51ca174cd844650b516d0a592a2c3837d5a8a9b62713c0f29292b845f27ef0ec361809e325c6b60cbbcd3f20357 llvm-3.6.0.src.tar.xz dc137bdf9c2c5adb25498c995f0b944016699267156a595cc1fe6127f6961d45162275023d194db42691d80fa8fc74f56abad9c145ef1ff492881f547ca76cfe cfe-3.6.0.src.tar.xz 52e0cd3cce3047bb98d52e5c03ac4a8c549fcdc628f57492727f3e7659b2d4bd29ad98ab4ebab387233911fbb098861ec020b28c051e6b2c17d73dd490beebf3 clang-tools-extra-3.6.0.src.tar.xz 2758bc2b78dcfb9b6509b83ebc4ebc86907ca3dc2a5f151f580771c674b934432cae055e342ed73096a08331b2f7b129ff65629b27932458b1877aeb554b6328 compiler-rt-3.6.0.src.tar.xz 4878becb5e28fa1f29f0e46b643a8df688f53a48b0c6988d3f581fabca3a5812af12d197e0a9b38e324b83c53026304070fa09fb9dc7c1b5532ab8488fcc7356 llvm-0001-fix-shared-build.patch e543093f1385e8fcd94780a2f7887a51a13b6eaf0ef8c07be827851cac918376f45936f9bed341e30bd83a3557e67165f31977b3d7350932e8c94b7fc6356bf6 llvm-0002-musl-triple.patch d73b6fc0525e4800e9629411d727b7457f1298cd798022aa1b1c7699f21c7c461cd5473f19ef0c2ab8dba15d81b2950e890bce10bcb9c2dcdb7bae4e8d9db4ca llvm-0003-musl-hacks.patch 0e99e707794d260b193cd601914a47f1d138c21e1de6fdb67a6ebfa7035fda190fc41041e03ccca564bbecc739b8efaf1ae6000e8b35b0de528b28820b28bf2c compiler-rt-0001-musl-no-dlvsym.patch b3475eb64891eddd5a135c89d5d9eb479497e2dd04d114ffe7518a4a4117d5f011985a13c77d83b07bd6c6e5fe625d21d791bb671d112014f2ef1b77fedd74ce compiler-rt-0002-musl-no-sanitizers.patch 266e1af8c495201e60e909de37a3c705670ad6b9d07dc29926c34e65fba19b0b60b39a0189c4fdb0222e7c061a4378f56dfc7286dcd5d6f9a67a823c13f1d840 clang-0001-fix-stdint.h.patch d550193133ac8baf435c73865a90a6bf5b3c5e0e0dd308d4f413043d2ca3f63b4edb2cda9f282f4632e1e6e8974aba83febfffdf923fedd5d760c5ada26e9c73 clang-0002-fix-unwind-header.patch 3f31200835b4e9e7067191c9610a732b036318c17c38db6da380cbf7d7df8184507e819844fe92f01afc676d7dcf266bf28a6bbe26aa5fe208ef99885b42753c clang-0003-add-alpine-linux-distro.patch 46cb2d09fe25c98ab38db31a46b62570bbf0647847a30e8f568081121a727b70acf1a94b2d6b977d2ca6a68893370d7ffe59b80c7f492a8aba74592795437bbb clang-0004-alpine-use-z-relro.patch c9dea90fefdaccb01190ea0e170918252cb4c355b5ffc8ebe55c1154fa97247ab9d9e26157bbf4fbe02ebd5b06bb5257adeae1e7efdaf1327d8e672c85799dce clang-0005-alpine-hash-style-gnu.patch 77b12b357b316206df7a3187a72c50b625990df7fb56de7ab811dc500ed982086e1d02491b8661df92fd0da9849a50057d36ad34fa40f6addfd674e66d0edb8e clang-0006-musl-alpine-triple.patch 73699c0dd5a1960caf00d997aa95a88a178d9aa9dc86d05e404d6ad9ac8c54d450d58870aa54e0cd75f6e29ec3ee034118a1db735a9583665d34c62cdb2c0ae3 clang-0007-musl-dynamic-linker-paths.patch 2e3c6b519bb07915bf02ee2b12d4a5e28197c22d89f4ffe92f4cc485c2ba00d94faf91473a6219cb2af89e986ea7bf05a6dfa94f20f6c5919818b053bf40df38 clang-0008-alpine-PIE-by-default.patch 7628c1b12febb27d0a9ecb846205edec61044fbb963ba5e588863652bccbb05d1436febf8840ff4b47dfb326689bb142464be59a18b17bd5d30aa03bb7e76a9f clang-0009-pass-host-triple-to-compiler-rt.patch"