# Contributor: Rasmus Thomsen # Contributor: Jakub Jirutka # Contributor: Shiz # Contributor: Jeizsm # Maintainer: Rasmus Thomsen pkgname=rust pkgver=1.40.0 _llvmver=9 _bootver=1.39.0 pkgrel=1 pkgdesc="The Rust Programming Language" url="https://www.rust-lang.org" arch="x86_64 armv7 armhf aarch64 x86 ppc64le" license="Apache-2.0 AND 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 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 2e6769eb39eaff3029d8298fc02856623c563cd8. makedepends=" cmake curl-dev file libgit2-dev openssl-dev llvm$_llvmver-dev llvm$_llvmver-test-utils python2 tar zlib-dev coreutils rust-bootstrap=>$_bootver cargo-bootstrap " # 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. # Disable tests for now, while we use foreign triplets options="!archcheck !check" 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 https://dist.cogitri.dev/rust/rust-$_bootver-x86_64.tar https://dist.cogitri.dev/rust/rust-$_bootver-x86.tar https://dist.cogitri.dev/rust/rust-$_bootver-armhf.tar https://dist.cogitri.dev/rust/rust-$_bootver-armv7.tar https://dist.cogitri.dev/rust/rust-$_bootver-aarch64.tar https://dist.cogitri.dev/rust/rust-$_bootver-ppc64le.tar musl-fix-static-linking.patch musl-fix-linux_musl_base.patch static-pie.patch need-rpath.patch minimize-rpath.patch alpine-move-py-scripts-to-share.patch alpine-target.patch install-template-shebang.patch check-rustc link-musl-dynamically.patch musl-dont-use-crt-static.patch 0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch" builddir="$srcdir/rustc-$pkgver-src" # secfixes: # 1.34.2-r0: # - CVE-2019-12083 # 1.26.0-r0: # - CVE-2019-16760 # We have to add new arches in multiple steps: # 1. Compile with the upstream triplets, compiling alpine's triplets in # 2. Compile again, now with our triplets selected as build/target, now that # rustc knows about them case "$CARCH" in x86) _build="i686-unknown-linux-musl" _target="$_build" ;; armv7) _build="armv7-unknown-linux-musleabihf" _target="$_build" ;; armhf) _build="arm-unknown-linux-musleabihf" _target="$_build" ;; ppc64le) _build="powerpc64le-unknown-linux-musl" _target="$_build" ;; aarch64) _build="aarch64-unknown-linux-musl" _target="$_build" ;; *) _build="$CBUILD" _target="$CTARGET" esac _rlibdir="usr/lib/rustlib/$_target/lib" _sharedir="usr/share/rust" ldpath="/$_rlibdir" # Find rustc in the tarball export PATH="$srcdir/rust-$CARCH/usr/bin:$PATH" export RUST_BACKTRACE=1 # Don't use system libgit2 for now... # https://github.com/rust-lang/rust/issues/63476 # Convince libgit2-sys to use the distro libgit2. #export LIBGIT2_SYS_USE_PKG_CONFIG=1 # rust checksums files in vendor/, but we have to patch a few files... _clear_vendor_checksums() { sed -i 's/\("files":{\)[^}]*/\1/' vendor/$1/.cargo-checksum.json } prepare() { default_prepare sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py # to dynamically link against musl _clear_vendor_checksums libc # Remove bundled dependencies. rm -Rf src/llvm-project/ } build() { # Fails to compile libbacktrace-sys otherwise case "$CARCH" in x86) export CFLAGS="$CFLAGS -fno-stack-protector" ;; esac ./configure \ --build="$_build" \ --host="$_target" \ --target="$_target" \ --prefix="/usr" \ --release-channel="stable" \ --enable-local-rust \ --local-rust-root="/usr" \ --llvm-root="/usr/lib/llvm$_llvmver" \ --disable-docs \ --enable-extended \ --tools="analysis,cargo,src" \ --enable-llvm-link-shared \ --enable-option-checking \ --enable-locked-deps \ --enable-vendor \ --set="target.$_build.musl-root=/usr" \ --set="target.$_build.crt-static=false" # Allow warnings instead of just aborting the build sed 's/#deny-warnings = .*/deny-warnings = false/' -i config.toml sed 's|deny(warnings,|deny(|' -i src/bootstrap/lib.rs ./x.py build --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" # 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="8afdb7fddbc5f2cec05fe962cd425ff8f3f41b056ffc983135d21d5c7d217084a1d73b4f9e4ff12faf7731ff1332d2889b71eed0a5216dd5eff5302d26b33d1e rustc-1.40.0-src.tar.gz 26de35c032183771374e9f7848d39e9b62d4475290637e3f47362648f4ef5297c0c7fa365cfc7516bfaac24802585b5a3d2be3959ab5cd7191db9808768a4892 rust-1.39.0-x86_64.tar 43530e8cc0f6112c26c13896236165a2ba8578a602dd55c4ea7239071169a649e53759cf995e414d7c5ccdf6d64290db2bbe07752544037f7bc96c2b65c2c470 rust-1.39.0-x86.tar 43c49bb4de1218e731239ed425cf98adcfb0797740f4937bfc216be4c1795603bf833ae2bf8401e491ca779b9e300fc0200e292d7734d199cf54bd2fe14c372e rust-1.39.0-armhf.tar 960201211406c9a7947d72a89a659b68f0119e0abb3b4a3ebaa5f295e05bdfa6b34fc978ff1b7f93f1e8c1d7040889b64fde04845262ec86f069b09c7842911b rust-1.39.0-armv7.tar 3997fb74a36fa22db0fa1ffe6907e3a67fa17627ffa8b0668540bdfe2b64441f0036e0ccca47828a689463309c9b1ecd229a851fabf97a7022cb855b2b70da1c rust-1.39.0-aarch64.tar eaaf7ed97d7945d40373eb55be6ee6d70e5442579fe8b956d968fc530a9fc466240843b5cfd29fb80396da810b88516aecc6c5c909fc04e1670a0b1318aafe9d rust-1.39.0-ppc64le.tar 8d52048070e9a158810f5ef71eae07a3b107b60986375a593c3509f4c47f8e2f7fcdff8bc558c03c46127dbf66c4077dd7b5b422a83f2c49fb5d52ecfae5697e musl-fix-static-linking.patch 41fd9e8a8dd99074d95d664e65f92dba644b8ef9fa37b9a1d781a01fe49eaa254c430f0f277622dc4f8203aad2d129a045fdf1679a0da526d549fac60654be26 musl-fix-linux_musl_base.patch 97e81c57af93df550577f41d795185a9eb0c37528776c250076cc57f06c87e81139eb71cd6b6a4730528511821ae50c304d7deb534d6422cd08bb44193ae605d static-pie.patch d4659b56dbf1218da98b995a0a89a8cfd069dd94b3e9aef4aee987484d96fc8b92f6d695ea4123eff26711961f2db2f7324bf5b4043f41722cd89581aac97f1c need-rpath.patch e90e544d2413ae79c553bb1d82eac9b41eb2a7c7ffb7cb28dc3573418bd453c27dcc48f38ce4b8e33bb994b5481db70303c707231b7d4f7fde561bebf0838f21 minimize-rpath.patch 35e0619672843d9dd41df4a086404a59b57c12fa014e42d06102bc3856a96ed021e716f9d581ec5c89444acbaedd3edcd2b8a85576df3bb4451c0edde3afbba5 alpine-move-py-scripts-to-share.patch 080c3c1af15936c3795724d3cf0f60798ef470bce898e43b6757843bf56f6d46de3dd5b9ea3b116b2011b40373cf8daf17abc94cfff4bdb6221bd431aa0844fd alpine-target.patch 7d59258d4462eba0207739a5c0c8baf1f19d9a396e5547bb4d59d700eb94d50ba6add2e523f3e94e29e993821018594625ea4ac86304fb58f7f8c82622a26ab0 install-template-shebang.patch c31fdfe8a9b3411576c75da46645cf0465b9053000a2ab49cf9b2f2733f679d6d33acbf236d67a20e14935d094a685453b7f1840180249f39d610fd0902c3125 check-rustc 2a91c0d149f19a2268b2db8e375e0c10820529f588161d8d8e68900d929235d9b1cb4f0d64539c1e20ecca3948b4715f2d9d3d16a2754373d56b4b5808bed6bd link-musl-dynamically.patch 795194976763326c5e4a9eefc8b651b6d5fb533d2d000631ed48a92bafac90e9ca33b8d662e6c53ef109ea1a90c69def715d7d7154e3f9fb9035a58a313a7db3 musl-dont-use-crt-static.patch f15c8e6a4c8ad33ee5874580ed76463e2a7359e9b4a8651eb974ea5354c3f992fd2ce1d04661ee8cff2105b25967428894ecdd144a6a45f09c7e1952b2f3731c 0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch"