1 # Template file for 'rust'
2 # partially adapted from Alpine/Adélie's Rust APKBUILD
4 # Permission to use rust and cargo trademark is granted.
5 # See: https://github.com/rust-lang/core-team/issues/4
7 # Always make sure custom distfiles used for bootstrap are
8 # uploaded to https://repo-default.voidlinux.org/distfiles/
13 hostmakedepends="curl pkg-config python3 tar cargo-bootstrap"
14 makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm18-devel"
15 depends="rust-std gcc"
16 short_desc="Safe, concurrent, practical systems language"
17 maintainer="Enno Boland <gottox@voidlinux.org>"
18 license="MIT, Apache-2.0"
19 homepage="https://www.rust-lang.org/"
20 distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
21 checksum=6f606c193f230f6b2cae4576f7b24d50f5f9b25dff11dbf9b22f787d3521d672
23 make_check=no # CBA for now
24 python_version=3 # needed for python files in rust-src
26 build_options="bindist"
27 desc_option_bindist="Generate tarballs for bootstrap"
29 if [ "$XBPS_LIBC" = "musl" ]; then
30 hostmakedepends+=" libexecinfo-devel"
32 if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
33 makedepends+=" libexecinfo-devel"
36 if [ "$CROSS_BUILD" ]; then
37 hostmakedepends+=" rust llvm18-devel"
38 # These are required for building the buildhost's stage0/1
39 hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
41 hostmakedepends+=" rust-bootstrap"
44 # we need this because cargo verifies checksums of all files in vendor
45 # crates when it builds and gives us no way to override or update the
46 # file sanely... so just clear out the file list
47 _clear_vendor_checksums() {
48 sed -i 's/\("files":{\)[^}]*/\1/' vendor/$1/.cargo-checksum.json
52 rm -rf src/llvm-project
53 if [ "$build_option_bindist" ]; then
54 for x in ${FILESDIR}/patches/static-llvm/*.patch; do
55 msg_normal "Applying patch $x\n"
60 # clear out all the checksum nonsense of patched vendor crates
61 _clear_vendor_checksums libc-0.2.155
63 # pre-configure 01-override-config overwrites vendor files
64 _clear_vendor_checksums onig_sys-69.8.1
68 local _local_rebuild _debug _debug_rustc _rpath _docs _llvm_shared
71 if [ "$CROSS_BUILD" ]; then
72 _local_rebuild="enable"
74 _local_rebuild="disable"
77 # disable rustc debug info as it bloats up rust-std significantly
78 # set to 1 or 2 if you wish to have debug info for rustc, it won't
79 # link on 32-bit platforms though (too big)
81 # just disable debug for now
84 # if true, the binaries will be built with rpath, so the binaries will be
85 # usable directly from the build directory, this is not desirable for
86 # packaging but is useful when building bootstrap binaries
87 if [ "$build_option_bindist" ]; then
90 _llvm_shared="disable"
97 if [ "$CROSS_BUILD" ]; then
98 _cross_args="--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
99 --set=target.${RUST_TARGET}.crt-static=false
100 --set=target.${RUST_TARGET}.cc=${CC}
101 --set=target.${RUST_TARGET}.cxx=${CXX}
102 --set=target.${RUST_TARGET}.ar=${AR}
103 --set=target.${RUST_TARGET}.linker=${CC}"
107 --build="${RUST_BUILD}" \
108 --host="${RUST_TARGET}" \
109 --target="${RUST_TARGET}" \
113 --enable-locked-deps \
114 --enable-verbose-tests \
115 --disable-full-bootstrap \
117 --disable-codegen-tests \
119 --${_llvm_shared}-llvm-link-shared \
121 --${_local_rebuild}-local-rebuild \
123 --debuginfo-level="${_debug}" \
124 --debuginfo-level-rustc="${_debug_rustc}" \
125 --debuginfo-level-tests=0 \
126 --release-channel=stable \
127 --release-description="Void Linux" \
128 --llvm-libunwind=no \
129 --llvm-config=/usr/bin/llvm-config \
130 --tools=clippy,rustdoc,rustfmt,rust-analyzer-proc-macro-srv \
131 --set="rust.optimize=true" \
132 --set="rust.debug=false" \
133 --set="rust.codegen-units=1" \
134 --set="rust.codegen-units-std=1" \
135 --set="rust.incremental=false" \
136 --set="rust.parallel-compiler=false" \
137 --set="rust.jemalloc=false" \
138 --set="build.submodules=false" \
139 --set="build.rustc=/usr/bin/rustc" \
140 --set="build.cargo=/usr/bin/cargo" \
141 --set="build.optimized-compiler-builtins=false" \
142 --set="target.${RUST_BUILD}.crt-static=false" \
143 --set="target.${RUST_BUILD}.cc=${CC_host:-$CC}" \
144 --set="target.${RUST_BUILD}.cxx=${CXX_host:-$CXX}" \
145 --set="target.${RUST_BUILD}.ar=${AR_host:-$AR}" \
146 --set="target.${RUST_BUILD}.linker=${CC_host:-$CC}" \
147 --set="dist.src-tarball=false" \
151 # Set the correct CFLAGS for the build host, we have to compile libbacktrace
152 # for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
155 export RUST_BACKTRACE=1
156 export JEMALLOC_SYS_WITH_LG_PAGE=16
157 export CARGO_HOME="$wrksrc/.cargo"
158 export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
159 # prevent sysroot from leaking in
161 env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
162 CXXFLAGS_${RUST_BUILD}="${CXXFLAGS_host}" \
163 CFLAGS_${RUST_TARGET}="${CFLAGS}" \
164 CXXFLAGS_${RUST_TARGET}="${CXXFLAGS}" \
165 python3 x.py dist --jobs $XBPS_MAKEJOBS
169 export RUST_BACKTRACE=1
171 python3 x.py test ${makejobs} --no-doc --no-fail-fast \
173 src/test/codegen-units \
174 src/test/incremental \
178 src/test/run-make-fulldeps \
184 if [ "$build_option_bindist" ]; then
185 mkdir -p ${XBPS_SRCDISTDIR}/distfiles
187 build/dist/rustc-${version}-${RUST_TARGET}.tar.xz \
188 build/dist/rust-std-${version}-${RUST_TARGET}.tar.xz \
189 ${XBPS_SRCDISTDIR}/distfiles
194 tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
195 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
196 tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
197 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
198 tar xf build/dist/rustc-dev-${version}-${RUST_TARGET}.tar.gz \
199 -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
200 tar xf build/dist/rust-docs-${version}-${RUST_TARGET}.tar.gz \
201 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
202 tar xf build/dist/rust-src-${version}.tar.gz \
203 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
204 tar xf build/dist/rustfmt-${version}-${RUST_TARGET}.tar.gz \
205 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
206 tar xf build/dist/clippy-${version}-${RUST_TARGET}.tar.gz \
207 -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
210 vlicense LICENSE-APACHE
213 cd ${DESTDIR}/usr/lib
214 # symlinks instead of copies
216 ln -sf rustlib/${RUST_TARGET}/lib/*.so .
220 short_desc+=" - documentation"
227 short_desc+=" - standard library"
228 if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
229 depends="libexecinfo-devel"
232 vmove usr/lib/rustlib/${RUST_TARGET}
233 vmove usr/lib/rustlib/rustc-src
238 short_desc+=" - source code"
240 vmove usr/lib/rustlib/src