1 # Maintainer: Johannes Löthberg <johannes@kyriasis.com>
2 # Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
3 # Contributor: Alexander F Rødseth <xyproto@archlinux.org>
4 # Contributor: Daniel Micay <danielmicay@gmail.com>
5 # Contributor: userwithuid <userwithuid@gmail.com>
8 pkgname=(rust lib32-rust-libs rust-musl rust-wasm rust-src)
12 pkgdesc="Systems programming language focused on safety, speed and concurrency"
13 url=https://www.rust-lang.org/
16 options=(!emptydirs !strip)
18 depends=(gcc-libs llvm-libs curl libssh2 gcc)
19 makedepends=(rust "llvm=$_llvm_ver" libffi lib32-gcc-libs perl python cmake musl
21 checkdepends=(procps-ng gdb)
23 "https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz"{,.asc}
24 "https://github.com/llvm/llvm-project/releases/download/llvmorg-$_llvm_ver/compiler-rt-$_llvm_ver.src.tar.xz"{,.sig}
25 0001-cargo-Change-libexec-dir.patch
26 0001-bootstrap-Change-libexec-dir.patch
27 0002-compiler-Change-LLVM-targets.patch
28 0003-compiler-Use-wasm-ld-for-wasm-targets.patch
30 sha256sums=('3546f9c3b91b1f8b8efd26c94d6b50312c08210397b4072ed2748e2bd4445c1a'
32 '4c3602d76c7868a96b30c36165c4b7643e2a20173fced7e071b4baeb2d74db3f'
34 '0f8cfbe0387dd62909fe9cb9523223ae1c2319494e2caf5fa4d0592198631b3e'
35 'a2a8a7c6a5732f79cc92f81d3c8380589c4e2b9a996fb565bbefe42f66b62597'
36 '977da945985dce4484ace8794cbc91241b1f3c27311c1a8b201231db6e1d19e5'
37 'fcf3c4442ba6a9e59415652ce8514428b2e37b80c5fe7d07fb44259ad37abafb')
38 validpgpkeys=(108F66205EAEB0AAA8DD5E1C85AB96E6FA1BE5FE # Rust Language (Tag and Release Signing Key) <rust-key@rust-lang.org>
39 474E22316ABF4785A88C6E8EA2C794A986419D8A # Tom Stellard <tstellar@redhat.com>
40 B6C8F98282B944E3B0D5C2530FC3042E345AD05D) # Hans Wennborg <hans@chromium.org>
45 # Patch bootstrap and cargo so credential helpers
46 # are in /usr/lib instead of /usr/libexec
47 patch -d src/tools/cargo -Np1 < ../0001-cargo-Change-libexec-dir.patch
48 patch -Np1 -i ../0001-bootstrap-Change-libexec-dir.patch
50 # Use our *-pc-linux-gnu targets, making LTO with clang simpler
51 patch -Np1 -i ../0002-compiler-Change-LLVM-targets.patch
54 patch -Np1 -i ../0003-compiler-Use-wasm-ld-for-wasm-targets.patch
56 cat >config.toml <<END
65 "x86_64-unknown-linux-gnu",
66 "i686-unknown-linux-gnu",
67 "x86_64-unknown-linux-musl",
68 "wasm32-unknown-unknown",
71 cargo = "/usr/bin/cargo"
72 rustc = "/usr/bin/rustc"
73 rustfmt = "/usr/bin/rustfmt"
76 tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src", "rust-demangler"]
80 # Generating docs fails with the wasm32-* targets
87 debuginfo-level-std = 2
89 description = "Arch Linux $pkgbase $epoch:$pkgver-$pkgrel"
91 backtrace-on-ice = true
92 remap-debuginfo = true
95 # LLVM crashes when passing an object through ThinLTO twice. This is triggered
96 # when using rust code in cross-language LTO if libstd was built using ThinLTO.
97 # http://blog.llvm.org/2019/09/closing-gap-cross-language-lto-between.html
98 # https://github.com/rust-lang/rust/issues/54872
102 compression-formats = ["gz"]
104 [target.x86_64-unknown-linux-gnu]
105 llvm-config = "/usr/bin/llvm-config"
107 [target.x86_64-unknown-linux-musl]
109 musl-root = "/usr/lib/musl"
111 [target.wasm32-unknown-unknown]
118 wasi-root = "/usr/share/wasi-sysroot"
123 local p="$1" f d; shift
126 mkdir -p "$(dirname "$d")"
128 rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
135 export RUST_BACKTRACE=1
136 export RUST_COMPILER_RT_ROOT="$srcdir/compiler-rt-$_llvm_ver.src"
137 [[ -d $RUST_COMPILER_RT_ROOT ]]
139 DESTDIR="$srcdir/dest-rust" python ./x.py install -j "$(nproc)"
143 # delete unnecessary files, e.g. files only used for the uninstall script
144 rm usr/lib/rustlib/{components,install.log,rust-installer-version,uninstall.sh}
145 rm usr/lib/rustlib/manifest-*
147 # rustbuild always installs copies of the shared libraries to /usr/lib,
148 # overwrite them with symlinks to the per-architecture versions
150 ln -srft usr/lib usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/*.so
151 ln -srft usr/lib32 usr/lib/rustlib/i686-unknown-linux-gnu/lib/*.so
153 mkdir -p usr/share/bash-completion
154 mv etc/bash_completion.d usr/share/bash-completion/completions
156 mkdir -p usr/share/licenses/rust
157 mv -t usr/share/licenses/rust usr/share/doc/rust/{COPYRIGHT,LICENSE*}
159 _pick dest-i686 usr/lib/rustlib/i686-unknown-linux-gnu usr/lib32
160 _pick dest-musl usr/lib/rustlib/x86_64-unknown-linux-musl
161 _pick dest-wasm usr/lib/rustlib/wasm32-*
162 _pick dest-src usr/lib/rustlib/src
166 optdepends=('lldb: rust-lldb script'
167 'gdb: rust-gdb script')
168 provides=(cargo rustfmt)
169 conflicts=(cargo rustfmt 'rust-docs<1:1.56.1-3')
170 replaces=(cargo rustfmt cargo-tree 'rust-docs<1:1.56.1-3')
172 cp -a dest-rust/* "$pkgdir"
175 package_lib32-rust-libs() {
176 pkgdesc="32-bit target and libraries for Rust"
177 depends=(rust lib32-gcc-libs)
178 provides=(lib32-rust)
179 conflicts=(lib32-rust)
180 replaces=(lib32-rust)
182 cp -a dest-i686/* "$pkgdir"
184 mkdir -p "$pkgdir/usr/share/licenses"
185 ln -s rust "$pkgdir/usr/share/licenses/$pkgname"
188 package_rust-musl() {
189 pkgdesc="Musl target for Rust"
192 cp -a dest-musl/* "$pkgdir"
194 mkdir -p "$pkgdir/usr/share/licenses"
195 ln -s rust "$pkgdir/usr/share/licenses/$pkgname"
198 package_rust-wasm() {
199 pkgdesc="WebAssembly targets for Rust"
202 cp -a dest-wasm/* "$pkgdir"
204 mkdir -p "$pkgdir/usr/share/licenses"
205 ln -s rust "$pkgdir/usr/share/licenses/$pkgname"
209 pkgdesc="Source code for the Rust standard library"
212 cp -a dest-src/* "$pkgdir"
214 mkdir -p "$pkgdir/usr/share/licenses"
215 ln -s rust "$pkgdir/usr/share/licenses/$pkgname"
218 # vim:set ts=2 sw=2 et: