# Contributor: Rasmus Thomsen # Contributor: Jakub Jirutka # Contributor: Shiz # Contributor: Jeizsm # Maintainer: Rasmus Thomsen pkgname=rust pkgver=1.34.2 _llvmver=7 _bootver=1.33.0 pkgrel=0 pkgdesc="The Rust Programming Language" url="http://www.rust-lang.org" arch="x86_64" license="Apache-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-bootstrap>=$_bootver cargo-bootstrap cmake curl-dev file libffi-dev libgit2-dev openssl-dev libssh2-dev llvm$_llvmver-dev llvm$_llvmver-test-utils python2 tar zlib-dev " # XXX: This is a hack to allow this abuild to depend on itself. Adding "rust" # to makedepends would not work, because abuild implicitly removes $pkgname # and $subpackages from the abuild's dependencies. provides="rust-bootstrap=$pkgver-r$pkgrel" # This is needed for -src that contains some testing binaries. options="!archcheck" subpackages=" $pkgname-dbg $pkgname-stdlib $pkgname-analysis $pkgname-gdb::noarch $pkgname-lldb::noarch $pkgname-doc $pkgname-src::noarch cargo cargo-bash-completions:_cargo_bashcomp:noarch cargo-zsh-completion:_cargo_zshcomp:noarch cargo-doc:_cargo_doc:noarch " 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 install-template-shebang.patch bootstrap-tool-respect-tool-config.patch cargo-tests-ignore-resolving_minimum_version_with_transitive_deps.patch check-rustc cargo-skip-broken-tests.patch " builddir="$srcdir/rustc-$pkgver-src" _rlibdir="usr/lib/rustlib/$CTARGET/lib" _sharedir="usr/share/rust" ldpath="/$_rlibdir" export RUST_BACKTRACE=1 export RUSTC_CRT_STATIC="false" # Convince libgit2-sys to use the distro libgit2. export LIBGIT2_SYS_USE_PKG_CONFIG=1 prepare() { default_prepare # Remove bundled dependencies. rm -Rf src/llvm/ } build() { ./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" \ --disable-docs \ --enable-extended \ --tools="analysis,cargo,src" \ --enable-llvm-link-shared \ --enable-option-checking \ --enable-locked-deps \ --enable-vendor ./x.py build -v --jobs ${JOBS:-2} } check() { # At this moment lib/rustlib/$CTARGET/lib does not contain a complete # copy of the .so libs from lib (they will be copied there during # 'x.py install'). Thus we must set LD_LIBRARY_PATH for tests to work. # This is related to change-rpath-to-rustlib.patch. export LD_LIBRARY_PATH="$builddir/build/$CTARGET/stage2/lib" "$srcdir"/check-rustc "$builddir"/build/$CTARGET/stage2/bin/rustc # XXX: There's some problem with these tests, we will figure it out later. # make check \ # LD_LIBRARY_PATH="$_stage0dir/lib" \ # VERBOSE=1 msg "Running tests for cargo..." CFG_DISABLE_CROSS_TESTS=1 ./x.py test --no-fail-fast src/tools/cargo unset LD_LIBRARY_PATH } package() { DESTDIR="$pkgdir" ./x.py install -v 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/ } analysis() { pkgdesc="Compiler analysis data for the Rust standard library" depends="$pkgname-stdlib=$pkgver-r$pkgrel" _mv "$pkgdir"/$_rlibdir/../analysis "$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 py2-lldb" mkdir -p "$subpkgdir" cd "$subpkgdir" _mv "$pkgdir"/usr/bin/rust-lldb usr/bin/ _mv "$pkgdir"/$_sharedir/etc/lldb_*.py $_sharedir/etc/ } src() { pkgdesc="$pkgdesc (source code)" depends="$pkgname" license="$license OFL-1.1 GPL-3.0-or-later GPL-3.0-with-GCC-exception CC-BY-SA-3.0 LGPL-3.0" _mv "$pkgdir"/usr/lib/rustlib/src/rust "$subpkgdir"/usr/src/ rmdir -p "$pkgdir"/usr/lib/rustlib/src 2>/dev/null || true mkdir -p "$subpkgdir"/usr/lib/rustlib/src ln -s ../../../src/rust "$subpkgdir"/usr/lib/rustlib/src/rust } cargo() { pkgdesc="The Rust package manager" license="Apache-2.0 MIT UNLICENSE" depends="$pkgname" # XXX: See comment on top-level provides=. provides="cargo-bootstrap=$pkgver-r$pkgrel" _mv "$pkgdir"/usr/bin/cargo "$subpkgdir"/usr/bin/ } _cargo_bashcomp() { pkgdesc="Bash completions for cargo" license="Apache-2.0 MIT" depends="" install_if="cargo=$pkgver-r$pkgrel bash-completion" cd "$pkgdir" _mv etc/bash_completion.d/cargo \ "$subpkgdir"/usr/share/bash-completion/completions/ rmdir -p etc/bash_completion.d 2>/dev/null || true } _cargo_zshcomp() { pkgdesc="ZSH completions for cargo" license="Apache-2.0 MIT" depends="" install_if="cargo=$pkgver-r$pkgrel zsh" cd "$pkgdir" _mv usr/share/zsh/site-functions/_cargo \ "$subpkgdir"/usr/share/zsh/site-functions/_cargo rmdir -p usr/share/zsh/site-functions 2>/dev/null || true } _cargo_doc() { pkgdesc="The Rust package manager (documentation)" license="Apache-2.0 MIT" install_if="docs cargo=$pkgver-r$pkgrel" # XXX: This is hackish! cd "$pkgdir"/../$pkgname-doc _mv usr/share/man/man1/cargo* "$subpkgdir"/usr/share/man/man1/ } _mv() { local dest; for dest; do true; done # get last argument mkdir -p "$dest" mv "$@" } sha512sums="a9483c937915c482c9bebb1c60769a43978456ee222f3ff1379790cebc18dc4140b8b4d0a077dd1a5051f3c07113388597731e01f82c2f2b5b709e21cde3ecb3 rustc-1.34.2-src.tar.gz 6713d0d0ccac6b17ed47e486c6d74d1f913887bf88d42527576188fa98063a33a1ea903967847d52126b996f965577f1311344d6e57063b1625221847290a0ed musl-fix-static-linking.patch a2871fa75fb63570031eda80390461a137fe31ba82bf253caeabf3fb6673b4c80b535917dde139a300fb6d5f8c14fe09c8f7aaf4a506ef5e837540cf00aaa977 musl-fix-linux_musl_base.patch e40d41a6dc5d400d6672f1836cd5b9e00391f7beb52e872d87db76bc95a606ce6aaae737a0256a1e5fba77c83bb223818d214dbe87028d47be65fb43c101595c llvm-with-ffi.patch 5490ba8d78e55ce24c1a4f152604a38066079f9fec0bb41184c5ef279092b45ecc67cba00995c9a3f594b5eacee88a330c6836d755b5c895b87a64579d33febe static-pie.patch b7931281bfc1deb25c72494b4111500fe46c2e551ca32cafdfcc9a1bff657ca0b2bfaeea52260b4604678403fc76a708c2416bfc9e5bdac04475c4a70602295b need-rpath.patch 9b5ac7dc9acc644a7415e0510a97910b3b7191e858b03d891532631d3f64427792b5b482fe6c748627209993349e9246551b7ebbd462565ac7460fd1652ee38f minimize-rpath.patch 35e0619672843d9dd41df4a086404a59b57c12fa014e42d06102bc3856a96ed021e716f9d581ec5c89444acbaedd3edcd2b8a85576df3bb4451c0edde3afbba5 alpine-move-py-scripts-to-share.patch 4f5746acb08c18f749691a8455cc81ea2e9a361621790b006b884c9c895ab9e51a001b6638bed071a9af5c232ed8d1b43c58260839a3f6dce4eec3f495ce4348 alpine-change-rpath-to-rustlib.patch 616e3d036e310d61f5a212aa25f46b8fa5c31ad637ba774123334d685684f2c87b25b40cdb33dc08e660a9a7593fee29aa55d0f166e6a9173236cb3a6af408aa alpine-target.patch 7d59258d4462eba0207739a5c0c8baf1f19d9a396e5547bb4d59d700eb94d50ba6add2e523f3e94e29e993821018594625ea4ac86304fb58f7f8c82622a26ab0 install-template-shebang.patch c2ccab15d48c11cc3af549a3944ca0d29cb3790345468f4f3779e5ac931554dea603e5523281fc391ba4a555ee468b516961c4cb8ecee007eadacf114f3d8758 bootstrap-tool-respect-tool-config.patch 3d6f027088e1ec189ce864bf5ed150ccad8be5d9fc0973f1b4d202eec6eab865834403335a9f0765bbfa54638aed7f5d5f2183ba9dfeab9f5bc4ef48111a8427 cargo-tests-ignore-resolving_minimum_version_with_transitive_deps.patch c31fdfe8a9b3411576c75da46645cf0465b9053000a2ab49cf9b2f2733f679d6d33acbf236d67a20e14935d094a685453b7f1840180249f39d610fd0902c3125 check-rustc afca9b5524e270b6ddad4b2c99bba9a5f156a2411b04a9ca5802b185b50420de70555bb2526dcb4d5b12b29ff30afa2fe461d1de83b5345dd8e4ccf52e875c3f cargo-skip-broken-tests.patch"