# Contributor: Jakub Jirutka # Contributor: Shiz # Contributor: Jeizsm # Maintainer: Jakub Jirutka pkgname=rust pkgver=1.21.0 _llvmver=4 _bootver=1.20.0 pkgrel=1 pkgdesc="The Rust Programming Language (compiler)" url="http://www.rust-lang.org" arch="x86_64" license="ASL-2.0 BSD ISC MIT" # gcc is needed at runtime just for linking. Someday rustc might invoke # the linker directly, and then we'll only need binutils. # See: https://github.com/rust-lang/rust/issues/11937 depends="$pkgname-stdlib=$pkgver-r$pkgrel gcc llvm-libunwind-dev musl-dev" # * Rust is self-hosted, so you need rustc (and cargo) to build rustc... # The last revision of this abuild that does not depend on itself (uses # prebuilt rustc and cargo) is 8cb3112594f10a8cee5b5412c28a846acb63167f. # * libffi-dev is needed just because we compile llvm with LLVM_ENABLE_FFI. makedepends="rust>=$_bootver cargo cmake file libffi-dev llvm$_llvmver-dev llvm$_llvmver-test-utils python2 tar zlib-dev" subpackages="$pkgname-dbg $pkgname-stdlib $pkgname-gdb::noarch $pkgname-lldb::noarch $pkgname-doc" source="https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz musl-fix-static-linking.patch musl-fix-linux_musl_base.patch llvm-with-ffi.patch static-pie.patch need-rpath.patch minimize-rpath.patch alpine-move-py-scripts-to-share.patch alpine-change-rpath-to-rustlib.patch alpine-target.patch check-rustc " builddir="$srcdir/rustc-$pkgver-src" _rlibdir="usr/lib/rustlib/$CTARGET/lib" _sharedir="usr/share/rust" ldpath="/$_rlibdir" prepare() { default_prepare cd "$builddir" # Remove bundled dependencies. rm -Rf src/llvm/ # Make sure to use the system LLVM. printf '[target.%s]\nllvm-config = "/usr/lib/llvm%s/bin/llvm-config"\n' \ "$CTARGET" "$_llvmver" > config.toml } build() { cd "$builddir" # jemalloc is disabled, because it increases size of statically linked # binaries produced by rustc (stripped hello_world 186 kiB vs. 358 kiB) # for only tiny performance boost (even negative in some tests). ./configure \ --build="$CBUILD" \ --host="$CTARGET" \ --target="$CTARGET" \ --prefix="/usr" \ --release-channel="stable" \ --enable-local-rust \ --local-rust-root="/usr" \ --llvm-root="/usr/lib/llvm$_llvmver" \ --musl-root="/usr" \ --enable-vendor \ --enable-llvm-link-shared \ --disable-jemalloc \ --disable-docs RUST_BACKTRACE=1 \ RUSTC_CRT_STATIC="false" \ ./x.py build -v } check() { "$srcdir"/check-rustc "$builddir/build/$CTARGET/stage2/bin/rustc" # XXX: There's some problem with these tests, we will figure it out later. # cd "$builddir" # make check \ # LD_LIBRARY_PATH="$_stage0dir/lib" \ # RUST_BACKTRACE=1 \ # RUST_CRT_STATIC="false" \ # VERBOSE=1 } package() { cd "$builddir" RUST_BACKTRACE=1 \ RUSTC_CRT_STATIC="false" \ ./x.py dist -v local component; for component in rustc rust-std; do tar -xf "build/dist/$component-$pkgver-$CTARGET.tar.gz" ./"$component-$pkgver-$CTARGET"/install.sh --destdir="$pkgdir" --prefix=/usr --disable-ldconfig done cd "$pkgdir" # These libraries are identical to those under rustlib/. Since we have # linked rustc/rustdoc against those under rustlib/, we can remove # them. Read change-rpath-to-rustlib.patch for more info. rm -r usr/lib/*.so # These objects are for static linking with musl on non-musl systems. rm $_rlibdir/crt*.o # Shared objects should have executable flag. chmod +x $_rlibdir/*.so # Python scripts are noarch, so move them to /usr/share. # Requires move-py-scripts-to-share.patch to be applied. _mv usr/lib/rustlib/etc/*.py $_sharedir/etc/ rmdir -p usr/lib/rustlib/etc 2>/dev/null || true # Remove some clutter. cd usr/lib/rustlib rm components install.log manifest-* rust-installer-version uninstall.sh } stdlib() { pkgdesc="Standard library for Rust (static rlibs)" _mv "$pkgdir"/$_rlibdir/*.rlib "$subpkgdir"/$_rlibdir/ } gdb() { pkgdesc="GDB pretty printers for Rust" depends="$pkgname gdb" mkdir -p "$subpkgdir" cd "$subpkgdir" _mv "$pkgdir"/usr/bin/rust-gdb usr/bin/ _mv "$pkgdir"/$_sharedir/etc/gdb_*.py $_sharedir/etc/ } lldb() { pkgdesc="LLDB pretty printers for Rust" depends="$pkgname lldb py-lldb" mkdir -p "$subpkgdir" cd "$subpkgdir" _mv "$pkgdir"/usr/bin/rust-lldb usr/bin/ _mv "$pkgdir"/$_sharedir/etc/lldb_*.py $_sharedir/etc/ } _mv() { local dest; for dest; do true; done # get last argument mkdir -p "$dest" mv $@ } sha512sums="47f29a5c9c926c1b209516a8546c67a24c1c6ee15c6302c8c6d340047b3e1f713cc6d09e568b67ae4b47b08cbb0befd95fc0d7a72f2ce21a5224d4e5da03b4f5 rustc-1.21.0-src.tar.gz e4675fb78920a31c2c6b0ffdf812b127d3c585557eba904d3aeb690362b06697cbd3cf307bb4bebaec2bfaa1057c5e3738b33437f53db0eae9836ae18d36a880 musl-fix-static-linking.patch 360b0c1b6374cb356989b6f254da2dfc2ab2390c8251f0151492206b908ebf85c6ff57405394b3f46f1fc3e26f7c986bb9e924065f4c4dfa1d50fff2a99b5cd0 musl-fix-linux_musl_base.patch dc6432293bd060d5e3a73f25870867654fae61995dcd919e244a2dc686b6107556deed8c59ca6002182bfeff5ebc1ca2b89c4028ab0fbfb79e65defe47c9b4b0 llvm-with-ffi.patch 936ddccb357307b3f7f3c10aadcdc3dfbbe0ccb8cc5675969a87b7cf1a8e72f73ed5118c6cd6a1a36a377457ead998cc8c71f4176361acb4416ec16673b4c597 static-pie.patch b5c8a4faf3571b5c79b052103639ea3b14f094ec0999963602111608afa1159219f958decf0b45dd409124b318f5e17af47b4e74207a9f1c9648a9572dc68cca need-rpath.patch d352614e7c774e181decae210140e789de7fc090327ff371981ad28a11ce51c8c01b27c1101a24bb84d75ed2f706f67868f7dbc52196d4ccdf4ebd2d6d6b6b5e minimize-rpath.patch 498f4649163974afc4f042c43cd0c15d36784031514201a2962061f288a9336c2bc9749f8d2308b8ce3656f8097b5fc5bef505f61e2a6ed422ef4153f5339d77 alpine-move-py-scripts-to-share.patch 0542e8ffeb7ff6017aeec84d99c14802c6536433b41dafe7c8fc0c40908548228f34ef142ad6ad94235115b05f02ce157553b470b0f242292f90f3125b249e94 alpine-change-rpath-to-rustlib.patch b9d07a5dcc2485da72d02667891f7ccb015b1a4e648273d15532756ed98e7eeeff35f3af53d1aae1d953dc4364e42491fadb78e8bac1643851e25b81b490356d alpine-target.patch 79549055dea81379c890b495c82456ab497a9179ec6702c59e11d0748bc668f47fc3d6a69c27a0545bb87c01318631dffc69260bf2d4badc75f53cbf7fad7528 check-rustc"