1 |
commit: a0449fb463341e064a926929e1c6d1c22b963891 |
2 |
Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Dec 29 10:17:49 2019 +0000 |
4 |
Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Dec 30 09:58:30 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a0449fb4 |
7 |
|
8 |
dev-lang/rust: revbump 1.40.0 with fixes |
9 |
|
10 |
add parallel-compiler useflag, to use pass RUSTFLAGS=" -Zthreads=<num>" |
11 |
add debian soname patch |
12 |
add system-bootstrap |
13 |
install rustlib into /usr/lib unconditionally |
14 |
drop multilib hacks |
15 |
various minor fixes |
16 |
add myself to metadata.xml explicitly |
17 |
|
18 |
Bug: https://bugs.gentoo.org/694248 |
19 |
Bug: https://bugs.gentoo.org/703744 |
20 |
Bug: https://bugs.gentoo.org/703470 |
21 |
Package-Manager: Portage-2.3.84, Repoman-2.3.20 |
22 |
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org> |
23 |
|
24 |
dev-lang/rust/files/1.40.0-add-soname.patch | 36 +++ |
25 |
dev-lang/rust/metadata.xml | 6 + |
26 |
dev-lang/rust/rust-1.40.0-r1.ebuild | 340 ++++++++++++++++++++++++++++ |
27 |
3 files changed, 382 insertions(+) |
28 |
|
29 |
diff --git a/dev-lang/rust/files/1.40.0-add-soname.patch b/dev-lang/rust/files/1.40.0-add-soname.patch |
30 |
new file mode 100644 |
31 |
index 00000000000..7a5c0189c68 |
32 |
--- /dev/null |
33 |
+++ b/dev-lang/rust/files/1.40.0-add-soname.patch |
34 |
@@ -0,0 +1,36 @@ |
35 |
+Description: Set DT_SONAME when building dylibs |
36 |
+ In Rust, library filenames include a version-specific hash to help |
37 |
+ the run-time linker find the correct version. Unlike in C/C++, the |
38 |
+ compiler looks for all libraries matching a glob that ignores the |
39 |
+ hash and reads embedded metadata to work out versions, etc. |
40 |
+ . |
41 |
+ The upshot is that there is no need for the usual "libfoo.so -> |
42 |
+ libfoo-1.2.3.so" symlink common with C/C++ when building with Rust, |
43 |
+ and no need to communicate an alternate filename to use at run-time |
44 |
+ vs compile time. If linking to a Rust dylib from C/C++ however, a |
45 |
+ "libfoo.so -> libfoo-$hash.so" symlink may well be useful and in |
46 |
+ this case DT_SONAME=libfoo-$hash.so would be required. More |
47 |
+ mundanely, various tools (eg: dpkg-shlibdeps) complain if they don't |
48 |
+ find DT_SONAME on shared libraries in public directories. |
49 |
+ . |
50 |
+ This patch passes -Wl,-soname=$outfile when building dylibs (and |
51 |
+ using a GNU linker). |
52 |
+Author: Angus Lees <gus@××××××.org> |
53 |
+Forwarded: no |
54 |
+ |
55 |
+--- a/src/librustc_codegen_ssa/back/link.rs |
56 |
++++ b/src/librustc_codegen_ssa/back/link.rs |
57 |
+@@ -1034,6 +1034,13 @@ |
58 |
+ cmd.args(&rpath::get_rpath_flags(&mut rpath_config)); |
59 |
+ } |
60 |
+ |
61 |
++ if (crate_type == config::CrateType::Dylib || crate_type == config::CrateType::Cdylib) |
62 |
++ && t.options.linker_is_gnu { |
63 |
++ let filename = String::from(out_filename.file_name().unwrap().to_str().unwrap()); |
64 |
++ let soname = [String::from("-Wl,-soname=") + &filename]; |
65 |
++ cmd.args(&soname); |
66 |
++ } |
67 |
++ |
68 |
+ // Finally add all the linker arguments provided on the command line along |
69 |
+ // with any #[link_args] attributes found inside the crate |
70 |
+ if let Some(ref args) = sess.opts.cg.link_args { |
71 |
|
72 |
diff --git a/dev-lang/rust/metadata.xml b/dev-lang/rust/metadata.xml |
73 |
index 17963dc4e81..70279a4bbfd 100644 |
74 |
--- a/dev-lang/rust/metadata.xml |
75 |
+++ b/dev-lang/rust/metadata.xml |
76 |
@@ -1,6 +1,10 @@ |
77 |
<?xml version="1.0" encoding="UTF-8"?> |
78 |
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
79 |
<pkgmetadata> |
80 |
+ <maintainer type="person"> |
81 |
+ <email>gyakovlev@g.o</email> |
82 |
+ <name>Georgy Yakovlev</name> |
83 |
+ </maintainer> |
84 |
<maintainer type="project"> |
85 |
<email>rust@g.o</email> |
86 |
<name>Rust Project</name> |
87 |
@@ -9,8 +13,10 @@ |
88 |
<flag name="clippy">Install clippy component</flag> |
89 |
<flag name="system-llvm">Use the system LLVM install</flag> |
90 |
<flag name="nightly">Enable nightly (UNSTABLE) features</flag> |
91 |
+ <flag name="parallel-compiler">Build a multi-threaded rustc</flag> |
92 |
<flag name="rls">Install rls component</flag> |
93 |
<flag name="rustfmt">Install rustfmt component</flag> |
94 |
+ <flag name="system-bootstrap">Bootstrap using installed rust compiler</flag> |
95 |
<flag name="wasm">Build support for the wasm32-unknown-unknown |
96 |
target</flag> |
97 |
</use> |
98 |
|
99 |
diff --git a/dev-lang/rust/rust-1.40.0-r1.ebuild b/dev-lang/rust/rust-1.40.0-r1.ebuild |
100 |
new file mode 100644 |
101 |
index 00000000000..aa528ebe857 |
102 |
--- /dev/null |
103 |
+++ b/dev-lang/rust/rust-1.40.0-r1.ebuild |
104 |
@@ -0,0 +1,340 @@ |
105 |
+# Copyright 1999-2019 Gentoo Authors |
106 |
+# Distributed under the terms of the GNU General Public License v2 |
107 |
+ |
108 |
+EAPI=7 |
109 |
+ |
110 |
+PYTHON_COMPAT=( python2_7 python3_{5,6,7} pypy ) |
111 |
+ |
112 |
+inherit bash-completion-r1 check-reqs estack flag-o-matic llvm multiprocessing multilib-build python-any-r1 rust-toolchain toolchain-funcs |
113 |
+ |
114 |
+if [[ ${PV} = *beta* ]]; then |
115 |
+ betaver=${PV//*beta} |
116 |
+ BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}" |
117 |
+ MY_P="rustc-beta" |
118 |
+ SLOT="beta/${PV}" |
119 |
+ SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz" |
120 |
+else |
121 |
+ ABI_VER="$(ver_cut 1-2)" |
122 |
+ SLOT="stable/${ABI_VER}" |
123 |
+ MY_P="rustc-${PV}" |
124 |
+ SRC="${MY_P}-src.tar.xz" |
125 |
+ KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86" |
126 |
+fi |
127 |
+ |
128 |
+RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0" |
129 |
+ |
130 |
+DESCRIPTION="Systems programming language from Mozilla" |
131 |
+HOMEPAGE="https://www.rust-lang.org/" |
132 |
+ |
133 |
+SRC_URI=" |
134 |
+ https://static.rust-lang.org/dist/${SRC} -> rustc-${PV}-src.tar.xz |
135 |
+ !system-bootstrap? ( $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION}) ) |
136 |
+" |
137 |
+ |
138 |
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 |
139 |
+ NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore ) |
140 |
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
141 |
+LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?} |
142 |
+ |
143 |
+LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA" |
144 |
+ |
145 |
+IUSE="clippy cpu_flags_x86_sse2 debug doc libressl nightly parallel-compiler rls rustfmt system-bootstrap system-llvm wasm ${ALL_LLVM_TARGETS[*]}" |
146 |
+ |
147 |
+# Please keep the LLVM dependency block separate. Since LLVM is slotted, |
148 |
+# we need to *really* make sure we're not pulling more than one slot |
149 |
+# simultaneously. |
150 |
+ |
151 |
+# How to use it: |
152 |
+# 1. List all the working slots (with min versions) in ||, newest first. |
153 |
+# 2. Update the := to specify *max* version, e.g. < 10. |
154 |
+# 3. Specify LLVM_MAX_SLOT, e.g. 9. |
155 |
+LLVM_DEPEND=" |
156 |
+ || ( |
157 |
+ sys-devel/llvm:9[llvm_targets_WebAssembly?] |
158 |
+ wasm? ( =sys-devel/lld-9* ) |
159 |
+ ) |
160 |
+ <sys-devel/llvm-10:= |
161 |
+" |
162 |
+LLVM_MAX_SLOT=9 |
163 |
+ |
164 |
+# FIXME: |
165 |
+# this should be '>=virtual/rust-1.$(($(ver_cut 2) - 1))', but we can't do it yet |
166 |
+# as the first gentoo-built rust that can bootstap new compiler is 1.40.0-r1 |
167 |
+BOOTSTRAP_DEPEND="|| ( =dev-lang/rust-${PF} =dev-lang/rust-bin-${PV}* )" |
168 |
+ |
169 |
+COMMON_DEPEND=" |
170 |
+ sys-libs/zlib |
171 |
+ !libressl? ( dev-libs/openssl:0= ) |
172 |
+ libressl? ( dev-libs/libressl:0= ) |
173 |
+ net-libs/libssh2 |
174 |
+ net-libs/http-parser:= |
175 |
+ net-misc/curl[ssl] |
176 |
+ system-llvm? ( |
177 |
+ ${LLVM_DEPEND} |
178 |
+ dev-util/cmake |
179 |
+ dev-util/ninja |
180 |
+ ) |
181 |
+" |
182 |
+ |
183 |
+DEPEND="${COMMON_DEPEND} |
184 |
+ ${PYTHON_DEPS} |
185 |
+ || ( |
186 |
+ >=sys-devel/gcc-4.7 |
187 |
+ >=sys-devel/clang-3.5 |
188 |
+ ) |
189 |
+ system-bootstrap? ( ${BOOTSTRAP_DEPEND} ) |
190 |
+" |
191 |
+ |
192 |
+RDEPEND="${COMMON_DEPEND} |
193 |
+ >=app-eselect/eselect-rust-20190311 |
194 |
+" |
195 |
+ |
196 |
+REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} ) |
197 |
+ parallel-compiler? ( nightly ) |
198 |
+ wasm? ( llvm_targets_WebAssembly ) |
199 |
+ x86? ( cpu_flags_x86_sse2 ) |
200 |
+" |
201 |
+ |
202 |
+QA_FLAGS_IGNORED=" |
203 |
+ usr/bin/*-${PV} |
204 |
+ usr/lib*/lib*.so |
205 |
+ usr/lib/rurstlib/*/codegen-backends/librustc_codegen_llvm-llvm.so |
206 |
+ usr/lib/rustlib/*/lib/lib*.so |
207 |
+" |
208 |
+ |
209 |
+QA_SONAME="usr/lib*/librustc_macros*.so" |
210 |
+ |
211 |
+PATCHES=( |
212 |
+ "${FILESDIR}"/1.36.0-libressl.patch |
213 |
+ "${FILESDIR}"/1.40.0-add-soname.patch |
214 |
+) |
215 |
+ |
216 |
+S="${WORKDIR}/${MY_P}-src" |
217 |
+ |
218 |
+toml_usex() { |
219 |
+ usex "$1" true false |
220 |
+} |
221 |
+ |
222 |
+pre_build_checks() { |
223 |
+ CHECKREQS_DISK_BUILD="9G" |
224 |
+ eshopts_push -s extglob |
225 |
+ if is-flagq '-g?(gdb)?([1-9])'; then |
226 |
+ CHECKREQS_DISK_BUILD="14G" |
227 |
+ fi |
228 |
+ eshopts_pop |
229 |
+ check-reqs_pkg_setup |
230 |
+} |
231 |
+ |
232 |
+pkg_pretend() { |
233 |
+ pre_build_checks |
234 |
+} |
235 |
+ |
236 |
+pkg_setup() { |
237 |
+ pre_build_checks |
238 |
+ python-any-r1_pkg_setup |
239 |
+ use system-llvm && llvm_pkg_setup |
240 |
+} |
241 |
+ |
242 |
+src_prepare() { |
243 |
+ if ! use system-bootstrap; then |
244 |
+ local rust_stage0_root="${WORKDIR}"/rust-stage0 |
245 |
+ local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)" |
246 |
+ |
247 |
+ "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig \ |
248 |
+ --destdir="${rust_stage0_root}" --prefix=/ || die |
249 |
+ fi |
250 |
+ |
251 |
+ default |
252 |
+} |
253 |
+ |
254 |
+src_configure() { |
255 |
+ local rust_target="" rust_targets="" arch_cflags |
256 |
+ |
257 |
+ # Collect rust target names to compile standard libs for all ABIs. |
258 |
+ for v in $(multilib_get_enabled_abi_pairs); do |
259 |
+ rust_targets="${rust_targets},\"$(rust_abi $(get_abi_CHOST ${v##*.}))\"" |
260 |
+ done |
261 |
+ if use wasm; then |
262 |
+ rust_targets="${rust_targets},\"wasm32-unknown-unknown\"" |
263 |
+ fi |
264 |
+ rust_targets="${rust_targets#,}" |
265 |
+ |
266 |
+ local extended="true" tools="\"cargo\"," |
267 |
+ if use clippy; then |
268 |
+ tools="\"clippy\",$tools" |
269 |
+ fi |
270 |
+ if use rls; then |
271 |
+ tools="\"rls\",\"analysis\",\"src\",$tools" |
272 |
+ fi |
273 |
+ if use rustfmt; then |
274 |
+ tools="\"rustfmt\",$tools" |
275 |
+ fi |
276 |
+ |
277 |
+ local rust_stage0_root |
278 |
+ if use system-bootstrap; then |
279 |
+ rust_stage0_root="$(rustc --print sysroot)" |
280 |
+ else |
281 |
+ rust_stage0_root="${WORKDIR}"/rust-stage0 |
282 |
+ fi |
283 |
+ |
284 |
+ rust_target="$(rust_abi)" |
285 |
+ |
286 |
+ cat <<- EOF > "${S}"/config.toml |
287 |
+ [llvm] |
288 |
+ optimize = $(toml_usex !debug) |
289 |
+ release-debuginfo = $(toml_usex debug) |
290 |
+ assertions = $(toml_usex debug) |
291 |
+ targets = "${LLVM_TARGETS// /;}" |
292 |
+ experimental-targets = "" |
293 |
+ link-shared = $(toml_usex system-llvm) |
294 |
+ [build] |
295 |
+ build = "${rust_target}" |
296 |
+ host = ["${rust_target}"] |
297 |
+ target = [${rust_targets}] |
298 |
+ cargo = "${rust_stage0_root}/bin/cargo" |
299 |
+ rustc = "${rust_stage0_root}/bin/rustc" |
300 |
+ docs = $(toml_usex doc) |
301 |
+ compiler-docs = $(toml_usex doc) |
302 |
+ submodules = false |
303 |
+ python = "${EPYTHON}" |
304 |
+ locked-deps = true |
305 |
+ vendor = true |
306 |
+ extended = ${extended} |
307 |
+ tools = [${tools}] |
308 |
+ verbose = 2 |
309 |
+ [install] |
310 |
+ prefix = "${EPREFIX}/usr" |
311 |
+ libdir = "lib" |
312 |
+ docdir = "share/doc/${PF}" |
313 |
+ mandir = "share/man" |
314 |
+ [rust] |
315 |
+ optimize = $(toml_usex !debug) |
316 |
+ debug = $(toml_usex debug) |
317 |
+ debug-assertions = $(toml_usex debug) |
318 |
+ default-linker = "$(tc-getCC)" |
319 |
+ parallel-compiler = $(toml_usex parallel-compiler) |
320 |
+ channel = "$(usex nightly nightly stable)" |
321 |
+ rpath = false |
322 |
+ lld = $(usex system-llvm false $(toml_usex wasm)) |
323 |
+ [dist] |
324 |
+ src-tarball = false |
325 |
+ EOF |
326 |
+ |
327 |
+ for v in $(multilib_get_enabled_abi_pairs); do |
328 |
+ rust_target=$(rust_abi $(get_abi_CHOST ${v##*.})) |
329 |
+ arch_cflags="$(get_abi_CFLAGS ${v##*.})" |
330 |
+ |
331 |
+ cat <<- EOF >> "${S}"/config.env |
332 |
+ CFLAGS_${rust_target}=${arch_cflags} |
333 |
+ EOF |
334 |
+ |
335 |
+ cat <<- EOF >> "${S}"/config.toml |
336 |
+ [target.${rust_target}] |
337 |
+ cc = "$(tc-getBUILD_CC)" |
338 |
+ cxx = "$(tc-getBUILD_CXX)" |
339 |
+ linker = "$(tc-getCC)" |
340 |
+ ar = "$(tc-getAR)" |
341 |
+ EOF |
342 |
+ if use system-llvm; then |
343 |
+ cat <<- EOF >> "${S}"/config.toml |
344 |
+ llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config" |
345 |
+ EOF |
346 |
+ fi |
347 |
+ done |
348 |
+ |
349 |
+ if use wasm; then |
350 |
+ cat <<- EOF >> "${S}"/config.toml |
351 |
+ [target.wasm32-unknown-unknown] |
352 |
+ linker = "$(usex system-llvm lld rust-lld)" |
353 |
+ EOF |
354 |
+ fi |
355 |
+} |
356 |
+ |
357 |
+src_compile() { |
358 |
+ env $(cat "${S}"/config.env)\ |
359 |
+ "${EPYTHON}" ./x.py build -vv --config="${S}"/config.toml -j$(makeopts_jobs) \ |
360 |
+ --exclude src/tools/miri || die # https://github.com/rust-lang/rust/issues/52305 |
361 |
+} |
362 |
+ |
363 |
+src_install() { |
364 |
+ env DESTDIR="${D}" "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml \ |
365 |
+ --exclude src/tools/miri || die |
366 |
+ |
367 |
+ # bug #689562, #689160 |
368 |
+ rm "${D}/etc/bash_completion.d/cargo" || die |
369 |
+ rmdir "${D}"/etc{/bash_completion.d,} || die |
370 |
+ dobashcomp build/tmp/dist/cargo-image/etc/bash_completion.d/cargo |
371 |
+ |
372 |
+ mv "${ED}/usr/bin/rustc" "${ED}/usr/bin/rustc-${PV}" || die |
373 |
+ mv "${ED}/usr/bin/rustdoc" "${ED}/usr/bin/rustdoc-${PV}" || die |
374 |
+ mv "${ED}/usr/bin/rust-gdb" "${ED}/usr/bin/rust-gdb-${PV}" || die |
375 |
+ mv "${ED}/usr/bin/rust-gdbgui" "${ED}/usr/bin/rust-gdbgui-${PV}" || die |
376 |
+ mv "${ED}/usr/bin/rust-lldb" "${ED}/usr/bin/rust-lldb-${PV}" || die |
377 |
+ mv "${ED}/usr/bin/cargo" "${ED}/usr/bin/cargo-${PV}" || die |
378 |
+ if use clippy; then |
379 |
+ mv "${ED}/usr/bin/clippy-driver" "${ED}/usr/bin/clippy-driver-${PV}" || die |
380 |
+ mv "${ED}/usr/bin/cargo-clippy" "${ED}/usr/bin/cargo-clippy-${PV}" || die |
381 |
+ fi |
382 |
+ if use rls; then |
383 |
+ mv "${ED}/usr/bin/rls" "${ED}/usr/bin/rls-${PV}" || die |
384 |
+ fi |
385 |
+ if use rustfmt; then |
386 |
+ mv "${ED}/usr/bin/rustfmt" "${ED}/usr/bin/rustfmt-${PV}" || die |
387 |
+ mv "${ED}/usr/bin/cargo-fmt" "${ED}/usr/bin/cargo-fmt-${PV}" || die |
388 |
+ fi |
389 |
+ |
390 |
+ # Move public shared libs to abi specific libdir |
391 |
+ # Private and target specific libs MUST stay in /usr/lib/rustlib/${rust_target}/lib |
392 |
+ if [[ $(get_libdir) != lib ]]; then |
393 |
+ dodir /usr/$(get_libdir) |
394 |
+ mv "${ED}/usr/lib"/*.so "${ED}/usr/$(get_libdir)/" || die |
395 |
+ fi |
396 |
+ |
397 |
+ dodoc COPYRIGHT |
398 |
+ |
399 |
+ # note: eselect-rust adds EROOT to all paths below |
400 |
+ cat <<-EOF > "${T}/provider-${P}" |
401 |
+ /usr/bin/rustdoc |
402 |
+ /usr/bin/rust-gdb |
403 |
+ /usr/bin/rust-gdbgui |
404 |
+ /usr/bin/rust-lldb |
405 |
+ EOF |
406 |
+ echo /usr/bin/cargo >> "${T}/provider-${P}" |
407 |
+ if use clippy; then |
408 |
+ echo /usr/bin/clippy-driver >> "${T}/provider-${P}" |
409 |
+ echo /usr/bin/cargo-clippy >> "${T}/provider-${P}" |
410 |
+ fi |
411 |
+ if use rls; then |
412 |
+ echo /usr/bin/rls >> "${T}/provider-${P}" |
413 |
+ fi |
414 |
+ if use rustfmt; then |
415 |
+ echo /usr/bin/rustfmt >> "${T}/provider-${P}" |
416 |
+ echo /usr/bin/cargo-fmt >> "${T}/provider-${P}" |
417 |
+ fi |
418 |
+ dodir /etc/env.d/rust |
419 |
+ insinto /etc/env.d/rust |
420 |
+ doins "${T}/provider-${P}" |
421 |
+} |
422 |
+ |
423 |
+pkg_postinst() { |
424 |
+ eselect rust update --if-unset |
425 |
+ |
426 |
+ elog "Rust installs a helper script for calling GDB and LLDB," |
427 |
+ elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}." |
428 |
+ |
429 |
+ ewarn "cargo is now installed from dev-lang/rust{,-bin} instead of dev-util/cargo." |
430 |
+ ewarn "This might have resulted in a dangling symlink for /usr/bin/cargo on some" |
431 |
+ ewarn "systems. This can be resolved by calling 'sudo eselect rust set ${P}'." |
432 |
+ |
433 |
+ if has_version app-editors/emacs; then |
434 |
+ elog "install app-emacs/rust-mode to get emacs support for rust." |
435 |
+ fi |
436 |
+ |
437 |
+ if has_version app-editors/gvim || has_version app-editors/vim; then |
438 |
+ elog "install app-vim/rust-vim to get vim support for rust." |
439 |
+ fi |
440 |
+} |
441 |
+ |
442 |
+pkg_postrm() { |
443 |
+ eselect rust cleanup |
444 |
+} |