From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 16F1F138335 for ; Thu, 26 Sep 2019 22:06:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 90088E0B1C; Thu, 26 Sep 2019 22:06:54 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 68375E0B1C for ; Thu, 26 Sep 2019 22:06:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DBE8834B605 for ; Thu, 26 Sep 2019 22:06:52 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 630227F9 for ; Thu, 26 Sep 2019 22:06:50 +0000 (UTC) From: "Georgy Yakovlev" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Georgy Yakovlev" Message-ID: <1569535597.d7c507ec43a21a951774add8a4a92680e5d8f4b3.gyakovlev@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/files/, dev-lang/rust/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-lang/rust/Manifest dev-lang/rust/files/1.38.0-fix-custom-libdir.patch dev-lang/rust/files/1.38.0-fix-multiple-llvm-rebuilds.patch dev-lang/rust/rust-1.38.0.ebuild X-VCS-Directories: dev-lang/rust/files/ dev-lang/rust/ X-VCS-Committer: gyakovlev X-VCS-Committer-Name: Georgy Yakovlev X-VCS-Revision: d7c507ec43a21a951774add8a4a92680e5d8f4b3 X-VCS-Branch: master Date: Thu, 26 Sep 2019 22:06:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 14906708-7d84-4ec1-9759-02b5db667945 X-Archives-Hash: ddb6ee793810a08a96981b328605085c commit: d7c507ec43a21a951774add8a4a92680e5d8f4b3 Author: Georgy Yakovlev gentoo org> AuthorDate: Thu Sep 26 21:58:56 2019 +0000 Commit: Georgy Yakovlev gentoo org> CommitDate: Thu Sep 26 22:06:37 2019 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d7c507ec dev-lang/rust: bump to 1.38.0 Package-Manager: Portage-2.3.76, Repoman-2.3.17 Signed-off-by: Georgy Yakovlev gentoo.org> dev-lang/rust/Manifest | 14 + dev-lang/rust/files/1.38.0-fix-custom-libdir.patch | 90 ++++++ .../files/1.38.0-fix-multiple-llvm-rebuilds.patch | 75 +++++ dev-lang/rust/rust-1.38.0.ebuild | 327 +++++++++++++++++++++ 4 files changed, 506 insertions(+) diff --git a/dev-lang/rust/Manifest b/dev-lang/rust/Manifest index fa10664a6c4..56ecbd36bd4 100644 --- a/dev-lang/rust/Manifest +++ b/dev-lang/rust/Manifest @@ -50,7 +50,21 @@ DIST rust-1.36.0-powerpc64-unknown-linux-gnu.tar.xz 145880928 BLAKE2B 4922df3a7d DIST rust-1.36.0-powerpc64le-unknown-linux-gnu.tar.xz 149721676 BLAKE2B e00bcc60a89354f6d4b5c89feffe5fe6dd7bf25d8dd2db2878e7c12ffc484e9258f37d80bda2b12f3965d96c73f1a03b6adbd8c20176c383e04f1a229d47d000 SHA512 02f32b544b0a55ba6f6fc4852f18766107bc0ce2c50488db11605e8a10e5965dd44e8332905c00080b08576370f2f0297ecbe12ba9fe01b4c24cdb9fd03ad64f DIST rust-1.36.0-s390x-unknown-linux-gnu.tar.xz 159518028 BLAKE2B c5876ea15c9fa56a92b4c0bf2aab472b83381a7a31fbb207e4165fdc49fea2150dddd53cc771dbcb81b01fe43a3175df146d8645d04c556af3556822fc59bf25 SHA512 c637b8f50cbce3333280f43ce4b97d3f75ddae429ee34461837c3c3869e20aed8c5e76f7a58998f617dc0ffc2e6afd00908e5de05f4c7ed9a8c34d5dbc7ce916 DIST rust-1.36.0-x86_64-unknown-linux-gnu.tar.xz 169600936 BLAKE2B 8bf075f2b5624e4716e3058512b85b70e72ec6f0c8ce8fc38857612b02aa5702a1bb447f13f882a1b96b1f32330d0a8f7f1f1db81827b51cb7429195e070a5a3 SHA512 3f14dda1e09ef8c8168600f4d70ba60cb2a1086ad9edb5eed708d0ffc16fdb9c582ce350a93afcd64b78f87737e37d4f099703835a1ec9837a5721c2335e17c7 +DIST rust-1.37.0-aarch64-unknown-linux-gnu.tar.xz 124322996 BLAKE2B 732dc36933682a18bcd5694b1715af5c442452df8232e2affda8185b9aaf0daf297cf7c4a64fc7d35898e1b3829ba9e8fbe33e8c8f7bc6183b3149f983208ba8 SHA512 c70054f589aa2aecfbd6a89f567306e0cf5d3eb56e5a544ced0a5d212f14033dab10559d22dd6b07945e45a25d8de14fc7897c9d24c0d8149548a06b404ca9d2 +DIST rust-1.37.0-arm-unknown-linux-gnueabi.tar.xz 124741032 BLAKE2B 88e38ea9152546c8a04bd6f93fa8d97d3e58255568a522d2774a2656a4c6dd7bad74633a10b424f6c5f6ca07ea07e473e620ab24dfdbe5c27bb5141ab0f5bba8 SHA512 bd28b8bb60b8e4373693ad9d41bfe62eb12a7272a5d7978691b0c7e1892a2df8d6ff8cf5c25dab805fab1d03dd17c76c1014d395b042118cb24603739c6dbb32 +DIST rust-1.37.0-arm-unknown-linux-gnueabihf.tar.xz 124971492 BLAKE2B 07614242bc500c9ca81a87ed81cc0bada9b467049b7bc2afbe6245b742ac2bec9030feb08f0ef8a2402bf2c2a19722b8b06dacd0ef56edb0522bf41e29080a01 SHA512 e380e2bf862a157cb5e06d27fa8e306474e708ce7e0ffd087531a4fa5729bef104131c256625c05515f6e7dfd43f639ce1fd5e05a2da42ad7f437d578b4acd8a +DIST rust-1.37.0-armv7-unknown-linux-gnueabihf.tar.xz 126583596 BLAKE2B f836c88801bde52c43726fb728d03b5f145b511a7a4b3d857de0218b87c83a4a2c939b9956aa61cef362a255209ea9e5159d2ac00edea2b9656ef320875f79a2 SHA512 6d9e055f36a2e912f30bebb25afdd3188019a438f208d3db67b38078bd5c37633c38fd48da15ba80640399babf89221e727a2bf43990aee269fcc5c91cd412b4 +DIST rust-1.37.0-i686-unknown-linux-gnu.tar.xz 177419360 BLAKE2B 4b28b002f0db349f9d12f2e4ae63b3fb5e9f472ec4d32d671626a56377cb87b07efd884ef3f4b23cca7072818c597fa8c693f55fd30ced5b408e8c0b0081af29 SHA512 b59377350f82efd10c7afe0f7a28ecbd5355719d841d40c98bec0f01961233f7a19bed2581a111a76cde8dd8dc68a019fa7d3da66cb7ebcb002ba52a14a7e573 +DIST rust-1.37.0-mips-unknown-linux-gnu.tar.xz 124577076 BLAKE2B 299d2b650c8236b94079ce4895e020bf2fe6c5d9b768da47d9716010eaa024c6b8ea743ddc7fadd660a9e49f65a02a8d0da7853cbff2bb6b43bb7771d3d42149 SHA512 1b71e1840470f7dd44cda177b7abf1cdc3f63db547fa36657b9fe5030a3d363afe1fa3ff8566351910daeef91ab4b33be46ef117342b4660fa23f76bee0ace00 +DIST rust-1.37.0-mips64-unknown-linux-gnuabi64.tar.xz 124565528 BLAKE2B e5bd6241ca7f2356638d39e18a71e577972143f37aa05e00e965bcce742828f25adf0f5cd6334c430d464e51b4112baeceb44a9eb41713233df6942b077983bb SHA512 1002173e608d29a2d32a6479a5c530d36e18bcce9e0813607369d3173c49b019a69ef05e8f1aba9b232285529f72837dfa8f4400866c49b6450e0f53028ebab1 +DIST rust-1.37.0-mipsel-unknown-linux-gnu.tar.xz 126620196 BLAKE2B 9174e7a48ba9e0f0bc2fc023991f6005614310a8db76824f5e733b0d8c4eaec6729c00b92e1c45f82fbb77f573c4bdc71004e887b9a170dc88c1a3f6e5ec0ccc SHA512 41f17b2f9bef0d5453153660d0f49aa0c8df0bfd003abac46728a477d3c00f67f5b1460aa851a92605fd628bf9dc18d9b44a16dbfc8fff22d84fd2a0a58b971e +DIST rust-1.37.0-powerpc-unknown-linux-gnu.tar.xz 124035536 BLAKE2B 2b0b2c34cbe929ff4632e13b41670fa25e765a8b954c3226da67e098a06bb59c1d2387bf64beddaa554e439dd1549dcb529048bcb1e0f00998aee7bf302d6f6c SHA512 54b08c4a5523749ee5054e000f82ffc7ec29562d1194fbc311bee0e953c49eead3c851dcaf34803bb8eb997550a64ec784f40927f52d33b18ceee7c921c0eed0 +DIST rust-1.37.0-powerpc64-unknown-linux-gnu.tar.xz 128662180 BLAKE2B 0df1def64d07b3eabf1aa6c993c7a01b596119abf60b1a3e3e6663b1bb3c6a945146c9cd639ee7d57462e1cbb866badfa83abb7b52b36de4b089552f624c2245 SHA512 e8e5cf1c64bd3eec389cef022e1c7bae4618fb6966505d2e762d10e7f443fece43b8b95c989c020bdf739abaf9c3f036230df46f6477a2ccd517a7bdef2ba0d7 +DIST rust-1.37.0-powerpc64le-unknown-linux-gnu.tar.xz 131763436 BLAKE2B 76b9120e98da09344ce5af39a9b333c6ca8917516ae7108d6cc129fdda4d4d6c21e2ca4c41533e202f63b992bcede5390ec986a262ea216c1340a82c5ba798e8 SHA512 366c8920448000bfb4baa3a47588a1c7bc81e18afb8d40f0efc824e429e9e6900efbdb4c9003fb45b9d8595328bd612bd63f390a7d3dedbb30b7dc57fc12abf3 +DIST rust-1.37.0-s390x-unknown-linux-gnu.tar.xz 141808296 BLAKE2B 73825a004be81cca4dfff1301ea0ef45c9f55ab8d9a9a0343585377d83c4bdc03d3c027622f18e144c9355afe6f5236a6273f84b43b01a221066d3c395f71017 SHA512 14f403d3ce9df2a2baba1db13c9f039d7118d7e0c8285ca19ea0284c32e80c3f786660dedef4d1758b2227f91732b8e7deccbf3f38c2b3491738c1408d6bfd0e +DIST rust-1.37.0-x86_64-unknown-linux-gnu.tar.xz 165034364 BLAKE2B 3047fff28da00e01179d3a648cb4e5636fa15ac7f4cb9ddc14e1df86d045b69ff3e41691b4a6ef4227c4cb58137524c5e029ba21a2c3a3a171fdb6f46b44f4ff SHA512 c4d48aa12cb929d6600f9cce81bb612c504aa1b3b3f8e76352af3a76b737dcbe0d31e8d139c17884b11aef9f12a55c4908fb8f3ff63dfa92533e4bd0a729914f DIST rustc-1.34.2-src.tar.xz 95048792 BLAKE2B e81e4bfda87ddfb09ab8a74792346970aa440c678d2bb1279c329db4929282f761ada6fea9d81ceeecfd513613025c8e636487626fc36bd0b33559e045bb1b15 SHA512 f1bd2b226d90aae8a4657e6117b9a8451d4ce8129f79cc0fce0da7613a3b7800e690bc0ede8fec20a2f5f32c13fa8e22ac97d3838e0d36936793535a75d9c381 DIST rustc-1.35.0-src.tar.xz 96543548 BLAKE2B 0291152f2b7aa8b50b22d74afbd9c7654bab8ae7dcb76224dbff43bc39a3b918ff86bfd20f408a9a16da8b20b08d9f0289bb63620f093d25d9fa008de57f52c3 SHA512 477c10b780bd54776be7ecbda0ab970416253e4a87c3e701825a7d07bcbcd91601b8e61129c5d04d4259e89c2e81e87cdbdee853375a8de5c9cf8372be2c9129 DIST rustc-1.36.0-src.tar.xz 98707920 BLAKE2B caff82482589941ab63be51eeffdf2a0419c1b624485240a0547b4bebc9f64f6c65a4babb960d1b23b3cde76550390d6d4813e1e9a9c43bf325998c87832fb94 SHA512 1adbb3b67d599f926dc19258e2596cb3b990e152e75e71645637098526207aa5632d7915fd5b67c7a045f63860cc7be3d28be014ad6141a342adc16b2fe8a879 DIST rustc-1.37.0-src.tar.xz 98654252 BLAKE2B ddee92c7959a0e1ee11ffe5ded6017703cfac7bbf2a00dc46c37ed28f1cd1d31e1d5b62cc1a5ae2d55d64f8705d0cb282f4968deddf36c3152e5e0cfdfbea67d SHA512 bfee43f578e6d44ead950b870b9fd31087e1bd3f917611f5dce7ad56504b83185edf43e297e8d1304e9e97b9a580d1e6adf6608ab8ed6dee0dc8c5153cdbc5d4 +DIST rustc-1.38.0-src.tar.xz 96163304 BLAKE2B 1e900b44db64727477ccf8e58e0ebb9ec209bbeb349816b5f7937e58c165db8befae33c5667732e5aaaa677c5a6c1e0229d9969ab8967fda9b8d7a593e6c5eb6 SHA512 b756d29a7a222bc7b5c7f42ff397346ab840f78e559f93e6e36b65e76eea525cf429899fe4de9fb8966623a2225b552feef9fa831bee50f9e25c976fa2af8c0a 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 new file mode 100644 index 00000000000..b2b14876c90 --- /dev/null +++ b/dev-lang/rust/files/1.38.0-fix-custom-libdir.patch @@ -0,0 +1,90 @@ +From 8553cc0681db7fb6b58b25bb3fbd520604a0cc3a Mon Sep 17 00:00:00 2001 +From: O01eg +Date: Wed, 7 Aug 2019 23:37:55 +0300 +Subject: [PATCH] Fix double resolving custom libdir + +--- + src/bootstrap/builder.rs | 20 +++++++++++++------- + src/bootstrap/dist.rs | 13 +++++++++---- + 2 files changed, 22 insertions(+), 11 deletions(-) + +diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs +index 5a75497173eb..06ccdd8e7f0f 100644 +--- a/src/bootstrap/builder.rs ++++ b/src/bootstrap/builder.rs +@@ -627,13 +627,7 @@ impl<'a> Builder<'a> { + } + + fn run(self, builder: &Builder<'_>) -> Interned { +- let compiler = self.compiler; +- let config = &builder.build.config; +- let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() { +- builder.build.config.libdir_relative().unwrap() +- } else { +- Path::new("lib") +- }; ++ let lib = builder.sysroot_libdir_relative(self.compiler); + let sysroot = builder + .sysroot(self.compiler) + .join(lib) +@@ -687,6 +681,18 @@ impl<'a> Builder<'a> { + } + } + ++ /// Returns the compiler's relative libdir where the standard library and other artifacts are ++ /// found for a compiler's sysroot. ++ /// ++ /// For example this returns `lib` on Unix and Windows. ++ pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path { ++ match self.config.libdir_relative() { ++ Some(relative_libdir) if compiler.stage >= 1 ++ => relative_libdir, ++ _ => Path::new("lib") ++ } ++ } ++ + /// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic + /// library lookup path. + pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) { +diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs +index bd012a887c26..213ceb194a81 100644 +--- a/src/bootstrap/dist.rs ++++ b/src/bootstrap/dist.rs +@@ -469,7 +469,6 @@ impl Step for Rustc { + fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) { + let host = compiler.host; + let src = builder.sysroot(compiler); +- let libdir = builder.rustc_libdir(compiler); + + // Copy rustc/rustdoc binaries + t!(fs::create_dir_all(image.join("bin"))); +@@ -481,11 +480,14 @@ impl Step for Rustc { + + // Copy runtime DLLs needed by the compiler + if libdir_relative.to_str() != Some("bin") { ++ let libdir = builder.rustc_libdir(compiler); + for entry in builder.read_dir(&libdir) { + let name = entry.file_name(); + if let Some(s) = name.to_str() { + if is_dylib(s) { +- builder.install(&entry.path(), &image.join(&libdir_relative), 0o644); ++ // Don't use custom libdir here because ^lib/ will be resolved again ++ // with installer ++ builder.install(&entry.path(), &image.join("lib"), 0o644); + } + } + } +@@ -493,8 +495,11 @@ impl Step for Rustc { + + // Copy over the codegen backends + let backends_src = builder.sysroot_codegen_backends(compiler); +- let backends_rel = backends_src.strip_prefix(&src).unwrap(); +- let backends_dst = image.join(&backends_rel); ++ let backends_rel = backends_src.strip_prefix(&src).unwrap() ++ .strip_prefix(builder.sysroot_libdir_relative(compiler)).unwrap(); ++ // Don't use custom libdir here because ^lib/ will be resolved again with installer ++ let backends_dst = image.join("lib").join(&backends_rel); ++ + t!(fs::create_dir_all(&backends_dst)); + builder.cp_r(&backends_src, &backends_dst); + 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 new file mode 100644 index 00000000000..235b95625e4 --- /dev/null +++ b/dev-lang/rust/files/1.38.0-fix-multiple-llvm-rebuilds.patch @@ -0,0 +1,75 @@ +From 53fe76479aab03b1fbe5b7184f45484886f769b1 Mon Sep 17 00:00:00 2001 +From: Josh Stone +Date: Wed, 4 Sep 2019 16:02:31 -0700 +Subject: [PATCH] Assume non-git LLVM is fresh if the stamp file exists + +Rustbuild usually writes the LLVM submodule commit in a stamp file, so +we can avoid rebuilding it unnecessarily. However, for builds from a +source tarball (non-git), we were assuming a rebuild is always needed. +This can cause a lot of extra work if any environment like `CFLAGS` +changed between steps like build and install, which are often separate +in distro builds. + +Now we also write an empty stamp file if the git commit is unknown, and +its presence is trusted to indicate that no rebuild is needed. An info +message reports that this is happening, along with the stamp file path +that can be deleted to force a rebuild anyway. +--- + src/bootstrap/native.rs | 27 ++++++++++++++------------- + 1 file changed, 14 insertions(+), 13 deletions(-) + +diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs +index f02def3e1b05..7bf9ea2688f4 100644 +--- a/src/bootstrap/native.rs ++++ b/src/bootstrap/native.rs +@@ -81,26 +81,29 @@ impl Step for Llvm { + (info, "src/llvm-project/llvm", builder.llvm_out(target), dir.join("bin")) + }; + +- if !llvm_info.is_git() { +- println!( +- "git could not determine the LLVM submodule commit hash. \ +- Assuming that an LLVM build is necessary.", +- ); +- } +- + let build_llvm_config = llvm_config_ret_dir + .join(exe("llvm-config", &*builder.config.build)); + let done_stamp = out_dir.join("llvm-finished-building"); + +- if let Some(llvm_commit) = llvm_info.sha() { +- if done_stamp.exists() { ++ if done_stamp.exists() { ++ if let Some(llvm_commit) = llvm_info.sha() { + let done_contents = t!(fs::read(&done_stamp)); + + // If LLVM was already built previously and the submodule's commit didn't change + // from the previous build, then no action is required. + if done_contents == llvm_commit.as_bytes() { +- return build_llvm_config ++ return build_llvm_config; + } ++ } else { ++ builder.info( ++ "Could not determine the LLVM submodule commit hash. \ ++ Assuming that an LLVM rebuild is not necessary.", ++ ); ++ builder.info(&format!( ++ "To force LLVM to rebuild, remove the file `{}`", ++ done_stamp.display() ++ )); ++ return build_llvm_config; + } + } + +@@ -303,9 +306,7 @@ impl Step for Llvm { + + cfg.build(); + +- if let Some(llvm_commit) = llvm_info.sha() { +- t!(fs::write(&done_stamp, llvm_commit)); +- } ++ t!(fs::write(&done_stamp, llvm_info.sha().unwrap_or(""))); + + build_llvm_config + } diff --git a/dev-lang/rust/rust-1.38.0.ebuild b/dev-lang/rust/rust-1.38.0.ebuild new file mode 100644 index 00000000000..152d59601f5 --- /dev/null +++ b/dev-lang/rust/rust-1.38.0.ebuild @@ -0,0 +1,327 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python2_7 python3_{5,6,7} pypy ) + +inherit check-reqs estack flag-o-matic llvm multiprocessing multilib-build python-any-r1 rust-toolchain toolchain-funcs + +if [[ ${PV} = *beta* ]]; then + betaver=${PV//*beta} + BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}" + MY_P="rustc-beta" + SLOT="beta/${PV}" + SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz" +else + ABI_VER="$(ver_cut 1-2)" + SLOT="stable/${ABI_VER}" + MY_P="rustc-${PV}" + SRC="${MY_P}-src.tar.xz" + KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86" +fi + +RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0" + +DESCRIPTION="Systems programming language from Mozilla" +HOMEPAGE="https://www.rust-lang.org/" + +SRC_URI="https://static.rust-lang.org/dist/${SRC} -> rustc-${PV}-src.tar.xz + $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION})" + +ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 + NVPTX PowerPC Sparc SystemZ WebAssembly X86 XCore ) +ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) +LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?} + +LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA" + +IUSE="clippy cpu_flags_x86_sse2 debug doc libressl rls rustfmt system-llvm wasm ${ALL_LLVM_TARGETS[*]}" + +# Please keep the LLVM dependency block separate. Since LLVM is slotted, +# we need to *really* make sure we're not pulling more than one slot +# simultaneously. + +# How to use it: +# 1. List all the working slots (with min versions) in ||, newest first. +# 2. Update the := to specify *max* version, e.g. < 9. +# 3. Specify LLVM_MAX_SLOT, e.g. 8. +LLVM_DEPEND=" + || ( + sys-devel/llvm:9[llvm_targets_WebAssembly?] + wasm? ( =sys-devel/lld-9* ) + ) + "${S}"/config.toml + [llvm] + optimize = $(toml_usex !debug) + release-debuginfo = $(toml_usex debug) + assertions = $(toml_usex debug) + targets = "${LLVM_TARGETS// /;}" + experimental-targets = "" + link-shared = $(toml_usex system-llvm) + [build] + build = "${rust_target}" + host = ["${rust_target}"] + target = [${rust_targets}] + cargo = "${rust_stage0_root}/bin/cargo" + rustc = "${rust_stage0_root}/bin/rustc" + docs = $(toml_usex doc) + submodules = false + python = "${EPYTHON}" + locked-deps = true + vendor = true + extended = ${extended} + tools = [${tools}] + verbose = 2 + [install] + prefix = "${EPREFIX}/usr" + libdir = "$(get_libdir)/${P}" + docdir = "share/doc/${P}" + mandir = "share/${P}/man" + [rust] + optimize = $(toml_usex !debug) + debug = $(toml_usex debug) + debug-assertions = $(toml_usex debug) + default-linker = "$(tc-getCC)" + channel = "stable" + rpath = false + lld = $(usex system-llvm false $(toml_usex wasm)) + EOF + + for v in $(multilib_get_enabled_abi_pairs); do + rust_target=$(rust_abi $(get_abi_CHOST ${v##*.})) + arch_cflags="$(get_abi_CFLAGS ${v##*.})" + + cat <<- EOF >> "${S}"/config.env + CFLAGS_${rust_target}=${arch_cflags} + EOF + + cat <<- EOF >> "${S}"/config.toml + [target.${rust_target}] + cc = "$(tc-getBUILD_CC)" + cxx = "$(tc-getBUILD_CXX)" + linker = "$(tc-getCC)" + ar = "$(tc-getAR)" + EOF + if use system-llvm; then + cat <<- EOF >> "${S}"/config.toml + llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config" + EOF + fi + done + + if use wasm; then + cat <<- EOF >> "${S}"/config.toml + [target.wasm32-unknown-unknown] + linker = "$(usex system-llvm lld rust-lld)" + EOF + fi +} + +src_compile() { + env $(cat "${S}"/config.env)\ + "${EPYTHON}" ./x.py build -vv --config="${S}"/config.toml -j$(makeopts_jobs) \ + --exclude src/tools/miri || die # https://github.com/rust-lang/rust/issues/52305 +} + +src_install() { + local rust_target abi_libdir + + env DESTDIR="${D}" "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml \ + --exclude src/tools/miri || die + + mv "${ED}/usr/bin/rustc" "${ED}/usr/bin/rustc-${PV}" || die + mv "${ED}/usr/bin/rustdoc" "${ED}/usr/bin/rustdoc-${PV}" || die + mv "${ED}/usr/bin/rust-gdb" "${ED}/usr/bin/rust-gdb-${PV}" || die + mv "${ED}/usr/bin/rust-gdbgui" "${ED}/usr/bin/rust-gdbgui-${PV}" || die + mv "${ED}/usr/bin/rust-lldb" "${ED}/usr/bin/rust-lldb-${PV}" || die + mv "${ED}/usr/bin/cargo" "${ED}/usr/bin/cargo-${PV}" || die + if use clippy; then + mv "${ED}/usr/bin/clippy-driver" "${ED}/usr/bin/clippy-driver-${PV}" || die + mv "${ED}/usr/bin/cargo-clippy" "${ED}/usr/bin/cargo-clippy-${PV}" || die + fi + if use rls; then + mv "${ED}/usr/bin/rls" "${ED}/usr/bin/rls-${PV}" || die + fi + if use rustfmt; then + mv "${ED}/usr/bin/rustfmt" "${ED}/usr/bin/rustfmt-${PV}" || die + mv "${ED}/usr/bin/cargo-fmt" "${ED}/usr/bin/cargo-fmt-${PV}" || die + fi + + # Copy shared library versions of standard libraries for all targets + # into the system's abi-dependent lib directories because the rust + # installer only does so for the native ABI. + for v in $(multilib_get_enabled_abi_pairs); do + if [ ${v##*.} = ${DEFAULT_ABI} ]; then + continue + fi + abi_libdir=$(get_abi_LIBDIR ${v##*.}) + rust_target=$(rust_abi $(get_abi_CHOST ${v##*.})) + mkdir -p "${ED}/usr/${abi_libdir}/${P}" + cp "${ED}/usr/$(get_libdir)/${P}/rustlib/${rust_target}/lib"/*.so \ + "${ED}/usr/${abi_libdir}/${P}" || die + done + + dodoc COPYRIGHT + + # FIXME: + # Really not sure if that env is needed, specailly LDPATH + cat <<-EOF > "${T}"/50${P} + LDPATH="${EPREFIX}/usr/$(get_libdir)/${P}" + MANPATH="${EPREFIX}/usr/share/${P}/man" + EOF + doenvd "${T}"/50${P} + + # note: eselect-rust adds EROOT to all paths below + cat <<-EOF > "${T}/provider-${P}" + /usr/bin/rustdoc + /usr/bin/rust-gdb + /usr/bin/rust-gdbgui + /usr/bin/rust-lldb + EOF + echo /usr/bin/cargo >> "${T}/provider-${P}" + if use clippy; then + echo /usr/bin/clippy-driver >> "${T}/provider-${P}" + echo /usr/bin/cargo-clippy >> "${T}/provider-${P}" + fi + if use rls; then + echo /usr/bin/rls >> "${T}/provider-${P}" + fi + if use rustfmt; then + echo /usr/bin/rustfmt >> "${T}/provider-${P}" + echo /usr/bin/cargo-fmt >> "${T}/provider-${P}" + fi + dodir /etc/env.d/rust + insinto /etc/env.d/rust + doins "${T}/provider-${P}" +} + +pkg_postinst() { + eselect rust update --if-unset + + elog "Rust installs a helper script for calling GDB and LLDB," + elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}." + + ewarn "cargo is now installed from dev-lang/rust{,-bin} instead of dev-util/cargo." + ewarn "This might have resulted in a dangling symlink for /usr/bin/cargo on some" + ewarn "systems. This can be resolved by calling 'sudo eselect rust set ${P}'." + + if has_version app-editors/emacs || has_version app-editors/emacs-vcs; then + elog "install app-emacs/rust-mode to get emacs support for rust." + fi + + if has_version app-editors/gvim || has_version app-editors/vim; then + elog "install app-vim/rust-vim to get vim support for rust." + fi +} + +pkg_postrm() { + eselect rust cleanup +}