Gentoo Archives: gentoo-commits

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/files/, dev-lang/rust/
Date: Thu, 26 Sep 2019 22:06:56
Message-Id: 1569535597.d7c507ec43a21a951774add8a4a92680e5d8f4b3.gyakovlev@gentoo
1 commit: d7c507ec43a21a951774add8a4a92680e5d8f4b3
2 Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
3 AuthorDate: Thu Sep 26 21:58:56 2019 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 26 22:06:37 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d7c507ec
7
8 dev-lang/rust: bump to 1.38.0
9
10 Package-Manager: Portage-2.3.76, Repoman-2.3.17
11 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
12
13 dev-lang/rust/Manifest | 14 +
14 dev-lang/rust/files/1.38.0-fix-custom-libdir.patch | 90 ++++++
15 .../files/1.38.0-fix-multiple-llvm-rebuilds.patch | 75 +++++
16 dev-lang/rust/rust-1.38.0.ebuild | 327 +++++++++++++++++++++
17 4 files changed, 506 insertions(+)
18
19 diff --git a/dev-lang/rust/Manifest b/dev-lang/rust/Manifest
20 index fa10664a6c4..56ecbd36bd4 100644
21 --- a/dev-lang/rust/Manifest
22 +++ b/dev-lang/rust/Manifest
23 @@ -50,7 +50,21 @@ DIST rust-1.36.0-powerpc64-unknown-linux-gnu.tar.xz 145880928 BLAKE2B 4922df3a7d
24 DIST rust-1.36.0-powerpc64le-unknown-linux-gnu.tar.xz 149721676 BLAKE2B e00bcc60a89354f6d4b5c89feffe5fe6dd7bf25d8dd2db2878e7c12ffc484e9258f37d80bda2b12f3965d96c73f1a03b6adbd8c20176c383e04f1a229d47d000 SHA512 02f32b544b0a55ba6f6fc4852f18766107bc0ce2c50488db11605e8a10e5965dd44e8332905c00080b08576370f2f0297ecbe12ba9fe01b4c24cdb9fd03ad64f
25 DIST rust-1.36.0-s390x-unknown-linux-gnu.tar.xz 159518028 BLAKE2B c5876ea15c9fa56a92b4c0bf2aab472b83381a7a31fbb207e4165fdc49fea2150dddd53cc771dbcb81b01fe43a3175df146d8645d04c556af3556822fc59bf25 SHA512 c637b8f50cbce3333280f43ce4b97d3f75ddae429ee34461837c3c3869e20aed8c5e76f7a58998f617dc0ffc2e6afd00908e5de05f4c7ed9a8c34d5dbc7ce916
26 DIST rust-1.36.0-x86_64-unknown-linux-gnu.tar.xz 169600936 BLAKE2B 8bf075f2b5624e4716e3058512b85b70e72ec6f0c8ce8fc38857612b02aa5702a1bb447f13f882a1b96b1f32330d0a8f7f1f1db81827b51cb7429195e070a5a3 SHA512 3f14dda1e09ef8c8168600f4d70ba60cb2a1086ad9edb5eed708d0ffc16fdb9c582ce350a93afcd64b78f87737e37d4f099703835a1ec9837a5721c2335e17c7
27 +DIST rust-1.37.0-aarch64-unknown-linux-gnu.tar.xz 124322996 BLAKE2B 732dc36933682a18bcd5694b1715af5c442452df8232e2affda8185b9aaf0daf297cf7c4a64fc7d35898e1b3829ba9e8fbe33e8c8f7bc6183b3149f983208ba8 SHA512 c70054f589aa2aecfbd6a89f567306e0cf5d3eb56e5a544ced0a5d212f14033dab10559d22dd6b07945e45a25d8de14fc7897c9d24c0d8149548a06b404ca9d2
28 +DIST rust-1.37.0-arm-unknown-linux-gnueabi.tar.xz 124741032 BLAKE2B 88e38ea9152546c8a04bd6f93fa8d97d3e58255568a522d2774a2656a4c6dd7bad74633a10b424f6c5f6ca07ea07e473e620ab24dfdbe5c27bb5141ab0f5bba8 SHA512 bd28b8bb60b8e4373693ad9d41bfe62eb12a7272a5d7978691b0c7e1892a2df8d6ff8cf5c25dab805fab1d03dd17c76c1014d395b042118cb24603739c6dbb32
29 +DIST rust-1.37.0-arm-unknown-linux-gnueabihf.tar.xz 124971492 BLAKE2B 07614242bc500c9ca81a87ed81cc0bada9b467049b7bc2afbe6245b742ac2bec9030feb08f0ef8a2402bf2c2a19722b8b06dacd0ef56edb0522bf41e29080a01 SHA512 e380e2bf862a157cb5e06d27fa8e306474e708ce7e0ffd087531a4fa5729bef104131c256625c05515f6e7dfd43f639ce1fd5e05a2da42ad7f437d578b4acd8a
30 +DIST rust-1.37.0-armv7-unknown-linux-gnueabihf.tar.xz 126583596 BLAKE2B f836c88801bde52c43726fb728d03b5f145b511a7a4b3d857de0218b87c83a4a2c939b9956aa61cef362a255209ea9e5159d2ac00edea2b9656ef320875f79a2 SHA512 6d9e055f36a2e912f30bebb25afdd3188019a438f208d3db67b38078bd5c37633c38fd48da15ba80640399babf89221e727a2bf43990aee269fcc5c91cd412b4
31 +DIST rust-1.37.0-i686-unknown-linux-gnu.tar.xz 177419360 BLAKE2B 4b28b002f0db349f9d12f2e4ae63b3fb5e9f472ec4d32d671626a56377cb87b07efd884ef3f4b23cca7072818c597fa8c693f55fd30ced5b408e8c0b0081af29 SHA512 b59377350f82efd10c7afe0f7a28ecbd5355719d841d40c98bec0f01961233f7a19bed2581a111a76cde8dd8dc68a019fa7d3da66cb7ebcb002ba52a14a7e573
32 +DIST rust-1.37.0-mips-unknown-linux-gnu.tar.xz 124577076 BLAKE2B 299d2b650c8236b94079ce4895e020bf2fe6c5d9b768da47d9716010eaa024c6b8ea743ddc7fadd660a9e49f65a02a8d0da7853cbff2bb6b43bb7771d3d42149 SHA512 1b71e1840470f7dd44cda177b7abf1cdc3f63db547fa36657b9fe5030a3d363afe1fa3ff8566351910daeef91ab4b33be46ef117342b4660fa23f76bee0ace00
33 +DIST rust-1.37.0-mips64-unknown-linux-gnuabi64.tar.xz 124565528 BLAKE2B e5bd6241ca7f2356638d39e18a71e577972143f37aa05e00e965bcce742828f25adf0f5cd6334c430d464e51b4112baeceb44a9eb41713233df6942b077983bb SHA512 1002173e608d29a2d32a6479a5c530d36e18bcce9e0813607369d3173c49b019a69ef05e8f1aba9b232285529f72837dfa8f4400866c49b6450e0f53028ebab1
34 +DIST rust-1.37.0-mipsel-unknown-linux-gnu.tar.xz 126620196 BLAKE2B 9174e7a48ba9e0f0bc2fc023991f6005614310a8db76824f5e733b0d8c4eaec6729c00b92e1c45f82fbb77f573c4bdc71004e887b9a170dc88c1a3f6e5ec0ccc SHA512 41f17b2f9bef0d5453153660d0f49aa0c8df0bfd003abac46728a477d3c00f67f5b1460aa851a92605fd628bf9dc18d9b44a16dbfc8fff22d84fd2a0a58b971e
35 +DIST rust-1.37.0-powerpc-unknown-linux-gnu.tar.xz 124035536 BLAKE2B 2b0b2c34cbe929ff4632e13b41670fa25e765a8b954c3226da67e098a06bb59c1d2387bf64beddaa554e439dd1549dcb529048bcb1e0f00998aee7bf302d6f6c SHA512 54b08c4a5523749ee5054e000f82ffc7ec29562d1194fbc311bee0e953c49eead3c851dcaf34803bb8eb997550a64ec784f40927f52d33b18ceee7c921c0eed0
36 +DIST rust-1.37.0-powerpc64-unknown-linux-gnu.tar.xz 128662180 BLAKE2B 0df1def64d07b3eabf1aa6c993c7a01b596119abf60b1a3e3e6663b1bb3c6a945146c9cd639ee7d57462e1cbb866badfa83abb7b52b36de4b089552f624c2245 SHA512 e8e5cf1c64bd3eec389cef022e1c7bae4618fb6966505d2e762d10e7f443fece43b8b95c989c020bdf739abaf9c3f036230df46f6477a2ccd517a7bdef2ba0d7
37 +DIST rust-1.37.0-powerpc64le-unknown-linux-gnu.tar.xz 131763436 BLAKE2B 76b9120e98da09344ce5af39a9b333c6ca8917516ae7108d6cc129fdda4d4d6c21e2ca4c41533e202f63b992bcede5390ec986a262ea216c1340a82c5ba798e8 SHA512 366c8920448000bfb4baa3a47588a1c7bc81e18afb8d40f0efc824e429e9e6900efbdb4c9003fb45b9d8595328bd612bd63f390a7d3dedbb30b7dc57fc12abf3
38 +DIST rust-1.37.0-s390x-unknown-linux-gnu.tar.xz 141808296 BLAKE2B 73825a004be81cca4dfff1301ea0ef45c9f55ab8d9a9a0343585377d83c4bdc03d3c027622f18e144c9355afe6f5236a6273f84b43b01a221066d3c395f71017 SHA512 14f403d3ce9df2a2baba1db13c9f039d7118d7e0c8285ca19ea0284c32e80c3f786660dedef4d1758b2227f91732b8e7deccbf3f38c2b3491738c1408d6bfd0e
39 +DIST rust-1.37.0-x86_64-unknown-linux-gnu.tar.xz 165034364 BLAKE2B 3047fff28da00e01179d3a648cb4e5636fa15ac7f4cb9ddc14e1df86d045b69ff3e41691b4a6ef4227c4cb58137524c5e029ba21a2c3a3a171fdb6f46b44f4ff SHA512 c4d48aa12cb929d6600f9cce81bb612c504aa1b3b3f8e76352af3a76b737dcbe0d31e8d139c17884b11aef9f12a55c4908fb8f3ff63dfa92533e4bd0a729914f
40 DIST rustc-1.34.2-src.tar.xz 95048792 BLAKE2B e81e4bfda87ddfb09ab8a74792346970aa440c678d2bb1279c329db4929282f761ada6fea9d81ceeecfd513613025c8e636487626fc36bd0b33559e045bb1b15 SHA512 f1bd2b226d90aae8a4657e6117b9a8451d4ce8129f79cc0fce0da7613a3b7800e690bc0ede8fec20a2f5f32c13fa8e22ac97d3838e0d36936793535a75d9c381
41 DIST rustc-1.35.0-src.tar.xz 96543548 BLAKE2B 0291152f2b7aa8b50b22d74afbd9c7654bab8ae7dcb76224dbff43bc39a3b918ff86bfd20f408a9a16da8b20b08d9f0289bb63620f093d25d9fa008de57f52c3 SHA512 477c10b780bd54776be7ecbda0ab970416253e4a87c3e701825a7d07bcbcd91601b8e61129c5d04d4259e89c2e81e87cdbdee853375a8de5c9cf8372be2c9129
42 DIST rustc-1.36.0-src.tar.xz 98707920 BLAKE2B caff82482589941ab63be51eeffdf2a0419c1b624485240a0547b4bebc9f64f6c65a4babb960d1b23b3cde76550390d6d4813e1e9a9c43bf325998c87832fb94 SHA512 1adbb3b67d599f926dc19258e2596cb3b990e152e75e71645637098526207aa5632d7915fd5b67c7a045f63860cc7be3d28be014ad6141a342adc16b2fe8a879
43 DIST rustc-1.37.0-src.tar.xz 98654252 BLAKE2B ddee92c7959a0e1ee11ffe5ded6017703cfac7bbf2a00dc46c37ed28f1cd1d31e1d5b62cc1a5ae2d55d64f8705d0cb282f4968deddf36c3152e5e0cfdfbea67d SHA512 bfee43f578e6d44ead950b870b9fd31087e1bd3f917611f5dce7ad56504b83185edf43e297e8d1304e9e97b9a580d1e6adf6608ab8ed6dee0dc8c5153cdbc5d4
44 +DIST rustc-1.38.0-src.tar.xz 96163304 BLAKE2B 1e900b44db64727477ccf8e58e0ebb9ec209bbeb349816b5f7937e58c165db8befae33c5667732e5aaaa677c5a6c1e0229d9969ab8967fda9b8d7a593e6c5eb6 SHA512 b756d29a7a222bc7b5c7f42ff397346ab840f78e559f93e6e36b65e76eea525cf429899fe4de9fb8966623a2225b552feef9fa831bee50f9e25c976fa2af8c0a
45
46 diff --git a/dev-lang/rust/files/1.38.0-fix-custom-libdir.patch b/dev-lang/rust/files/1.38.0-fix-custom-libdir.patch
47 new file mode 100644
48 index 00000000000..b2b14876c90
49 --- /dev/null
50 +++ b/dev-lang/rust/files/1.38.0-fix-custom-libdir.patch
51 @@ -0,0 +1,90 @@
52 +From 8553cc0681db7fb6b58b25bb3fbd520604a0cc3a Mon Sep 17 00:00:00 2001
53 +From: O01eg <o01eg@××××××.ru>
54 +Date: Wed, 7 Aug 2019 23:37:55 +0300
55 +Subject: [PATCH] Fix double resolving custom libdir
56 +
57 +---
58 + src/bootstrap/builder.rs | 20 +++++++++++++-------
59 + src/bootstrap/dist.rs | 13 +++++++++----
60 + 2 files changed, 22 insertions(+), 11 deletions(-)
61 +
62 +diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
63 +index 5a75497173eb..06ccdd8e7f0f 100644
64 +--- a/src/bootstrap/builder.rs
65 ++++ b/src/bootstrap/builder.rs
66 +@@ -627,13 +627,7 @@ impl<'a> Builder<'a> {
67 + }
68 +
69 + fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
70 +- let compiler = self.compiler;
71 +- let config = &builder.build.config;
72 +- let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() {
73 +- builder.build.config.libdir_relative().unwrap()
74 +- } else {
75 +- Path::new("lib")
76 +- };
77 ++ let lib = builder.sysroot_libdir_relative(self.compiler);
78 + let sysroot = builder
79 + .sysroot(self.compiler)
80 + .join(lib)
81 +@@ -687,6 +681,18 @@ impl<'a> Builder<'a> {
82 + }
83 + }
84 +
85 ++ /// Returns the compiler's relative libdir where the standard library and other artifacts are
86 ++ /// found for a compiler's sysroot.
87 ++ ///
88 ++ /// For example this returns `lib` on Unix and Windows.
89 ++ pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path {
90 ++ match self.config.libdir_relative() {
91 ++ Some(relative_libdir) if compiler.stage >= 1
92 ++ => relative_libdir,
93 ++ _ => Path::new("lib")
94 ++ }
95 ++ }
96 ++
97 + /// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
98 + /// library lookup path.
99 + pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {
100 +diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
101 +index bd012a887c26..213ceb194a81 100644
102 +--- a/src/bootstrap/dist.rs
103 ++++ b/src/bootstrap/dist.rs
104 +@@ -469,7 +469,6 @@ impl Step for Rustc {
105 + fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
106 + let host = compiler.host;
107 + let src = builder.sysroot(compiler);
108 +- let libdir = builder.rustc_libdir(compiler);
109 +
110 + // Copy rustc/rustdoc binaries
111 + t!(fs::create_dir_all(image.join("bin")));
112 +@@ -481,11 +480,14 @@ impl Step for Rustc {
113 +
114 + // Copy runtime DLLs needed by the compiler
115 + if libdir_relative.to_str() != Some("bin") {
116 ++ let libdir = builder.rustc_libdir(compiler);
117 + for entry in builder.read_dir(&libdir) {
118 + let name = entry.file_name();
119 + if let Some(s) = name.to_str() {
120 + if is_dylib(s) {
121 +- builder.install(&entry.path(), &image.join(&libdir_relative), 0o644);
122 ++ // Don't use custom libdir here because ^lib/ will be resolved again
123 ++ // with installer
124 ++ builder.install(&entry.path(), &image.join("lib"), 0o644);
125 + }
126 + }
127 + }
128 +@@ -493,8 +495,11 @@ impl Step for Rustc {
129 +
130 + // Copy over the codegen backends
131 + let backends_src = builder.sysroot_codegen_backends(compiler);
132 +- let backends_rel = backends_src.strip_prefix(&src).unwrap();
133 +- let backends_dst = image.join(&backends_rel);
134 ++ let backends_rel = backends_src.strip_prefix(&src).unwrap()
135 ++ .strip_prefix(builder.sysroot_libdir_relative(compiler)).unwrap();
136 ++ // Don't use custom libdir here because ^lib/ will be resolved again with installer
137 ++ let backends_dst = image.join("lib").join(&backends_rel);
138 ++
139 + t!(fs::create_dir_all(&backends_dst));
140 + builder.cp_r(&backends_src, &backends_dst);
141 +
142
143 diff --git a/dev-lang/rust/files/1.38.0-fix-multiple-llvm-rebuilds.patch b/dev-lang/rust/files/1.38.0-fix-multiple-llvm-rebuilds.patch
144 new file mode 100644
145 index 00000000000..235b95625e4
146 --- /dev/null
147 +++ b/dev-lang/rust/files/1.38.0-fix-multiple-llvm-rebuilds.patch
148 @@ -0,0 +1,75 @@
149 +From 53fe76479aab03b1fbe5b7184f45484886f769b1 Mon Sep 17 00:00:00 2001
150 +From: Josh Stone <jistone@××××××.com>
151 +Date: Wed, 4 Sep 2019 16:02:31 -0700
152 +Subject: [PATCH] Assume non-git LLVM is fresh if the stamp file exists
153 +
154 +Rustbuild usually writes the LLVM submodule commit in a stamp file, so
155 +we can avoid rebuilding it unnecessarily. However, for builds from a
156 +source tarball (non-git), we were assuming a rebuild is always needed.
157 +This can cause a lot of extra work if any environment like `CFLAGS`
158 +changed between steps like build and install, which are often separate
159 +in distro builds.
160 +
161 +Now we also write an empty stamp file if the git commit is unknown, and
162 +its presence is trusted to indicate that no rebuild is needed. An info
163 +message reports that this is happening, along with the stamp file path
164 +that can be deleted to force a rebuild anyway.
165 +---
166 + src/bootstrap/native.rs | 27 ++++++++++++++-------------
167 + 1 file changed, 14 insertions(+), 13 deletions(-)
168 +
169 +diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
170 +index f02def3e1b05..7bf9ea2688f4 100644
171 +--- a/src/bootstrap/native.rs
172 ++++ b/src/bootstrap/native.rs
173 +@@ -81,26 +81,29 @@ impl Step for Llvm {
174 + (info, "src/llvm-project/llvm", builder.llvm_out(target), dir.join("bin"))
175 + };
176 +
177 +- if !llvm_info.is_git() {
178 +- println!(
179 +- "git could not determine the LLVM submodule commit hash. \
180 +- Assuming that an LLVM build is necessary.",
181 +- );
182 +- }
183 +-
184 + let build_llvm_config = llvm_config_ret_dir
185 + .join(exe("llvm-config", &*builder.config.build));
186 + let done_stamp = out_dir.join("llvm-finished-building");
187 +
188 +- if let Some(llvm_commit) = llvm_info.sha() {
189 +- if done_stamp.exists() {
190 ++ if done_stamp.exists() {
191 ++ if let Some(llvm_commit) = llvm_info.sha() {
192 + let done_contents = t!(fs::read(&done_stamp));
193 +
194 + // If LLVM was already built previously and the submodule's commit didn't change
195 + // from the previous build, then no action is required.
196 + if done_contents == llvm_commit.as_bytes() {
197 +- return build_llvm_config
198 ++ return build_llvm_config;
199 + }
200 ++ } else {
201 ++ builder.info(
202 ++ "Could not determine the LLVM submodule commit hash. \
203 ++ Assuming that an LLVM rebuild is not necessary.",
204 ++ );
205 ++ builder.info(&format!(
206 ++ "To force LLVM to rebuild, remove the file `{}`",
207 ++ done_stamp.display()
208 ++ ));
209 ++ return build_llvm_config;
210 + }
211 + }
212 +
213 +@@ -303,9 +306,7 @@ impl Step for Llvm {
214 +
215 + cfg.build();
216 +
217 +- if let Some(llvm_commit) = llvm_info.sha() {
218 +- t!(fs::write(&done_stamp, llvm_commit));
219 +- }
220 ++ t!(fs::write(&done_stamp, llvm_info.sha().unwrap_or("")));
221 +
222 + build_llvm_config
223 + }
224
225 diff --git a/dev-lang/rust/rust-1.38.0.ebuild b/dev-lang/rust/rust-1.38.0.ebuild
226 new file mode 100644
227 index 00000000000..152d59601f5
228 --- /dev/null
229 +++ b/dev-lang/rust/rust-1.38.0.ebuild
230 @@ -0,0 +1,327 @@
231 +# Copyright 1999-2019 Gentoo Authors
232 +# Distributed under the terms of the GNU General Public License v2
233 +
234 +EAPI=7
235 +
236 +PYTHON_COMPAT=( python2_7 python3_{5,6,7} pypy )
237 +
238 +inherit check-reqs estack flag-o-matic llvm multiprocessing multilib-build python-any-r1 rust-toolchain toolchain-funcs
239 +
240 +if [[ ${PV} = *beta* ]]; then
241 + betaver=${PV//*beta}
242 + BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}"
243 + MY_P="rustc-beta"
244 + SLOT="beta/${PV}"
245 + SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz"
246 +else
247 + ABI_VER="$(ver_cut 1-2)"
248 + SLOT="stable/${ABI_VER}"
249 + MY_P="rustc-${PV}"
250 + SRC="${MY_P}-src.tar.xz"
251 + KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86"
252 +fi
253 +
254 +RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
255 +
256 +DESCRIPTION="Systems programming language from Mozilla"
257 +HOMEPAGE="https://www.rust-lang.org/"
258 +
259 +SRC_URI="https://static.rust-lang.org/dist/${SRC} -> rustc-${PV}-src.tar.xz
260 + $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION})"
261 +
262 +ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430
263 + NVPTX PowerPC Sparc SystemZ WebAssembly X86 XCore )
264 +ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
265 +LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?}
266 +
267 +LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
268 +
269 +IUSE="clippy cpu_flags_x86_sse2 debug doc libressl rls rustfmt system-llvm wasm ${ALL_LLVM_TARGETS[*]}"
270 +
271 +# Please keep the LLVM dependency block separate. Since LLVM is slotted,
272 +# we need to *really* make sure we're not pulling more than one slot
273 +# simultaneously.
274 +
275 +# How to use it:
276 +# 1. List all the working slots (with min versions) in ||, newest first.
277 +# 2. Update the := to specify *max* version, e.g. < 9.
278 +# 3. Specify LLVM_MAX_SLOT, e.g. 8.
279 +LLVM_DEPEND="
280 + || (
281 + sys-devel/llvm:9[llvm_targets_WebAssembly?]
282 + wasm? ( =sys-devel/lld-9* )
283 + )
284 + <sys-devel/llvm-10:=
285 +"
286 +LLVM_MAX_SLOT=8
287 +
288 +COMMON_DEPEND="
289 + sys-libs/zlib
290 + !libressl? ( dev-libs/openssl:0= )
291 + libressl? ( dev-libs/libressl:0= )
292 + net-libs/libssh2
293 + net-libs/http-parser:=
294 + net-misc/curl[ssl]
295 + system-llvm? (
296 + ${LLVM_DEPEND}
297 + )
298 +"
299 +
300 +DEPEND="${COMMON_DEPEND}
301 + ${PYTHON_DEPS}
302 + || (
303 + >=sys-devel/gcc-4.7
304 + >=sys-devel/clang-3.5
305 + )
306 + dev-util/cmake
307 +"
308 +
309 +RDEPEND="${COMMON_DEPEND}
310 + >=app-eselect/eselect-rust-20190311
311 + !dev-util/cargo
312 + rustfmt? ( !dev-util/rustfmt )
313 +"
314 +
315 +REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )
316 + wasm? ( llvm_targets_WebAssembly )
317 + x86? ( cpu_flags_x86_sse2 )
318 +"
319 +QA_FLAGS_IGNORED="usr/bin/* usr/lib*/${P}"
320 +
321 +PATCHES=(
322 + "${FILESDIR}"/1.38.0-fix-custom-libdir.patch
323 + "${FILESDIR}"/1.38.0-fix-multiple-llvm-rebuilds.patch
324 + "${FILESDIR}"/1.36.0-libressl.patch
325 + "${FILESDIR}"/1.36.0-libressl3.patch
326 +)
327 +
328 +S="${WORKDIR}/${MY_P}-src"
329 +
330 +toml_usex() {
331 + usex "$1" true false
332 +}
333 +
334 +pre_build_checks() {
335 + CHECKREQS_DISK_BUILD="9G"
336 + eshopts_push -s extglob
337 + if is-flagq '-g?(gdb)?([1-9])'; then
338 + CHECKREQS_DISK_BUILD="14G"
339 + fi
340 + eshopts_pop
341 + check-reqs_pkg_setup
342 +}
343 +
344 +pkg_pretend() {
345 + pre_build_checks
346 +}
347 +
348 +pkg_setup() {
349 + pre_build_checks
350 + python-any-r1_pkg_setup
351 + use system-llvm && llvm_pkg_setup
352 +}
353 +
354 +src_prepare() {
355 + local rust_stage0_root="${WORKDIR}"/rust-stage0
356 +
357 + local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)"
358 +
359 + "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig --destdir="${rust_stage0_root}" --prefix=/ || die
360 +
361 + default
362 +}
363 +
364 +src_configure() {
365 + local rust_target="" rust_targets="" arch_cflags
366 +
367 + # Collect rust target names to compile standard libs for all ABIs.
368 + for v in $(multilib_get_enabled_abi_pairs); do
369 + rust_targets="${rust_targets},\"$(rust_abi $(get_abi_CHOST ${v##*.}))\""
370 + done
371 + if use wasm; then
372 + rust_targets="${rust_targets},\"wasm32-unknown-unknown\""
373 + fi
374 + rust_targets="${rust_targets#,}"
375 +
376 + local extended="true" tools="\"cargo\","
377 + if use clippy; then
378 + tools="\"clippy\",$tools"
379 + fi
380 + if use rls; then
381 + tools="\"rls\",\"analysis\",\"src\",$tools"
382 + fi
383 + if use rustfmt; then
384 + tools="\"rustfmt\",$tools"
385 + fi
386 +
387 + local rust_stage0_root="${WORKDIR}"/rust-stage0
388 +
389 + rust_target="$(rust_abi)"
390 +
391 + cat <<- EOF > "${S}"/config.toml
392 + [llvm]
393 + optimize = $(toml_usex !debug)
394 + release-debuginfo = $(toml_usex debug)
395 + assertions = $(toml_usex debug)
396 + targets = "${LLVM_TARGETS// /;}"
397 + experimental-targets = ""
398 + link-shared = $(toml_usex system-llvm)
399 + [build]
400 + build = "${rust_target}"
401 + host = ["${rust_target}"]
402 + target = [${rust_targets}]
403 + cargo = "${rust_stage0_root}/bin/cargo"
404 + rustc = "${rust_stage0_root}/bin/rustc"
405 + docs = $(toml_usex doc)
406 + submodules = false
407 + python = "${EPYTHON}"
408 + locked-deps = true
409 + vendor = true
410 + extended = ${extended}
411 + tools = [${tools}]
412 + verbose = 2
413 + [install]
414 + prefix = "${EPREFIX}/usr"
415 + libdir = "$(get_libdir)/${P}"
416 + docdir = "share/doc/${P}"
417 + mandir = "share/${P}/man"
418 + [rust]
419 + optimize = $(toml_usex !debug)
420 + debug = $(toml_usex debug)
421 + debug-assertions = $(toml_usex debug)
422 + default-linker = "$(tc-getCC)"
423 + channel = "stable"
424 + rpath = false
425 + lld = $(usex system-llvm false $(toml_usex wasm))
426 + EOF
427 +
428 + for v in $(multilib_get_enabled_abi_pairs); do
429 + rust_target=$(rust_abi $(get_abi_CHOST ${v##*.}))
430 + arch_cflags="$(get_abi_CFLAGS ${v##*.})"
431 +
432 + cat <<- EOF >> "${S}"/config.env
433 + CFLAGS_${rust_target}=${arch_cflags}
434 + EOF
435 +
436 + cat <<- EOF >> "${S}"/config.toml
437 + [target.${rust_target}]
438 + cc = "$(tc-getBUILD_CC)"
439 + cxx = "$(tc-getBUILD_CXX)"
440 + linker = "$(tc-getCC)"
441 + ar = "$(tc-getAR)"
442 + EOF
443 + if use system-llvm; then
444 + cat <<- EOF >> "${S}"/config.toml
445 + llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config"
446 + EOF
447 + fi
448 + done
449 +
450 + if use wasm; then
451 + cat <<- EOF >> "${S}"/config.toml
452 + [target.wasm32-unknown-unknown]
453 + linker = "$(usex system-llvm lld rust-lld)"
454 + EOF
455 + fi
456 +}
457 +
458 +src_compile() {
459 + env $(cat "${S}"/config.env)\
460 + "${EPYTHON}" ./x.py build -vv --config="${S}"/config.toml -j$(makeopts_jobs) \
461 + --exclude src/tools/miri || die # https://github.com/rust-lang/rust/issues/52305
462 +}
463 +
464 +src_install() {
465 + local rust_target abi_libdir
466 +
467 + env DESTDIR="${D}" "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml \
468 + --exclude src/tools/miri || die
469 +
470 + mv "${ED}/usr/bin/rustc" "${ED}/usr/bin/rustc-${PV}" || die
471 + mv "${ED}/usr/bin/rustdoc" "${ED}/usr/bin/rustdoc-${PV}" || die
472 + mv "${ED}/usr/bin/rust-gdb" "${ED}/usr/bin/rust-gdb-${PV}" || die
473 + mv "${ED}/usr/bin/rust-gdbgui" "${ED}/usr/bin/rust-gdbgui-${PV}" || die
474 + mv "${ED}/usr/bin/rust-lldb" "${ED}/usr/bin/rust-lldb-${PV}" || die
475 + mv "${ED}/usr/bin/cargo" "${ED}/usr/bin/cargo-${PV}" || die
476 + if use clippy; then
477 + mv "${ED}/usr/bin/clippy-driver" "${ED}/usr/bin/clippy-driver-${PV}" || die
478 + mv "${ED}/usr/bin/cargo-clippy" "${ED}/usr/bin/cargo-clippy-${PV}" || die
479 + fi
480 + if use rls; then
481 + mv "${ED}/usr/bin/rls" "${ED}/usr/bin/rls-${PV}" || die
482 + fi
483 + if use rustfmt; then
484 + mv "${ED}/usr/bin/rustfmt" "${ED}/usr/bin/rustfmt-${PV}" || die
485 + mv "${ED}/usr/bin/cargo-fmt" "${ED}/usr/bin/cargo-fmt-${PV}" || die
486 + fi
487 +
488 + # Copy shared library versions of standard libraries for all targets
489 + # into the system's abi-dependent lib directories because the rust
490 + # installer only does so for the native ABI.
491 + for v in $(multilib_get_enabled_abi_pairs); do
492 + if [ ${v##*.} = ${DEFAULT_ABI} ]; then
493 + continue
494 + fi
495 + abi_libdir=$(get_abi_LIBDIR ${v##*.})
496 + rust_target=$(rust_abi $(get_abi_CHOST ${v##*.}))
497 + mkdir -p "${ED}/usr/${abi_libdir}/${P}"
498 + cp "${ED}/usr/$(get_libdir)/${P}/rustlib/${rust_target}/lib"/*.so \
499 + "${ED}/usr/${abi_libdir}/${P}" || die
500 + done
501 +
502 + dodoc COPYRIGHT
503 +
504 + # FIXME:
505 + # Really not sure if that env is needed, specailly LDPATH
506 + cat <<-EOF > "${T}"/50${P}
507 + LDPATH="${EPREFIX}/usr/$(get_libdir)/${P}"
508 + MANPATH="${EPREFIX}/usr/share/${P}/man"
509 + EOF
510 + doenvd "${T}"/50${P}
511 +
512 + # note: eselect-rust adds EROOT to all paths below
513 + cat <<-EOF > "${T}/provider-${P}"
514 + /usr/bin/rustdoc
515 + /usr/bin/rust-gdb
516 + /usr/bin/rust-gdbgui
517 + /usr/bin/rust-lldb
518 + EOF
519 + echo /usr/bin/cargo >> "${T}/provider-${P}"
520 + if use clippy; then
521 + echo /usr/bin/clippy-driver >> "${T}/provider-${P}"
522 + echo /usr/bin/cargo-clippy >> "${T}/provider-${P}"
523 + fi
524 + if use rls; then
525 + echo /usr/bin/rls >> "${T}/provider-${P}"
526 + fi
527 + if use rustfmt; then
528 + echo /usr/bin/rustfmt >> "${T}/provider-${P}"
529 + echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
530 + fi
531 + dodir /etc/env.d/rust
532 + insinto /etc/env.d/rust
533 + doins "${T}/provider-${P}"
534 +}
535 +
536 +pkg_postinst() {
537 + eselect rust update --if-unset
538 +
539 + elog "Rust installs a helper script for calling GDB and LLDB,"
540 + elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}."
541 +
542 + ewarn "cargo is now installed from dev-lang/rust{,-bin} instead of dev-util/cargo."
543 + ewarn "This might have resulted in a dangling symlink for /usr/bin/cargo on some"
544 + ewarn "systems. This can be resolved by calling 'sudo eselect rust set ${P}'."
545 +
546 + if has_version app-editors/emacs || has_version app-editors/emacs-vcs; then
547 + elog "install app-emacs/rust-mode to get emacs support for rust."
548 + fi
549 +
550 + if has_version app-editors/gvim || has_version app-editors/vim; then
551 + elog "install app-vim/rust-vim to get vim support for rust."
552 + fi
553 +}
554 +
555 +pkg_postrm() {
556 + eselect rust cleanup
557 +}