# Template file for 'rust' # partially adapted from Alpine/Adélie's Rust APKBUILD # # Permission to use rust and cargo trademark is granted. # See: https://github.com/rust-lang/core-team/issues/4 # # Always make sure custom distfiles used for bootstrap are # uploaded to https://repo-default.voidlinux.org/distfiles/ # pkgname=rust version=1.93.0 revision=1 _change_id=148795 _llvmver=21 hostmakedepends="curl pkg-config python3 tar cargo-bootstrap $(vopt_if wasi "clang${_llvmver} llvm${_llvmver} wasi-libc")" makedepends="libffi-devel ncurses-devel libxml2-devel libzstd-devel zlib-devel llvm${_llvmver}-devel" depends="rust-std gcc" short_desc="Safe, concurrent, practical systems language" maintainer="Enno Boland " license="Apache-2.0 OR MIT" homepage="https://www.rust-lang.org/" distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz" checksum=69112bd83c321943ffc390b7db2f59ef3febb95dac700f67c2156fbf6b50a705 lib32disabled=yes make_check=no # CBA for now python_version=3 # needed for python files in rust-src build_helper="qemu" build_options="docs bindist wasm" build_options_default="docs" desc_option_bindist="Generate tarballs for bootstrap" desc_option_docs="build standard library documentation" desc_option_wasm="build wasm targets" vopt_conflict wasm docs # building with docs for wasm targets is currently broken subpackages="$(vopt_if docs rust-doc) rust-std $(vopt_if wasm rust-wasm) rust-src" if [ "$XBPS_LIBC" = "musl" ]; then hostmakedepends+=" libexecinfo-devel" fi if [ "$XBPS_TARGET_LIBC" = "musl" ]; then makedepends+=" libexecinfo-devel" fi if [ "$CROSS_BUILD" ]; then hostmakedepends+=" rust llvm${_llvmver}-devel" # These are required for building the buildhost's stage0/1 hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel" else hostmakedepends+=" rust-bootstrap" fi # we need this because cargo verifies checksums of all files in vendor # crates when it builds and gives us no way to override or update the # file sanely... so just clear out the file list _clear_vendor_checksums() { sed -i 's/\("files":{\)[^}]*/\1/' vendor/$1/.cargo-checksum.json } post_patch() { if [ "$build_option_bindist" ]; then for x in ${FILESDIR}/patches/static-llvm/*.patch; do msg_normal "Applying patch $x\n" patch -sNp1 -i ${x} done fi # xbps-src replaces config.sub files. _clear_vendor_checksums onig_sys-69.9.1 # ensure no leftover vendor config remains # rm -r .cargo } do_configure() { local _local_rebuild _debug _debug_rustc _rpath _docs _llvm_shared local _cross_args if [ "$CROSS_BUILD" ]; then _local_rebuild="enable" else _local_rebuild="disable" fi # disable rustc debug info as it bloats up rust-std significantly # set to 1 or 2 if you wish to have debug info for rustc, it won't # link on 32-bit platforms though (too big) _debug_rustc="0" # just disable debug for now _debug="0" # if true, the binaries will be built with rpath, so the binaries will be # usable directly from the build directory, this is not desirable for # packaging but is useful when building bootstrap binaries if [ "$build_option_bindist" ]; then _rpath="enable" _docs="disable" _llvm_shared="disable" else _rpath="disable" if [ "$build_option_docs" ]; then _docs="enable" else _docs="disable" fi _llvm_shared="enable" fi if [ "$CROSS_BUILD" ]; then _cross_args=" --set=target.${RUST_TARGET}.llvm-config=${XBPS_WRAPPERDIR}/llvm-config-qemu --set=target.${RUST_TARGET}.crt-static=false --set=target.${RUST_TARGET}.cc=${CC} --set=target.${RUST_TARGET}.cxx=${CXX} --set=target.${RUST_TARGET}.ar=${AR} --set=target.${RUST_TARGET}.linker=${CC}" fi if [ -z "$build_option_bindist" -a -n "$build_option_wasm" ]; then _extra_targets=",wasm32-unknown-unknown" _wasm_args=" --set=target.wasm32-unknown-unknown.sanitizers=false --set=target.wasm32-unknown-unknown.profiler=false --set=target.wasm32-unknown-unknown.linker=lld --set=target.wasm32-unknown-unknown.cc=clang --set=target.wasm32-unknown-unknown.cxx=clang++ --set=target.wasm32-unknown-unknown.ar=llvm-ar --set=target.wasm32-unknown-unknown.ranlib=llvm-ranlib" for t in wasm32-wasip1 wasm32-wasip1-threads wasm32-wasip2; do _extra_targets+=",${t}" _wasm_args+=" --set=target.${t}.sanitizers=false --set=target.${t}.profiler=false --set=target.${t}.linker=lld --set=target.${t}.wasi-root=/usr/share/wasi-sysroot --set=target.${t}.cc=clang --set=target.${t}.cxx=clang++ --set=target.${t}.ar=llvm-ar --set=target.${t}.ranlib=llvm-ranlib" done fi # cross bootstrap with docs is currently broken in 1.91.0 if [ "$CROSS_BUILD" ]; then _docs="disable" fi ./configure \ --build="${RUST_BUILD}" \ --host="${RUST_TARGET}" \ --target="${RUST_TARGET}${_extra_targets}" \ --prefix=/usr \ --python=python3 \ --enable-option-checking \ --enable-vendor \ --enable-local-rust \ --enable-locked-deps \ --enable-verbose-tests \ --disable-full-bootstrap \ --enable-extended \ --enable-profiler \ --disable-codegen-tests \ --disable-dist-src \ --${_llvm_shared}-llvm-link-shared \ --${_rpath}-rpath \ --${_local_rebuild}-local-rebuild \ --${_docs}-docs \ --debuginfo-level="${_debug}" \ --debuginfo-level-rustc="${_debug_rustc}" \ --debuginfo-level-tests=0 \ --release-channel=stable \ --release-description="Void Linux" \ --llvm-libunwind=no \ --llvm-config=/usr/bin/llvm-config \ --disable-lld \ --disable-llvm-bitcode-linker \ --tools=clippy,rustdoc,rustfmt,rust-analyzer-proc-macro-srv,wasm-component-ld \ --set="change-id=${_change_id}" \ --set="rust.deny-warnings=false" \ --set="rust.optimize=true" \ --set="rust.debug=false" \ --set="rust.codegen-units=1" \ --set="rust.codegen-units-std=1" \ --set="rust.incremental=false" \ --set="rust.jemalloc=false" \ --set="rust.llvm-tools=false" \ --set="build.submodules=false" \ --set="build.rustc=/usr/bin/rustc" \ --set="build.cargo=/usr/bin/cargo" \ --set="build.optimized-compiler-builtins=false" \ --set="target.${RUST_BUILD}.crt-static=false" \ --set="target.${RUST_BUILD}.cc=${CC_host:-$CC}" \ --set="target.${RUST_BUILD}.cxx=${CXX_host:-$CXX}" \ --set="target.${RUST_BUILD}.ar=${AR_host:-$AR}" \ --set="target.${RUST_BUILD}.linker=${CC_host:-$CC}" \ --set="dist.src-tarball=false" \ ${_wasm_args} ${_cross_args} } do_build() { export RUST_BACKTRACE=1 export JEMALLOC_SYS_WITH_LG_PAGE=16 export CARGO_HOME="/host/cargo" export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt # 1. prevent sysroot from leaking in by removing it from RUSTFLAGS. # 2. Make the std debugging symbols point to rust-src. export RUSTFLAGS="--remap-path-prefix=library=/usr/lib/rustlib/src/rust/library" # unset CFLAGS, CXXFLAGS and LDFLAGS to work around # cc-rs, which adds them to the target specific flags, # causing cross compilation to break if CFLAGS are target # specific. env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \ CXXFLAGS_${RUST_BUILD}="${CXXFLAGS_host}" \ LDFLAGS_${RUST_BUILD}="${LDFLAGS_host}" \ CFLAGS_${RUST_TARGET}="${CFLAGS}" \ CXXFLAGS_${RUST_TARGET}="${CXXFLAGS}" \ LDFLAGS_${RUST_TARGET}="${LDFLAGS}" \ CFLAGS="" CXXFLAGS="" LDFLAGS="" \ python3 x.py dist --jobs $XBPS_MAKEJOBS } do_check() { export RUST_BACKTRACE=1 python3 x.py test ${makejobs} --no-doc --no-fail-fast \ src/test/codegen \ src/test/codegen-units \ src/test/incremental \ src/test/mir-opt \ src/test/pretty \ src/test/run-make \ src/test/run-make-fulldeps \ src/test/ui \ src/test/ui-fulldeps } do_install() { if [ "$build_option_bindist" ]; then mkdir -p ${XBPS_SRCDISTDIR}/distfiles install -m 0644 \ build/dist/rustc-${version}-${RUST_TARGET}.tar.xz \ build/dist/rust-std-${version}-${RUST_TARGET}.tar.xz \ ${XBPS_SRCDISTDIR}/distfiles exit 1 fi vmkdir usr tar xf "build/dist/rustc-${version}-${RUST_TARGET}.tar.gz" \ -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in tar xf "build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz" \ -C "$PKGDESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in tar xf "build/dist/rustc-dev-${version}-${RUST_TARGET}.tar.gz" \ -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in if [ -z "$CROSS_BUILD" ]; then if [ "$build_option_docs" ]; then tar xf "build/dist/rust-docs-${version}-${RUST_TARGET}.tar.gz" \ -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in fi fi tar xf "build/dist/rust-src-${version}.tar.gz" \ -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in tar xf "build/dist/rustfmt-${version}-${RUST_TARGET}.tar.gz" \ -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in tar xf "build/dist/clippy-${version}-${RUST_TARGET}.tar.gz" \ -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in vlicense COPYRIGHT vlicense LICENSE-APACHE vlicense LICENSE-MIT # move from a non-compliant path mv "${DESTDIR}/usr/etc/target-spec-json-schema.json" \ "${DESTDIR}/usr/share/rust/target-spec-json-schema.json" cd ${DESTDIR}/usr/lib # symlinks instead of copies rm *.so ln -sf rustlib/${RUST_TARGET}/lib/*.so . } rust-doc_package() { short_desc+=" - documentation" pkg_install() { vmove usr/share/doc } } rust-std_package() { short_desc+=" - standard library" if [ "$XBPS_TARGET_LIBC" = "musl" ]; then depends="libexecinfo-devel" fi pkg_install() { vmove "usr/lib/rustlib/${RUST_TARGET}" vmove usr/lib/rustlib/rustc-src } } rust-wasm_package() { short_desc+=" - wasm" nostrip=yes pkg_install() { if [ -z "$build_option_bindist" -a -n "$build_option_wasm" ]; then for t in wasm32-unknown-unknown wasm32-wasip1 wasm32-wasip1-threads wasm32-wasip2; do tar xf "build/dist/rust-std-${version}-${t}.tar.gz" \ -C "$PKGDESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in done fi } } rust-src_package() { short_desc+=" - source code" pkg_install() { vmove usr/lib/rustlib/src } }