1 |
commit: c03f0410ab91dd47fed65113350654e15b2811b6 |
2 |
Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jan 20 21:59:06 2022 +0000 |
4 |
Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 20 22:02:17 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c03f0410 |
7 |
|
8 |
dev-lang/rust: add 1.58.1 |
9 |
|
10 |
Bug: https://bugs.gentoo.org/831638 |
11 |
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org> |
12 |
|
13 |
dev-lang/rust/Manifest | 2 + |
14 |
dev-lang/rust/metadata.xml | 1 + |
15 |
dev-lang/rust/rust-1.58.1.ebuild | 704 +++++++++++++++++++++++++++++++++++++++ |
16 |
3 files changed, 707 insertions(+) |
17 |
|
18 |
diff --git a/dev-lang/rust/Manifest b/dev-lang/rust/Manifest |
19 |
index c8dda48c543b..d82be7271a09 100644 |
20 |
--- a/dev-lang/rust/Manifest |
21 |
+++ b/dev-lang/rust/Manifest |
22 |
@@ -202,3 +202,5 @@ DIST rustc-1.57.0-src.tar.xz 122681768 BLAKE2B 739fe2c34b01bb0c6beeb7717badeb2ba |
23 |
DIST rustc-1.57.0-src.tar.xz.asc 801 BLAKE2B e5c2e91999d8d2bcb5be36ddc8559a59fc53445f639bd179239489f9fd2a2f00f2191cdbb2000b73866fbb332b51be090e95e348a3573676dc24e00cdbb071fa SHA512 fcf1393a1be3c585447e08078b804e7ffcddcb47d87877c13526592e317b889b15ad1786baef5d6adf020631a6773a9dd31c04779f475a528b28871920a4641f |
24 |
DIST rustc-1.58.0-src.tar.xz 124348768 BLAKE2B e5a0d919a1ca1202e218cec3da93fc69cba163069b1f2b4051778a49184715579c14cd6b03baa0225b10a8f1adf758aca427c910d95dfa2e647bbf8b7d133785 SHA512 70104f4d3b474dcb9935200ef0503f29cb15f10d38ba8630e1dadbb384924dd9137fced647794699efe83ac88083e4ae5f45712f0e1c8bc0a6f8c23eecdb0aeb |
25 |
DIST rustc-1.58.0-src.tar.xz.asc 801 BLAKE2B d8b3ae366d20e0a27b53973e0d215c0fd5f596116ede15ac0e729db4a92fff6c602fc3893674863040a97abaaab36b351413e87a2c6d77f823fcda5805d23daa SHA512 e4bffe84637b2708d00fae091e3eb868063a8f65da918a847ef7db3f1edd35f96068489cae77238decfc134f4456cf6e3122f993e61f1e4986d3ec7f029d7125 |
26 |
+DIST rustc-1.58.1-src.tar.xz 124353160 BLAKE2B 686c7272db544ad46f7fb01b4e05f24f4e08ff959a000cadfaef5d8fc413b93f5ed839077bc9715defc7a0a179af091f65c7a5d7104b0b3153f0654c237c094b SHA512 eff3279d2e519343cea542a9ae2daab592e44f35af344e33ff43ed55fc7c824511790d1991dd36a603d12465de8c3688e7194c2b9557f288c587ffa04738c2ce |
27 |
+DIST rustc-1.58.1-src.tar.xz.asc 801 BLAKE2B f0b600a503b0ca777dd5d690dca7252ecc6d7d49ca4a9cc8edc0647038f727e9052a861f9868292f837d78d6b02efe9ed5efa85843262c44cf6f73254cc7c9b0 SHA512 983c1ffdc4febf8bce6efc123c76b13f233772bc0a152ffaeb7ebf8f1f7b82a6b5d653407a4d293953d6fbf62c0df4ff4d398a1133061b53ae0f85317a14380b |
28 |
|
29 |
diff --git a/dev-lang/rust/metadata.xml b/dev-lang/rust/metadata.xml |
30 |
index a51257c9ae1d..472e67741b03 100644 |
31 |
--- a/dev-lang/rust/metadata.xml |
32 |
+++ b/dev-lang/rust/metadata.xml |
33 |
@@ -11,6 +11,7 @@ |
34 |
</maintainer> |
35 |
<use> |
36 |
<flag name="clippy">Install clippy, Rust code linter</flag> |
37 |
+ <flag name="dist">Install dist tarballs (used for bootstrapping)</flag> |
38 |
<flag name="miri">Install miri, an interpreter for Rust's mid-level intermediate representation (requires USE=nightly)</flag> |
39 |
<flag name="nightly">Enable nightly (UNSTABLE) features</flag> |
40 |
<flag name="parallel-compiler">Build a multi-threaded rustc (experimental, not tested by upstream)</flag> |
41 |
|
42 |
diff --git a/dev-lang/rust/rust-1.58.1.ebuild b/dev-lang/rust/rust-1.58.1.ebuild |
43 |
new file mode 100644 |
44 |
index 000000000000..810ce4d6e69b |
45 |
--- /dev/null |
46 |
+++ b/dev-lang/rust/rust-1.58.1.ebuild |
47 |
@@ -0,0 +1,704 @@ |
48 |
+# Copyright 1999-2022 Gentoo Authors |
49 |
+# Distributed under the terms of the GNU General Public License v2 |
50 |
+ |
51 |
+EAPI=7 |
52 |
+ |
53 |
+PYTHON_COMPAT=( python3_{7..10} ) |
54 |
+ |
55 |
+inherit bash-completion-r1 check-reqs estack flag-o-matic llvm multiprocessing \ |
56 |
+ multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs verify-sig |
57 |
+ |
58 |
+if [[ ${PV} = *beta* ]]; then |
59 |
+ betaver=${PV//*beta} |
60 |
+ BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}" |
61 |
+ MY_P="rustc-beta" |
62 |
+ SLOT="beta/${PV}" |
63 |
+ SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz -> rustc-${PV}-src.tar.xz" |
64 |
+else |
65 |
+ ABI_VER="$(ver_cut 1-2)" |
66 |
+ SLOT="stable/${ABI_VER}" |
67 |
+ MY_P="rustc-${PV}" |
68 |
+ SRC="${MY_P}-src.tar.xz" |
69 |
+ KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86" |
70 |
+fi |
71 |
+ |
72 |
+RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0" |
73 |
+ |
74 |
+DESCRIPTION="Systems programming language from Mozilla" |
75 |
+HOMEPAGE="https://www.rust-lang.org/" |
76 |
+ |
77 |
+SRC_URI=" |
78 |
+ https://static.rust-lang.org/dist/${SRC} |
79 |
+ verify-sig? ( https://static.rust-lang.org/dist/${SRC}.asc ) |
80 |
+ !system-bootstrap? ( $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION}) ) |
81 |
+" |
82 |
+ |
83 |
+# keep in sync with llvm ebuild of the same version as bundled one. |
84 |
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430 |
85 |
+ NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore ) |
86 |
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
87 |
+LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/(-)?} |
88 |
+ |
89 |
+LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA" |
90 |
+ |
91 |
+IUSE="clippy cpu_flags_x86_sse2 debug dist doc miri nightly parallel-compiler rls rustfmt rust-src system-bootstrap system-llvm test wasm ${ALL_LLVM_TARGETS[*]}" |
92 |
+ |
93 |
+# Please keep the LLVM dependency block separate. Since LLVM is slotted, |
94 |
+# we need to *really* make sure we're not pulling more than one slot |
95 |
+# simultaneously. |
96 |
+ |
97 |
+# How to use it: |
98 |
+# List all the working slots in LLVM_VALID_SLOTS, newest first. |
99 |
+LLVM_VALID_SLOTS=( 13 ) |
100 |
+LLVM_MAX_SLOT="${LLVM_VALID_SLOTS[0]}" |
101 |
+ |
102 |
+# splitting usedeps needed to avoid CI/pkgcheck's UncheckableDep limitation |
103 |
+# (-) usedep needed because we may build with older llvm without that target |
104 |
+LLVM_DEPEND="|| ( " |
105 |
+for _s in ${LLVM_VALID_SLOTS[@]}; do |
106 |
+ LLVM_DEPEND+=" ( " |
107 |
+ for _x in ${ALL_LLVM_TARGETS[@]}; do |
108 |
+ LLVM_DEPEND+=" |
109 |
+ ${_x}? ( sys-devel/llvm:${_s}[${_x}(-)] )" |
110 |
+ done |
111 |
+ LLVM_DEPEND+=" )" |
112 |
+done |
113 |
+unset _s _x |
114 |
+LLVM_DEPEND+=" ) |
115 |
+ <sys-devel/llvm-$(( LLVM_MAX_SLOT + 1 )):= |
116 |
+ wasm? ( sys-devel/lld ) |
117 |
+" |
118 |
+ |
119 |
+# to bootstrap we need at least exactly previous version, or same. |
120 |
+# most of the time previous versions fail to bootstrap with newer |
121 |
+# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok, |
122 |
+# but it fails to bootstrap with 1.48.x |
123 |
+# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.txt |
124 |
+RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*" |
125 |
+RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*" |
126 |
+BOOTSTRAP_DEPEND="|| |
127 |
+ ( |
128 |
+ =dev-lang/rust-"${RUST_DEP_PREV}" |
129 |
+ =dev-lang/rust-bin-"${RUST_DEP_PREV}" |
130 |
+ =dev-lang/rust-"${RUST_DEP_CURR}" |
131 |
+ =dev-lang/rust-bin-"${RUST_DEP_CURR}" |
132 |
+ ) |
133 |
+" |
134 |
+ |
135 |
+BDEPEND="${PYTHON_DEPS} |
136 |
+ app-eselect/eselect-rust |
137 |
+ || ( |
138 |
+ >=sys-devel/gcc-4.7 |
139 |
+ >=sys-devel/clang-3.5 |
140 |
+ ) |
141 |
+ system-bootstrap? ( ${BOOTSTRAP_DEPEND} ) |
142 |
+ !system-llvm? ( |
143 |
+ >=dev-util/cmake-3.13.4 |
144 |
+ dev-util/ninja |
145 |
+ ) |
146 |
+ test? ( sys-devel/gdb ) |
147 |
+ verify-sig? ( sec-keys/openpgp-keys-rust ) |
148 |
+" |
149 |
+ |
150 |
+DEPEND=" |
151 |
+ >=app-arch/xz-utils-5.2 |
152 |
+ net-misc/curl:=[http2,ssl] |
153 |
+ sys-libs/zlib:= |
154 |
+ dev-libs/openssl:0= |
155 |
+ elibc_musl? ( sys-libs/libunwind:= ) |
156 |
+ system-llvm? ( ${LLVM_DEPEND} ) |
157 |
+" |
158 |
+ |
159 |
+# we need to block older versions due to layout changes. |
160 |
+RDEPEND="${DEPEND} |
161 |
+ app-eselect/eselect-rust |
162 |
+ !<dev-lang/rust-1.47.0-r1 |
163 |
+ !<dev-lang/rust-bin-1.47.0-r1 |
164 |
+" |
165 |
+ |
166 |
+REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} ) |
167 |
+ miri? ( nightly ) |
168 |
+ parallel-compiler? ( nightly ) |
169 |
+ rls? ( rust-src ) |
170 |
+ test? ( ${ALL_LLVM_TARGETS[*]} ) |
171 |
+ wasm? ( llvm_targets_WebAssembly ) |
172 |
+ x86? ( cpu_flags_x86_sse2 ) |
173 |
+" |
174 |
+ |
175 |
+# we don't use cmake.eclass, but can get a warning |
176 |
+CMAKE_WARN_UNUSED_CLI=no |
177 |
+ |
178 |
+QA_FLAGS_IGNORED=" |
179 |
+ usr/lib/${PN}/${PV}/bin/.* |
180 |
+ usr/lib/${PN}/${PV}/libexec/.* |
181 |
+ usr/lib/${PN}/${PV}/lib/lib.*.so |
182 |
+ usr/lib/${PN}/${PV}/lib/rustlib/.*/bin/.* |
183 |
+ usr/lib/${PN}/${PV}/lib/rustlib/.*/lib/lib.*.so |
184 |
+" |
185 |
+ |
186 |
+QA_SONAME=" |
187 |
+ usr/lib/${PN}/${PV}/lib/lib.*.so.* |
188 |
+ usr/lib/${PN}/${PV}/lib/rustlib/.*/lib/lib.*.so |
189 |
+" |
190 |
+ |
191 |
+QA_PRESTRIPPED=" |
192 |
+ usr/lib/rust/${PV}/lib/rustlib/.*/bin/rust-llvm-dwp |
193 |
+" |
194 |
+# An rmeta file is custom binary format that contains the metadata for the crate. |
195 |
+# rmeta files do not support linking, since they do not contain compiled object files. |
196 |
+# so we can safely silence the warning for this QA check. |
197 |
+QA_EXECSTACK="usr/lib/${PN}/${PV}/lib/rustlib/*/lib*.rlib:lib.rmeta" |
198 |
+ |
199 |
+# causes double bootstrap |
200 |
+RESTRICT="test" |
201 |
+ |
202 |
+VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/rust.asc |
203 |
+ |
204 |
+PATCHES=( |
205 |
+ "${FILESDIR}"/1.55.0-ignore-broken-and-non-applicable-tests.patch |
206 |
+ "${FILESDIR}"/1.49.0-gentoo-musl-target-specs.patch |
207 |
+) |
208 |
+ |
209 |
+S="${WORKDIR}/${MY_P}-src" |
210 |
+ |
211 |
+toml_usex() { |
212 |
+ usex "${1}" true false |
213 |
+} |
214 |
+ |
215 |
+bootstrap_rust_version_check() { |
216 |
+ # never call from pkg_pretend. eselect-rust may be not installed yet. |
217 |
+ [[ ${MERGE_TYPE} == binary ]] && return |
218 |
+ local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))" |
219 |
+ local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))" |
220 |
+ local rustc_version=( $(eselect --brief rust show 2>/dev/null) ) |
221 |
+ rustc_version=${rustc_version[0]#rust-bin-} |
222 |
+ rustc_version=${rustc_version#rust-} |
223 |
+ |
224 |
+ [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, check 'eselect rust' output" |
225 |
+ |
226 |
+ if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then |
227 |
+ eerror "Rust >=${rustc_wanted} is required" |
228 |
+ eerror "please run 'eselect rust' and set correct rust version" |
229 |
+ die "selected rust version is too old" |
230 |
+ elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then |
231 |
+ eerror "Rust <${rustc_toonew} is required" |
232 |
+ eerror "please run 'eselect rust' and set correct rust version" |
233 |
+ die "selected rust version is too new" |
234 |
+ else |
235 |
+ einfo "Using rust ${rustc_version} to build" |
236 |
+ fi |
237 |
+} |
238 |
+ |
239 |
+pre_build_checks() { |
240 |
+ local M=4096 |
241 |
+ # multiply requirements by 1.5 if we are doing x86-multilib |
242 |
+ if use amd64; then |
243 |
+ M=$(( $(usex abi_x86_32 15 10) * ${M} / 10 )) |
244 |
+ fi |
245 |
+ M=$(( $(usex clippy 128 0) + ${M} )) |
246 |
+ M=$(( $(usex miri 128 0) + ${M} )) |
247 |
+ M=$(( $(usex rls 512 0) + ${M} )) |
248 |
+ M=$(( $(usex rustfmt 256 0) + ${M} )) |
249 |
+ # add 2G if we compile llvm and 256M per llvm_target |
250 |
+ if ! use system-llvm; then |
251 |
+ M=$(( 2048 + ${M} )) |
252 |
+ local ltarget |
253 |
+ for ltarget in ${ALL_LLVM_TARGETS[@]}; do |
254 |
+ M=$(( $(usex ${ltarget} 256 0) + ${M} )) |
255 |
+ done |
256 |
+ fi |
257 |
+ M=$(( $(usex wasm 256 0) + ${M} )) |
258 |
+ M=$(( $(usex debug 2 1) * ${M} )) |
259 |
+ eshopts_push -s extglob |
260 |
+ if is-flagq '-g?(gdb)?([1-9])'; then |
261 |
+ M=$(( 15 * ${M} / 10 )) |
262 |
+ fi |
263 |
+ eshopts_pop |
264 |
+ M=$(( $(usex system-bootstrap 0 1024) + ${M} )) |
265 |
+ M=$(( $(usex doc 256 0) + ${M} )) |
266 |
+ CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE} |
267 |
+} |
268 |
+ |
269 |
+llvm_check_deps() { |
270 |
+ has_version -r "sys-devel/llvm:${LLVM_SLOT}[${LLVM_TARGET_USEDEPS// /,}]" |
271 |
+} |
272 |
+ |
273 |
+pkg_pretend() { |
274 |
+ pre_build_checks |
275 |
+} |
276 |
+ |
277 |
+pkg_setup() { |
278 |
+ pre_build_checks |
279 |
+ python-any-r1_pkg_setup |
280 |
+ |
281 |
+ export LIBGIT2_NO_PKG_CONFIG=1 #749381 |
282 |
+ |
283 |
+ use system-bootstrap && bootstrap_rust_version_check |
284 |
+ |
285 |
+ if use system-llvm; then |
286 |
+ llvm_pkg_setup |
287 |
+ |
288 |
+ local llvm_config="$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config" |
289 |
+ export LLVM_LINK_SHARED=1 |
290 |
+ export RUSTFLAGS="${RUSTFLAGS} -Lnative=$("${llvm_config}" --libdir)" |
291 |
+ fi |
292 |
+} |
293 |
+ |
294 |
+src_prepare() { |
295 |
+ if ! use system-bootstrap; then |
296 |
+ local rust_stage0_root="${WORKDIR}"/rust-stage0 |
297 |
+ local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)" |
298 |
+ |
299 |
+ "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig \ |
300 |
+ --without=rust-docs --destdir="${rust_stage0_root}" --prefix=/ || die |
301 |
+ fi |
302 |
+ |
303 |
+ default |
304 |
+} |
305 |
+ |
306 |
+src_configure() { |
307 |
+ local rust_target="" rust_targets="" arch_cflags |
308 |
+ |
309 |
+ # Collect rust target names to compile standard libs for all ABIs. |
310 |
+ for v in $(multilib_get_enabled_abi_pairs); do |
311 |
+ rust_targets="${rust_targets},\"$(rust_abi $(get_abi_CHOST ${v##*.}))\"" |
312 |
+ done |
313 |
+ if use wasm; then |
314 |
+ rust_targets="${rust_targets},\"wasm32-unknown-unknown\"" |
315 |
+ if use system-llvm; then |
316 |
+ # un-hardcode rust-lld linker for this target |
317 |
+ # https://bugs.gentoo.org/715348 |
318 |
+ sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/wasm_base.rs || die |
319 |
+ fi |
320 |
+ fi |
321 |
+ rust_targets="${rust_targets#,}" |
322 |
+ |
323 |
+ local tools="\"cargo\"," |
324 |
+ if use clippy; then |
325 |
+ tools="\"clippy\",$tools" |
326 |
+ fi |
327 |
+ if use miri; then |
328 |
+ tools="\"miri\",$tools" |
329 |
+ fi |
330 |
+ if use rls; then |
331 |
+ tools="\"rls\",\"analysis\",$tools" |
332 |
+ fi |
333 |
+ if use rustfmt; then |
334 |
+ tools="\"rustfmt\",$tools" |
335 |
+ fi |
336 |
+ if use rust-src; then |
337 |
+ tools="\"src\",$tools" |
338 |
+ fi |
339 |
+ |
340 |
+ local rust_stage0_root |
341 |
+ if use system-bootstrap; then |
342 |
+ local printsysroot |
343 |
+ printsysroot="$(rustc --print sysroot || die "Can't determine rust's sysroot")" |
344 |
+ rust_stage0_root="${printsysroot}" |
345 |
+ else |
346 |
+ rust_stage0_root="${WORKDIR}"/rust-stage0 |
347 |
+ fi |
348 |
+ # in case of prefix it will be already prefixed, as --print sysroot returns full path |
349 |
+ [[ -d ${rust_stage0_root} ]] || die "${rust_stage0_root} is not a directory" |
350 |
+ |
351 |
+ rust_target="$(rust_abi)" |
352 |
+ |
353 |
+ cat <<- _EOF_ > "${S}"/config.toml |
354 |
+ changelog-seen = 2 |
355 |
+ [llvm] |
356 |
+ download-ci-llvm = false |
357 |
+ optimize = $(toml_usex !debug) |
358 |
+ release-debuginfo = $(toml_usex debug) |
359 |
+ assertions = $(toml_usex debug) |
360 |
+ ninja = true |
361 |
+ targets = "${LLVM_TARGETS// /;}" |
362 |
+ experimental-targets = "" |
363 |
+ link-shared = $(toml_usex system-llvm) |
364 |
+ $(case "${rust_target}" in |
365 |
+ i586-*-linux-*) |
366 |
+ # https://github.com/rust-lang/rust/issues/93059 |
367 |
+ echo 'cflags = "-fcf-protection=none"' |
368 |
+ echo 'cxxflags = "-fcf-protection=none"' |
369 |
+ echo 'ldflags = "-fcf-protection=none"' |
370 |
+ ;; |
371 |
+ esac) |
372 |
+ [build] |
373 |
+ build-stage = 2 |
374 |
+ test-stage = 2 |
375 |
+ doc-stage = 2 |
376 |
+ build = "${rust_target}" |
377 |
+ host = ["${rust_target}"] |
378 |
+ target = [${rust_targets}] |
379 |
+ cargo = "${rust_stage0_root}/bin/cargo" |
380 |
+ rustc = "${rust_stage0_root}/bin/rustc" |
381 |
+ rustfmt = "${rust_stage0_root}/bin/rustfmt" |
382 |
+ docs = $(toml_usex doc) |
383 |
+ compiler-docs = false |
384 |
+ submodules = false |
385 |
+ python = "${EPYTHON}" |
386 |
+ locked-deps = true |
387 |
+ vendor = true |
388 |
+ extended = true |
389 |
+ tools = [${tools}] |
390 |
+ verbose = 2 |
391 |
+ sanitizers = false |
392 |
+ profiler = false |
393 |
+ cargo-native-static = false |
394 |
+ [install] |
395 |
+ prefix = "${EPREFIX}/usr/lib/${PN}/${PV}" |
396 |
+ sysconfdir = "etc" |
397 |
+ docdir = "share/doc/rust" |
398 |
+ bindir = "bin" |
399 |
+ libdir = "lib" |
400 |
+ mandir = "share/man" |
401 |
+ [rust] |
402 |
+ # https://github.com/rust-lang/rust/issues/54872 |
403 |
+ codegen-units-std = 1 |
404 |
+ optimize = true |
405 |
+ debug = $(toml_usex debug) |
406 |
+ debug-assertions = $(toml_usex debug) |
407 |
+ debug-assertions-std = $(toml_usex debug) |
408 |
+ debuginfo-level = $(usex debug 2 0) |
409 |
+ debuginfo-level-rustc = $(usex debug 2 0) |
410 |
+ debuginfo-level-std = $(usex debug 2 0) |
411 |
+ debuginfo-level-tools = $(usex debug 2 0) |
412 |
+ debuginfo-level-tests = 0 |
413 |
+ backtrace = true |
414 |
+ incremental = false |
415 |
+ default-linker = "$(tc-getCC)" |
416 |
+ parallel-compiler = $(toml_usex parallel-compiler) |
417 |
+ channel = "$(usex nightly nightly stable)" |
418 |
+ description = "gentoo" |
419 |
+ rpath = false |
420 |
+ verbose-tests = true |
421 |
+ optimize-tests = $(toml_usex !debug) |
422 |
+ codegen-tests = true |
423 |
+ dist-src = false |
424 |
+ remap-debuginfo = true |
425 |
+ lld = $(usex system-llvm false $(toml_usex wasm)) |
426 |
+ # only deny warnings if doc+wasm are NOT requested, documenting stage0 wasm std fails without it |
427 |
+ # https://github.com/rust-lang/rust/issues/74976 |
428 |
+ # https://github.com/rust-lang/rust/issues/76526 |
429 |
+ deny-warnings = $(usex wasm $(usex doc false true) true) |
430 |
+ backtrace-on-ice = true |
431 |
+ jemalloc = false |
432 |
+ [dist] |
433 |
+ src-tarball = false |
434 |
+ compression-formats = ["xz"] |
435 |
+ _EOF_ |
436 |
+ |
437 |
+ for v in $(multilib_get_enabled_abi_pairs); do |
438 |
+ rust_target=$(rust_abi $(get_abi_CHOST ${v##*.})) |
439 |
+ arch_cflags="$(get_abi_CFLAGS ${v##*.})" |
440 |
+ |
441 |
+ cat <<- _EOF_ >> "${S}"/config.env |
442 |
+ CFLAGS_${rust_target}=${arch_cflags} |
443 |
+ _EOF_ |
444 |
+ |
445 |
+ cat <<- _EOF_ >> "${S}"/config.toml |
446 |
+ [target.${rust_target}] |
447 |
+ ar = "$(tc-getAR)" |
448 |
+ cc = "$(tc-getCC)" |
449 |
+ cxx = "$(tc-getCXX)" |
450 |
+ linker = "$(tc-getCC)" |
451 |
+ ranlib = "$(tc-getRANLIB)" |
452 |
+ _EOF_ |
453 |
+ # librustc_target/spec/linux_musl_base.rs sets base.crt_static_default = true; |
454 |
+ if use elibc_musl; then |
455 |
+ cat <<- _EOF_ >> "${S}"/config.toml |
456 |
+ crt-static = false |
457 |
+ _EOF_ |
458 |
+ fi |
459 |
+ if use system-llvm; then |
460 |
+ cat <<- _EOF_ >> "${S}"/config.toml |
461 |
+ llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config" |
462 |
+ _EOF_ |
463 |
+ fi |
464 |
+ done |
465 |
+ if use wasm; then |
466 |
+ cat <<- _EOF_ >> "${S}"/config.toml |
467 |
+ [target.wasm32-unknown-unknown] |
468 |
+ linker = "$(usex system-llvm lld rust-lld)" |
469 |
+ _EOF_ |
470 |
+ fi |
471 |
+ |
472 |
+ if [[ -n ${I_KNOW_WHAT_I_AM_DOING_CROSS} ]]; then # whitespace intentionally shifted below |
473 |
+ # experimental cross support |
474 |
+ # discussion: https://bugs.gentoo.org/679878 |
475 |
+ # TODO: c*flags, clang, system-llvm, cargo.eclass target support |
476 |
+ # it would be much better if we could split out stdlib |
477 |
+ # complilation to separate ebuild and abuse CATEGORY to |
478 |
+ # just install to /usr/lib/rustlib/<target> |
479 |
+ |
480 |
+ # extra targets defined as a bash array |
481 |
+ # spec format: <LLVM target>:<rust-target>:<CTARGET> |
482 |
+ # best place would be /etc/portage/env/dev-lang/rust |
483 |
+ # Example: |
484 |
+ # RUST_CROSS_TARGETS=( |
485 |
+ # "AArch64:aarch64-unknown-linux-gnu:aarch64-unknown-linux-gnu" |
486 |
+ # ) |
487 |
+ # no extra hand holding is done, no target transformations, all |
488 |
+ # values are passed as-is with just basic checks, so it's up to user to supply correct values |
489 |
+ # valid rust targets can be obtained with |
490 |
+ # rustc --print target-list |
491 |
+ # matching cross toolchain has to be installed |
492 |
+ # matching LLVM_TARGET has to be enabled for both rust and llvm (if using system one) |
493 |
+ # only gcc toolchains installed with crossdev are checked for now. |
494 |
+ |
495 |
+ # BUG: we can't pass host flags to cross compiler, so just filter for now |
496 |
+ # BUG: this should be more fine-grained. |
497 |
+ filter-flags '-mcpu=*' '-march=*' '-mtune=*' |
498 |
+ |
499 |
+ local cross_target_spec |
500 |
+ for cross_target_spec in "${RUST_CROSS_TARGETS[@]}";do |
501 |
+ # extracts first element form <LLVM target>:<rust-target>:<CTARGET> |
502 |
+ local cross_llvm_target="${cross_target_spec%%:*}" |
503 |
+ # extracts toolchain triples, <rust-target>:<CTARGET> |
504 |
+ local cross_triples="${cross_target_spec#*:}" |
505 |
+ # extracts first element after before : separator |
506 |
+ local cross_rust_target="${cross_triples%%:*}" |
507 |
+ # extracts last element after : separator |
508 |
+ local cross_toolchain="${cross_triples##*:}" |
509 |
+ use llvm_targets_${cross_llvm_target} || die "need llvm_targets_${cross_llvm_target} target enabled" |
510 |
+ command -v ${cross_toolchain}-gcc > /dev/null 2>&1 || die "need ${cross_toolchain} cross toolchain" |
511 |
+ |
512 |
+ cat <<- _EOF_ >> "${S}"/config.toml |
513 |
+ [target.${cross_rust_target}] |
514 |
+ ar = "${cross_toolchain}-ar" |
515 |
+ cc = "${cross_toolchain}-gcc" |
516 |
+ cxx = "${cross_toolchain}-g++" |
517 |
+ linker = "${cross_toolchain}-gcc" |
518 |
+ ranlib = "${cross_toolchain}-ranlib" |
519 |
+ _EOF_ |
520 |
+ if use system-llvm; then |
521 |
+ cat <<- _EOF_ >> "${S}"/config.toml |
522 |
+ llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config" |
523 |
+ _EOF_ |
524 |
+ fi |
525 |
+ if [[ "${cross_toolchain}" == *-musl* ]]; then |
526 |
+ cat <<- _EOF_ >> "${S}"/config.toml |
527 |
+ musl-root = "$(${cross_toolchain}-gcc -print-sysroot)/usr" |
528 |
+ _EOF_ |
529 |
+ fi |
530 |
+ |
531 |
+ # append cross target to "normal" target list |
532 |
+ # example 'target = ["powerpc64le-unknown-linux-gnu"]' |
533 |
+ # becomes 'target = ["powerpc64le-unknown-linux-gnu","aarch64-unknown-linux-gnu"]' |
534 |
+ |
535 |
+ rust_targets="${rust_targets},\"${cross_rust_target}\"" |
536 |
+ sed -i "/^target = \[/ s#\[.*\]#\[${rust_targets}\]#" config.toml || die |
537 |
+ |
538 |
+ ewarn |
539 |
+ ewarn "Enabled ${cross_rust_target} rust target" |
540 |
+ ewarn "Using ${cross_toolchain} cross toolchain" |
541 |
+ ewarn |
542 |
+ if ! has_version -b 'sys-devel/binutils[multitarget]' ; then |
543 |
+ ewarn "'sys-devel/binutils[multitarget]' is not installed" |
544 |
+ ewarn "'strip' will be unable to strip cross libraries" |
545 |
+ ewarn "cross targets will be installed with full debug information" |
546 |
+ ewarn "enable 'multitarget' USE flag for binutils to be able to strip object files" |
547 |
+ ewarn |
548 |
+ ewarn "Alternatively llvm-strip can be used, it supports stripping any target" |
549 |
+ ewarn "define STRIP=\"llvm-strip\" to use it (experimental)" |
550 |
+ ewarn |
551 |
+ fi |
552 |
+ done |
553 |
+ fi # I_KNOW_WHAT_I_AM_DOING_CROSS |
554 |
+ |
555 |
+ einfo "Rust configured with the following flags:" |
556 |
+ echo |
557 |
+ echo RUSTFLAGS="${RUSTFLAGS:-}" |
558 |
+ echo RUSTFLAGS_BOOTSTRAP="${RUSTFLAGS_BOOTSTRAP:-}" |
559 |
+ echo RUSTFLAGS_NOT_BOOTSTRAP="${RUSTFLAGS_NOT_BOOTSTRAP:-}" |
560 |
+ env | grep "CARGO_TARGET_.*_RUSTFLAGS=" |
561 |
+ cat "${S}"/config.env || die |
562 |
+ echo |
563 |
+ einfo "config.toml contents:" |
564 |
+ cat "${S}"/config.toml || die |
565 |
+ echo |
566 |
+} |
567 |
+ |
568 |
+src_compile() { |
569 |
+ # we need \n IFS to have config.env with spaces loaded properly. #734018 |
570 |
+ ( |
571 |
+ IFS=$'\n' |
572 |
+ env $(cat "${S}"/config.env) RUST_BACKTRACE=1\ |
573 |
+ "${EPYTHON}" ./x.py build -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die |
574 |
+ ) |
575 |
+} |
576 |
+ |
577 |
+src_test() { |
578 |
+ # https://rustc-dev-guide.rust-lang.org/tests/intro.html |
579 |
+ |
580 |
+ # those are basic and codegen tests. |
581 |
+ local tests=( |
582 |
+ codegen |
583 |
+ codegen-units |
584 |
+ compile-fail |
585 |
+ incremental |
586 |
+ mir-opt |
587 |
+ pretty |
588 |
+ run-make |
589 |
+ ) |
590 |
+ |
591 |
+ # fails if llvm is not built with ALL targets. |
592 |
+ # and known to fail with system llvm sometimes. |
593 |
+ use system-llvm || tests+=( assembly ) |
594 |
+ |
595 |
+ # fragile/expensive/less important tests |
596 |
+ # or tests that require extra builds |
597 |
+ # TODO: instead of skipping, just make some nonfatal. |
598 |
+ if [[ ${ERUST_RUN_EXTRA_TESTS:-no} != no ]]; then |
599 |
+ tests+=( |
600 |
+ rustdoc |
601 |
+ rustdoc-js |
602 |
+ rustdoc-js-std |
603 |
+ rustdoc-ui |
604 |
+ run-make-fulldeps |
605 |
+ ui |
606 |
+ ui-fulldeps |
607 |
+ ) |
608 |
+ fi |
609 |
+ |
610 |
+ local i failed=() |
611 |
+ einfo "rust_src_test: enabled tests ${tests[@]/#/src/test/}" |
612 |
+ for i in "${tests[@]}"; do |
613 |
+ local t="src/test/${i}" |
614 |
+ einfo "rust_src_test: running ${t}" |
615 |
+ if ! ( |
616 |
+ IFS=$'\n' |
617 |
+ env $(cat "${S}"/config.env) RUST_BACKTRACE=1 \ |
618 |
+ "${EPYTHON}" ./x.py test -vv --config="${S}"/config.toml \ |
619 |
+ -j$(makeopts_jobs) --no-doc --no-fail-fast "${t}" |
620 |
+ ) |
621 |
+ then |
622 |
+ failed+=( "${t}" ) |
623 |
+ eerror "rust_src_test: ${t} failed" |
624 |
+ fi |
625 |
+ done |
626 |
+ |
627 |
+ if [[ ${#failed[@]} -ne 0 ]]; then |
628 |
+ eerror "rust_src_test: failure summary: ${failed[@]}" |
629 |
+ die "aborting due to test failures" |
630 |
+ fi |
631 |
+} |
632 |
+ |
633 |
+src_install() { |
634 |
+ ( |
635 |
+ IFS=$'\n' |
636 |
+ env $(cat "${S}"/config.env) DESTDIR="${D}" \ |
637 |
+ "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die |
638 |
+ ) |
639 |
+ |
640 |
+ # bug #689562, #689160 |
641 |
+ rm -v "${ED}/usr/lib/${PN}/${PV}/etc/bash_completion.d/cargo" || die |
642 |
+ rmdir -v "${ED}/usr/lib/${PN}/${PV}"/etc{/bash_completion.d,} || die |
643 |
+ newbashcomp src/tools/cargo/src/etc/cargo.bashcomp.sh cargo |
644 |
+ |
645 |
+ local symlinks=( |
646 |
+ cargo |
647 |
+ rustc |
648 |
+ rustdoc |
649 |
+ rust-gdb |
650 |
+ rust-gdbgui |
651 |
+ rust-lldb |
652 |
+ ) |
653 |
+ |
654 |
+ use clippy && symlinks+=( clippy-driver cargo-clippy ) |
655 |
+ use miri && symlinks+=( miri cargo-miri ) |
656 |
+ use rls && symlinks+=( rls ) |
657 |
+ use rustfmt && symlinks+=( rustfmt cargo-fmt ) |
658 |
+ |
659 |
+ einfo "installing eselect-rust symlinks and paths: ${symlinks[@]}" |
660 |
+ local i |
661 |
+ for i in "${symlinks[@]}"; do |
662 |
+ # we need realpath on /usr/bin/* symlink return version-appended binary path. |
663 |
+ # so /usr/bin/rustc should point to /usr/lib/rust/<ver>/bin/rustc-<ver> |
664 |
+ # need to fix eselect-rust to remove this hack. |
665 |
+ local ver_i="${i}-${PV}" |
666 |
+ if [[ -f "${ED}/usr/lib/${PN}/${PV}/bin/${i}" ]]; then |
667 |
+ einfo "Installing ${i} symlink" |
668 |
+ ln -v "${ED}/usr/lib/${PN}/${PV}/bin/${i}" "${ED}/usr/lib/${PN}/${PV}/bin/${ver_i}" || die |
669 |
+ else |
670 |
+ ewarn "${i} symlink requested, but source file not found" |
671 |
+ ewarn "please report this" |
672 |
+ fi |
673 |
+ dosym "../lib/${PN}/${PV}/bin/${ver_i}" "/usr/bin/${ver_i}" |
674 |
+ done |
675 |
+ |
676 |
+ # symlinks to switch components to active rust in eselect |
677 |
+ dosym "${PV}/lib" "/usr/lib/${PN}/lib-${PV}" |
678 |
+ dosym "${PV}/libexec" "/usr/lib/${PN}/libexec-${PV}" |
679 |
+ dosym "${PV}/share/man" "/usr/lib/${PN}/man-${PV}" |
680 |
+ dosym "rust/${PV}/lib/rustlib" "/usr/lib/rustlib-${PV}" |
681 |
+ dosym "../../lib/${PN}/${PV}/share/doc/rust" "/usr/share/doc/${P}" |
682 |
+ |
683 |
+ newenvd - "50${P}" <<-_EOF_ |
684 |
+ LDPATH="${EPREFIX}/usr/lib/rust/lib" |
685 |
+ MANPATH="${EPREFIX}/usr/lib/rust/man" |
686 |
+ $(use amd64 && usex elibc_musl 'CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=-crt-static"' '') |
687 |
+ $(use arm64 && usex elibc_musl 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C target-feature=-crt-static"' '') |
688 |
+ _EOF_ |
689 |
+ |
690 |
+ rm -rf "${ED}/usr/lib/${PN}/${PV}"/*.old || die |
691 |
+ rm -rf "${ED}/usr/lib/${PN}/${PV}/doc"/*.old || die |
692 |
+ |
693 |
+ # note: eselect-rust adds EROOT to all paths below |
694 |
+ cat <<-_EOF_ > "${T}/provider-${P}" |
695 |
+ /usr/bin/cargo |
696 |
+ /usr/bin/rustdoc |
697 |
+ /usr/bin/rust-gdb |
698 |
+ /usr/bin/rust-gdbgui |
699 |
+ /usr/bin/rust-lldb |
700 |
+ /usr/lib/rustlib |
701 |
+ /usr/lib/rust/lib |
702 |
+ /usr/lib/rust/libexec |
703 |
+ /usr/lib/rust/man |
704 |
+ /usr/share/doc/rust |
705 |
+ _EOF_ |
706 |
+ |
707 |
+ if use clippy; then |
708 |
+ echo /usr/bin/clippy-driver >> "${T}/provider-${P}" |
709 |
+ echo /usr/bin/cargo-clippy >> "${T}/provider-${P}" |
710 |
+ fi |
711 |
+ if use miri; then |
712 |
+ echo /usr/bin/miri >> "${T}/provider-${P}" |
713 |
+ echo /usr/bin/cargo-miri >> "${T}/provider-${P}" |
714 |
+ fi |
715 |
+ if use rls; then |
716 |
+ echo /usr/bin/rls >> "${T}/provider-${P}" |
717 |
+ fi |
718 |
+ if use rustfmt; then |
719 |
+ echo /usr/bin/rustfmt >> "${T}/provider-${P}" |
720 |
+ echo /usr/bin/cargo-fmt >> "${T}/provider-${P}" |
721 |
+ fi |
722 |
+ |
723 |
+ insinto /etc/env.d/rust |
724 |
+ doins "${T}/provider-${P}" |
725 |
+ |
726 |
+ if use dist; then |
727 |
+ insinto "/usr/lib/${PN}/${PV}/dist" |
728 |
+ doins -r "${S}/build/dist/." |
729 |
+ fi |
730 |
+} |
731 |
+ |
732 |
+pkg_postinst() { |
733 |
+ eselect rust update |
734 |
+ |
735 |
+ if has_version sys-devel/gdb || has_version dev-util/lldb; then |
736 |
+ elog "Rust installs a helper script for calling GDB and LLDB," |
737 |
+ elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}." |
738 |
+ fi |
739 |
+ |
740 |
+ if has_version app-editors/emacs; then |
741 |
+ elog "install app-emacs/rust-mode to get emacs support for rust." |
742 |
+ fi |
743 |
+ |
744 |
+ if has_version app-editors/gvim || has_version app-editors/vim; then |
745 |
+ elog "install app-vim/rust-vim to get vim support for rust." |
746 |
+ fi |
747 |
+} |
748 |
+ |
749 |
+pkg_postrm() { |
750 |
+ eselect rust cleanup |
751 |
+} |