From 4bdc9a8c85755595e25103228e0d259c4ce393c7 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Thu, 17 Jul 2025 21:45:32 -0400 Subject: 1.88.0? --- dev-lang/rust/Manifest | 11 +- dev-lang/rust/files/1.67.0-doc-wasm.patch | 34 - .../rust/files/1.85.0-cross-compile-libz.patch | 26 - .../rust/files/1.85.0-musl-dynamic-linking.patch | 271 ------- dev-lang/rust/files/rust-no-alloc-shim-func.patch | 611 +++++++++++++++ dev-lang/rust/rust-1.86.0-r991.ebuild | 816 -------------------- dev-lang/rust/rust-1.88.0-r991.ebuild | 838 +++++++++++++++++++++ 7 files changed, 1454 insertions(+), 1153 deletions(-) delete mode 100644 dev-lang/rust/files/1.67.0-doc-wasm.patch delete mode 100644 dev-lang/rust/files/1.85.0-cross-compile-libz.patch delete mode 100644 dev-lang/rust/files/1.85.0-musl-dynamic-linking.patch create mode 100644 dev-lang/rust/files/rust-no-alloc-shim-func.patch delete mode 100644 dev-lang/rust/rust-1.86.0-r991.ebuild create mode 100644 dev-lang/rust/rust-1.88.0-r991.ebuild diff --git a/dev-lang/rust/Manifest b/dev-lang/rust/Manifest index a1c5ec5..b289a58 100644 --- a/dev-lang/rust/Manifest +++ b/dev-lang/rust/Manifest @@ -1,11 +1,10 @@ -AUX 1.67.0-doc-wasm.patch 1359 BLAKE2B 59293c5b61de7ca283629d7f65b965388a42527811fc8355cdf5320fee03d10560f34e9c9a25dbe91e5758c37484485581a5e524a497711f1e108e5ffde6c53c SHA512 f3bafc2d0d2569f0d6891e14aa307cd2425d6624832b27381ae9d6f7ced488eff6d5fa0cdcd77a98d1f92a10a9d832f3aa3c481d1abbb42a0882862bbb189346 -AUX 1.85.0-cross-compile-libz.patch 1130 BLAKE2B 145695a50ccf2db6f8060bf313924e4b337b63f4d1d8f49c7da014f9a3c9ab3849b7acdd6f0defd75f88852eafe5986019371b09c8305f65280883b7be7d9c70 SHA512 2c27d13ffb62143b1019b7568c7d1187744d9a4d01390d8dfb0d27fe758506dad317fafe0a12eeb13e785885c006cb4e72db104ef72229f51c276a3bfdf2bc9e -AUX 1.85.0-musl-dynamic-linking.patch 15350 BLAKE2B 86704d0f99630153c10454d9776e8097f74e56abe69fcb71e6e9b62e8d8ee003cab981c9d2b719e4290249aece6b3b0fd547727ab89516500bfba18a8ffbb58b SHA512 31fec41ddd6c84988f22869ab7b81adc92ca5ebdce2f62ec4ddb6ed91e0bedcf3e34ddbd8a0725fa2ec50b84d0f87444c1beceaefb301f34864461ae071691f6 +AUX rust-no-alloc-shim-func.patch 23911 BLAKE2B 3f4f857e7ff65ecebf87d7a228165422a1bbfb8ae8dce590b933e1ef85784e76167c165cf64b245ee5bec783e207e941b85fbe0c17b19adb53e9461d9da72ae0 SHA512 7b7c3a2346f7605699fb0f4e4cd0cf9d996dd47f9910535972d613833e3fff589e7618c2b54aa9d9afac5f947b65b6045df934c54bbc82cebc9128662d7594ee DIST rust-patches-1.87.0-r1.tar.bz2 4635 BLAKE2B d813ec4a602d3bb879927a44a0b9f752aac255e31dfd13c56ab71b3fae7ce46a742c1d2e7494a7e17728f1edb2327ddd6ad6ebabc0c47d66326b766bbd323fbd SHA512 596ffe744a5849b443f077bbd4edbcbb240b9ac51c9d53e0e436e46d7c93a6734477d22eba4a066a0cf474503a6357a72dfa124e594f645be6f50d9bd25bdb10 -DIST rustc-1.86.0-src.tar.xz 275696736 BLAKE2B 9f33a710a3e567d92f56091920643f5ef2ddf2ad52acb5d9ee78496a7b5dbc10da5a51c72cf2a6f66d543a531d3138a49767c98501ae4e885e03988d2ccfbb59 SHA512 9ce195e24a03765f7163de16271e3d19d731d4b80fcc2bfd919106c9d42543eade018f712f6947ea3c6e57c6cb2e6841596aa668d608b8da15101a7da14f3097 -DIST rustc-1.86.0-src.tar.xz.asc 801 BLAKE2B 3e10a3894c7eee68d37bc5707d797548119f830667e27e652a199d13633199713bd01bd0f41a5f2af3c682561903e36abe27b36ef78d9a1d65bdf485527d2c15 SHA512 0b74dab9ee56d0a08e26e9cd40f722e4d99de63ac678f969f0c54d50737074fb28e170db5a36ce2627ec332e5ce3bb8a92167aefbccff7c70e4cb057bc0a94ac +DIST rust-patches-1.88.0.tar.bz2 4062 BLAKE2B 64168ffa608f2edf2e0b3d079152c3b5dd59d0cea29078894f286bf91488e2e7769c55ede2d43769368d2147b46699d1bf981190d6800dc3d41c736289122eaf SHA512 b565acfb4d1146e52b1fb66b4a242927407cc34f1b38c2a100135cbbde24c8374af1997bc22069cca25f33cc8d747e56391f3d98a2d4e13dc0abcec0d6f88b0b DIST rustc-1.87.0-src.tar.xz 283604208 BLAKE2B 7ede723121ff8df3908674631ceaec75797d91ccd6f1df4afd7187878adbb8d99c9e8a3b11c6027703b2e8d06785299d93d8649f3eda7f356dd2a6734d99d05b SHA512 2ef08c9be45434401f916d54b3739f52d255f8a3a4ce05a717499250c2333eeaf601f1d18085b878c027c609f44da74d0151f5bfc2c9ae1e01166919a91a1d2b DIST rustc-1.87.0-src.tar.xz.asc 801 BLAKE2B c9740c03baedcd70defba3fd37831692adaf0e984ef6b11d259244330d044fcacf935e6dd76caf126848da0c40f38e5368c60e8aabed5d3c2655a61fdbdc7564 SHA512 ebc13374381839a997c63455b733fd2a7960b4fd497f19c29be948cce8bb59a31ddda5da54ca154c16f7de43dd1bacd6c6bd76f3b6b36c5b43f4cfaf1746b952 -EBUILD rust-1.86.0-r991.ebuild 25752 BLAKE2B 012c5f50453277324d419691065bed55f1ad535391c2ff06b3bc7319a2cebccb60085bdd27de6f2c819551a267e3abb0131cb354ea4ec859138dfcaa9066f08b SHA512 3a974ec64dc53dfb2ef8eb52377edb13bd150ec9505243fca196dee3dcf1c9809500234b03cfc3ccc1cd3fab6749aab2e11a909945ff560f52ac1dcc9f296bfc +DIST rustc-1.88.0-src.tar.xz 283294344 BLAKE2B fc17efbc8b2e54f2da61384097dcb3b8f595f27f7853f56cef034913f6b46a718113af0fe66f0e3b0afd184ec506b35f3b74172926cf727ddc061f567d54fa4c SHA512 e6c62af2953f49462b2369e9551b12f2bec114577f90e3e76049636da4279b1e7f4d53bc6896f5d0d4715d90ef6d29dacff529a45690ffac6af62ad64600db40 +DIST rustc-1.88.0-src.tar.xz.asc 801 BLAKE2B 858e987ad1fc49c1e1cbc5ea709f835c60fce907e89205e431c843bfad97dc0ccbcf399fc7d87319b8455561cbc24020bd88cb572cbe932cb8b80a8adec39687 SHA512 64ab398dc602fed3ad7bf232249e80cc0a9831aa90c7eb37658f7dc5b2af04ee391f9633aae7a1d90f743d019cec531318384f71384ecbe4f6169e6e88b7ba0e EBUILD rust-1.87.0-r991.ebuild 25731 BLAKE2B 04d2691166b1a8225051c8f25d26ee34de1a4439018f7081091da193d0efd03c6293996e55ac2f834dd777fc040986bbff0dca18cf552239dc78aa3a315513e7 SHA512 dc640d8b6db55a803fcb14a38735b287bbd0ec116a01b2ac2f7ace2e9bca5d4bda7a46268664876e10bde2fec4ef97473eebe002c68c193f11a7d62cc39e8982 EBUILD rust-1.87.0-r992.ebuild 26009 BLAKE2B 6e7f4e13a58b4ff6edabf8f0e2dcda75bb20775eec85dae4249b071898c4c98d5347964475916551ee14a527287f1711f898e5e6363f5c3703c0fd3462eda54b SHA512 b7749d604c0e10fa173884bc8e8ccbfb6c668a7eef6c41a6c3dfbe4bd9650552e0d85a5541b6a2e150f782464e154f308c70dc063ee2d31fb296a958a968cd7f +EBUILD rust-1.88.0-r991.ebuild 26361 BLAKE2B 351de1da6933ac9dd77d04df172d2badd2534543d0db1340e7dcb6e5bc204ec36c3c36bbac8b8f71f26581ae524a1a5a66950e142e6bba06f8e65bf8af7fd2b2 SHA512 24c27386720c1c94240c53142c95c9f96ad605377c44d846344344e9dfa16c999e738fe20eea604a7381fc9257935e55df1153a3bc5174f7d3b49fb6ad69610b diff --git a/dev-lang/rust/files/1.67.0-doc-wasm.patch b/dev-lang/rust/files/1.67.0-doc-wasm.patch deleted file mode 100644 index 06011de..0000000 --- a/dev-lang/rust/files/1.67.0-doc-wasm.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 92aa5f6b272bcdc020a34f8d90f9ef851b5b4504 Mon Sep 17 00:00:00 2001 -From: John Millikin -Date: Mon, 9 Jan 2023 13:54:21 +0900 -Subject: [PATCH] Disable `linux_ext` in wasm32 and fortanix rustdoc builds. - -The `std::os::unix` module is stubbed out when building docs for these -target platforms. The introduction of Linux-specific extension traits -caused `std::os::net` to depend on sub-modules of `std::os::unix`, -which broke rustdoc for the `wasm32-unknown-unknown` target. - -Adding an additional `#[cfg]` guard solves that rustdoc failure by -not declaring `linux_ext` on targets with a stubbed `std::os::unix`. ---- - library/std/src/os/net/mod.rs | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/library/std/src/os/net/mod.rs b/library/std/src/os/net/mod.rs -index 5ec267c41e97c..b7046dd7c598c 100644 ---- a/library/std/src/os/net/mod.rs -+++ b/library/std/src/os/net/mod.rs -@@ -1,4 +1,13 @@ - //! OS-specific networking functionality. - -+// See cfg macros in `library/std/src/os/mod.rs` for why these platforms must -+// be special-cased during rustdoc generation. -+#[cfg(not(all( -+ doc, -+ any( -+ all(target_arch = "wasm32", not(target_os = "wasi")), -+ all(target_vendor = "fortanix", target_env = "sgx") -+ ) -+)))] - #[cfg(any(target_os = "linux", target_os = "android", doc))] - pub(super) mod linux_ext; diff --git a/dev-lang/rust/files/1.85.0-cross-compile-libz.patch b/dev-lang/rust/files/1.85.0-cross-compile-libz.patch deleted file mode 100644 index 7bd45c4..0000000 --- a/dev-lang/rust/files/1.85.0-cross-compile-libz.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 768f7e50a6d9a3db4e4eef45dcb4c56e9b580389 Mon Sep 17 00:00:00 2001 -From: Matt Jolly -Date: Sun, 9 Feb 2025 21:12:43 +1000 -Subject: [PATCH] Update libz cross-compile patch for 9999 (1.86.0) - -See-also: https://paste.sr.ht/~kchibisov/682321e0fd4a3ece4a4b7b71591896f5cd3cdb22 -See-also: https://github.com/gentoo/gentoo/pull/35246#discussion_r1484525497 ---- a/compiler/rustc_llvm/build.rs -+++ b/compiler/rustc_llvm/build.rs -@@ -219,13 +219,7 @@ fn main() { - // of llvm-config, not the target that we're attempting to link. - let mut cmd = Command::new(&llvm_config); - cmd.arg(llvm_link_arg).arg("--libs"); -- -- // Don't link system libs if cross-compiling unless targeting Windows. -- // On Windows system DLLs aren't linked directly, instead import libraries are used. -- // These import libraries are independent of the host. -- if !is_crossed || target.contains("windows") { -- cmd.arg("--system-libs"); -- } -+ cmd.arg("--system-libs"); - - // We need libkstat for getHostCPUName on SPARC builds. - // See also: https://github.com/llvm/llvm-project/issues/64186 --- -2.48.0 diff --git a/dev-lang/rust/files/1.85.0-musl-dynamic-linking.patch b/dev-lang/rust/files/1.85.0-musl-dynamic-linking.patch deleted file mode 100644 index a6ab967..0000000 --- a/dev-lang/rust/files/1.85.0-musl-dynamic-linking.patch +++ /dev/null @@ -1,271 +0,0 @@ -From be965af5421e55c0032a989b220bc0da005d2272 Mon Sep 17 00:00:00 2001 -From: Michal Rostecki -Date: Tue, 25 Feb 2025 16:24:21 +0100 -Subject: [PATCH] Enable dynamic linking by default for musl - ---- - .../src/spec/targets/aarch64_unknown_linux_musl.rs | 3 --- - .../src/spec/targets/arm_unknown_linux_musleabi.rs | 3 +-- - .../src/spec/targets/arm_unknown_linux_musleabihf.rs | 3 +-- - .../src/spec/targets/armv5te_unknown_linux_musleabi.rs | 3 +-- - .../src/spec/targets/armv7_unknown_linux_musleabi.rs | 3 +-- - .../src/spec/targets/armv7_unknown_linux_musleabihf.rs | 3 +-- - .../rustc_target/src/spec/targets/i586_unknown_linux_musl.rs | 2 -- - .../rustc_target/src/spec/targets/i686_unknown_linux_musl.rs | 2 -- - .../src/spec/targets/mips64_unknown_linux_muslabi64.rs | 3 +-- - .../src/spec/targets/mips64el_unknown_linux_muslabi64.rs | 2 -- - .../src/spec/targets/powerpc64_unknown_linux_musl.rs | 2 -- - .../src/spec/targets/powerpc64le_unknown_linux_musl.rs | 2 -- - .../src/spec/targets/powerpc_unknown_linux_musl.rs | 2 -- - .../src/spec/targets/powerpc_unknown_linux_muslspe.rs | 2 -- - .../src/spec/targets/riscv32gc_unknown_linux_musl.rs | 3 +-- - .../rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs | 2 -- - .../src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs | 3 +-- - .../rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs | 2 -- - 18 files changed, 8 insertions(+), 37 deletions(-) - -diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs -index 4fefdfa5c5e..bb65048a56d 100644 ---- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs -+++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs -@@ -12,9 +12,6 @@ pub(crate) fn target() -> Target { - | SanitizerSet::MEMORY - | SanitizerSet::THREAD; - -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; -- - Target { - llvm_target: "aarch64-unknown-linux-musl".into(), - metadata: crate::spec::TargetMetadata { -diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs -index 26241dd0bd4..cab79e2bf7d 100644 ---- a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs -+++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs -@@ -20,8 +20,7 @@ pub(crate) fn target() -> Target { - features: "+strict-align,+v6".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- crt_static_default: true, -+ crt_static_default: false, - ..base::linux_musl::opts() - }, - } -diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs -index 4bbde7667b9..c5f6c180a95 100644 ---- a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs -+++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs -@@ -20,8 +20,7 @@ pub(crate) fn target() -> Target { - features: "+strict-align,+v6,+vfp2,-d32".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- crt_static_default: true, -+ crt_static_default: false, - ..base::linux_musl::opts() - }, - } -diff --git a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs -index 62619546891..680dafe6943 100644 ---- a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs -+++ b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs -@@ -20,8 +20,7 @@ pub(crate) fn target() -> Target { - max_atomic_width: Some(32), - mcount: "\u{1}mcount".into(), - has_thumb_interworking: true, -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- crt_static_default: true, -+ crt_static_default: false, - ..base::linux_musl::opts() - }, - } -diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs -index 0436e0d8df4..e862b28ca92 100644 ---- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs -+++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs -@@ -24,8 +24,7 @@ pub(crate) fn target() -> Target { - features: "+v7,+thumb2,+soft-float,-neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- crt_static_default: true, -+ crt_static_default: false, - ..base::linux_musl::opts() - }, - } -diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs -index 22e49f2f1b0..acb7c99cdaf 100644 ---- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs -+++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs -@@ -23,8 +23,7 @@ pub(crate) fn target() -> Target { - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- crt_static_default: true, -+ crt_static_default: false, - ..base::linux_musl::opts() - }, - } -diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs -index 8ad93496f3a..623422a89ea 100644 ---- a/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs -+++ b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs -@@ -4,7 +4,5 @@ pub(crate) fn target() -> Target { - let mut base = super::i686_unknown_linux_musl::target(); - base.cpu = "pentium".into(); - base.llvm_target = "i586-unknown-linux-musl".into(); -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; - base - } -diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs -index 6ba87c732b7..b805b80b85b 100644 ---- a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs -+++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs -@@ -6,8 +6,6 @@ pub(crate) fn target() -> Target { - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-melf_i386"]); - base.stack_probes = StackProbeType::Inline; -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; - - // The unwinder used by i686-unknown-linux-musl, the LLVM libunwind - // implementation, apparently relies on frame pointers existing... somehow. -diff --git a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs -index 32f5c79d653..9a25fe773fb 100644 ---- a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs -+++ b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs -@@ -22,8 +22,7 @@ pub(crate) fn target() -> Target { - abi: "abi64".into(), - endian: Endian::Big, - mcount: "_mcount".into(), -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- crt_static_default: true, -+ crt_static_default: false, - ..base - }, - } -diff --git a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs -index 5e7c37fd46c..4f50e8b7033 100644 ---- a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs -+++ b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs -@@ -5,8 +5,6 @@ pub(crate) fn target() -> Target { - base.cpu = "mips64r2".into(); - base.features = "+mips64r2".into(); - base.max_atomic_width = Some(64); -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; - Target { - // LLVM doesn't recognize "muslabi64" yet. - llvm_target: "mips64el-unknown-linux-musl".into(), -diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs -index a54b17c87a7..a964f417799 100644 ---- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs -+++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs -@@ -7,8 +7,6 @@ pub(crate) fn target() -> Target { - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; - - Target { - llvm_target: "powerpc64-unknown-linux-musl".into(), -diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs -index f763c37f535..d0335506f16 100644 ---- a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs -+++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs -@@ -6,8 +6,6 @@ pub(crate) fn target() -> Target { - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; - - Target { - llvm_target: "powerpc64le-unknown-linux-musl".into(), -diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs -index 0cd0ea96ad3..5372a83e29a 100644 ---- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs -+++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs -@@ -6,8 +6,6 @@ pub(crate) fn target() -> Target { - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; - - Target { - llvm_target: "powerpc-unknown-linux-musl".into(), -diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs -index b86c3c2e8e0..2305db81c5e 100644 ---- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs -+++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs -@@ -6,8 +6,6 @@ pub(crate) fn target() -> Target { - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe"]); - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; - - Target { - llvm_target: "powerpc-unknown-linux-muslspe".into(), -diff --git a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs -index a07429bb0c5..cf2d7669a8a 100644 ---- a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs -+++ b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs -@@ -23,8 +23,7 @@ pub(crate) fn target() -> Target { - llvm_abiname: "ilp32d".into(), - max_atomic_width: Some(32), - supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- crt_static_default: true, -+ crt_static_default: false, - ..base::linux_musl::opts() - }, - } -diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs -index fbe8c48eca7..7a78004927b 100644 ---- a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs -+++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs -@@ -12,8 +12,6 @@ pub(crate) fn target() -> Target { - base.stack_probes = StackProbeType::Inline; - base.supported_sanitizers = - SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD; -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; - - Target { - llvm_target: "s390x-unknown-linux-musl".into(), -diff --git a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs -index 1149b6d16eb..e1e060c211d 100644 ---- a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs -+++ b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs -@@ -27,8 +27,7 @@ pub(crate) fn target() -> Target { - features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- crt_static_default: true, -+ crt_static_default: false, - ..base::linux_musl::opts() - }, - } -diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs -index 8dcdc5be8a9..8be0f335db9 100644 ---- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs -+++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs -@@ -14,8 +14,6 @@ pub(crate) fn target() -> Target { - | SanitizerSet::MEMORY - | SanitizerSet::THREAD; - base.supports_xray = true; -- // FIXME(compiler-team#422): musl targets should be dynamically linked by default. -- base.crt_static_default = true; - - Target { - llvm_target: "x86_64-unknown-linux-musl".into(), --- -2.45.3 - diff --git a/dev-lang/rust/files/rust-no-alloc-shim-func.patch b/dev-lang/rust/files/rust-no-alloc-shim-func.patch new file mode 100644 index 0000000..ecdadb2 --- /dev/null +++ b/dev-lang/rust/files/rust-no-alloc-shim-func.patch @@ -0,0 +1,611 @@ +From 6906b44e1c667705ce04626901a75d51f4910de3 Mon Sep 17 00:00:00 2001 +From: Daniel Paoliello +Date: Thu, 15 May 2025 16:38:46 -0700 +Subject: [PATCH] Change __rust_no_alloc_shim_is_unstable to be a function + +--- + compiler/rustc_ast/src/expand/allocator.rs | 2 +- + .../rustc_codegen_cranelift/src/allocator.rs | 40 +++++++--- + compiler/rustc_codegen_gcc/src/allocator.rs | 78 ++++++++++--------- + compiler/rustc_codegen_llvm/src/allocator.rs | 74 ++++++++++-------- + .../src/back/symbol_export.rs | 14 +--- + compiler/rustc_symbol_mangling/src/v0.rs | 4 - + library/alloc/src/alloc.rs | 7 +- + src/tools/miri/src/shims/extern_static.rs | 4 - + src/tools/miri/src/shims/foreign_items.rs | 4 + + tests/codegen/alloc-optimisation.rs | 3 +- + tests/codegen/unwind-landingpad-inline.rs | 6 +- + tests/codegen/vec-iter-collect-len.rs | 6 +- + tests/codegen/vec-optimizes-away.rs | 3 +- + tests/run-make/no-alloc-shim/foo.rs | 6 +- + tests/run-make/no-alloc-shim/rmake.rs | 22 ++++-- + tests/run-make/symbols-all-mangled/rmake.rs | 8 -- + tests/ui/sanitizer/dataflow-abilist.txt | 1 + + 18 files changed, 155 insertions(+), 131 deletions(-) + +diff --git a/compiler/rustc_ast/src/expand/allocator.rs b/compiler/rustc_ast/src/expand/allocator.rs +index dd8d5ae624a3c..7dee2ed17b4be 100644 +--- a/compiler/rustc_ast/src/expand/allocator.rs ++++ b/compiler/rustc_ast/src/expand/allocator.rs +@@ -22,7 +22,7 @@ pub fn alloc_error_handler_name(alloc_error_handler_kind: AllocatorKind) -> &'st + } + } + +-pub const NO_ALLOC_SHIM_IS_UNSTABLE: &str = "__rust_no_alloc_shim_is_unstable"; ++pub const NO_ALLOC_SHIM_IS_UNSTABLE: &str = "__rust_no_alloc_shim_is_unstable_v2"; + + pub enum AllocatorTy { + Layout, +diff --git a/compiler/rustc_codegen_cranelift/src/allocator.rs b/compiler/rustc_codegen_cranelift/src/allocator.rs +index 9cff8a84db3d9..ffb932a3c38e6 100644 +--- a/compiler/rustc_codegen_cranelift/src/allocator.rs ++++ b/compiler/rustc_codegen_cranelift/src/allocator.rs +@@ -1,6 +1,7 @@ + //! Allocator shim + // Adapted from rustc + ++use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext}; + use rustc_ast::expand::allocator::{ + ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, + alloc_error_handler_name, default_fn_name, global_fn_name, +@@ -97,16 +98,31 @@ fn codegen_inner( + data.define(Box::new([val])); + module.define_data(data_id, &data).unwrap(); + +- let data_id = module +- .declare_data( +- &mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE), +- Linkage::Export, +- false, +- false, +- ) +- .unwrap(); +- let mut data = DataDescription::new(); +- data.set_align(1); +- data.define(Box::new([0])); +- module.define_data(data_id, &data).unwrap(); ++ { ++ let sig = Signature { ++ call_conv: module.target_config().default_call_conv, ++ params: vec![], ++ returns: vec![], ++ }; ++ let func_id = module ++ .declare_function( ++ &mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE), ++ Linkage::Export, ++ &sig, ++ ) ++ .unwrap(); ++ ++ let mut ctx = Context::new(); ++ ctx.func.signature = sig; ++ let mut func_ctx = FunctionBuilderContext::new(); ++ let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); ++ ++ let block = bcx.create_block(); ++ bcx.switch_to_block(block); ++ bcx.ins().return_(&[]); ++ bcx.seal_all_blocks(); ++ bcx.finalize(); ++ ++ module.define_function(func_id, &mut ctx).unwrap(); ++ } + } +diff --git a/compiler/rustc_codegen_gcc/src/allocator.rs b/compiler/rustc_codegen_gcc/src/allocator.rs +index f4ebd42ee2dc0..cf8aa500c778f 100644 +--- a/compiler/rustc_codegen_gcc/src/allocator.rs ++++ b/compiler/rustc_codegen_gcc/src/allocator.rs +@@ -57,7 +57,7 @@ pub(crate) unsafe fn codegen( + let from_name = mangle_internal_symbol(tcx, &global_fn_name(method.name)); + let to_name = mangle_internal_symbol(tcx, &default_fn_name(method.name)); + +- create_wrapper_function(tcx, context, &from_name, &to_name, &types, output); ++ create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output); + } + } + +@@ -66,7 +66,7 @@ pub(crate) unsafe fn codegen( + tcx, + context, + &mangle_internal_symbol(tcx, "__rust_alloc_error_handler"), +- &mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind)), ++ Some(&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind))), + &[usize, usize], + None, + ); +@@ -81,21 +81,21 @@ pub(crate) unsafe fn codegen( + let value = context.new_rvalue_from_int(i8, value as i32); + global.global_set_initializer_rvalue(value); + +- let name = mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE); +- let global = context.new_global(None, GlobalKind::Exported, i8, name); +- #[cfg(feature = "master")] +- global.add_attribute(VarAttribute::Visibility(symbol_visibility_to_gcc( +- tcx.sess.default_visibility(), +- ))); +- let value = context.new_rvalue_from_int(i8, 0); +- global.global_set_initializer_rvalue(value); ++ create_wrapper_function( ++ tcx, ++ context, ++ &mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE), ++ None, ++ &[], ++ None, ++ ); + } + + fn create_wrapper_function( + tcx: TyCtxt<'_>, + context: &Context<'_>, + from_name: &str, +- to_name: &str, ++ to_name: Option<&str>, + types: &[Type<'_>], + output: Option>, + ) { +@@ -124,34 +124,40 @@ fn create_wrapper_function( + // TODO(antoyo): emit unwind tables. + } + +- let args: Vec<_> = types +- .iter() +- .enumerate() +- .map(|(index, typ)| context.new_parameter(None, *typ, format!("param{}", index))) +- .collect(); +- let callee = context.new_function( +- None, +- FunctionType::Extern, +- output.unwrap_or(void), +- &args, +- to_name, +- false, +- ); +- #[cfg(feature = "master")] +- callee.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden)); +- + let block = func.new_block("entry"); + +- let args = args +- .iter() +- .enumerate() +- .map(|(i, _)| func.get_param(i as i32).to_rvalue()) +- .collect::>(); +- let ret = context.new_call(None, callee, &args); +- //llvm::LLVMSetTailCall(ret, True); +- if output.is_some() { +- block.end_with_return(None, ret); ++ if let Some(to_name) = to_name { ++ let args: Vec<_> = types ++ .iter() ++ .enumerate() ++ .map(|(index, typ)| context.new_parameter(None, *typ, format!("param{}", index))) ++ .collect(); ++ let callee = context.new_function( ++ None, ++ FunctionType::Extern, ++ output.unwrap_or(void), ++ &args, ++ to_name, ++ false, ++ ); ++ #[cfg(feature = "master")] ++ callee.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden)); ++ ++ let args = args ++ .iter() ++ .enumerate() ++ .map(|(i, _)| func.get_param(i as i32).to_rvalue()) ++ .collect::>(); ++ let ret = context.new_call(None, callee, &args); ++ //llvm::LLVMSetTailCall(ret, True); ++ if output.is_some() { ++ block.end_with_return(None, ret); ++ } else { ++ block.add_eval(None, ret); ++ block.end_with_void_return(None); ++ } + } else { ++ assert!(output.is_none()); + block.end_with_void_return(None); + } + +diff --git a/compiler/rustc_codegen_llvm/src/allocator.rs b/compiler/rustc_codegen_llvm/src/allocator.rs +index 4a78e69497994..9dca63cfc8d4f 100644 +--- a/compiler/rustc_codegen_llvm/src/allocator.rs ++++ b/compiler/rustc_codegen_llvm/src/allocator.rs +@@ -57,7 +57,7 @@ pub(crate) unsafe fn codegen( + let from_name = mangle_internal_symbol(tcx, &global_fn_name(method.name)); + let to_name = mangle_internal_symbol(tcx, &default_fn_name(method.name)); + +- create_wrapper_function(tcx, &cx, &from_name, &to_name, &args, output, false); ++ create_wrapper_function(tcx, &cx, &from_name, Some(&to_name), &args, output, false); + } + } + +@@ -66,7 +66,7 @@ pub(crate) unsafe fn codegen( + tcx, + &cx, + &mangle_internal_symbol(tcx, "__rust_alloc_error_handler"), +- &mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind)), ++ Some(&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind))), + &[usize, usize], // size, align + None, + true, +@@ -81,11 +81,16 @@ pub(crate) unsafe fn codegen( + let llval = llvm::LLVMConstInt(i8, val as u64, False); + llvm::set_initializer(ll_g, llval); + +- let name = mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE); +- let ll_g = cx.declare_global(&name, i8); +- llvm::set_visibility(ll_g, llvm::Visibility::from_generic(tcx.sess.default_visibility())); +- let llval = llvm::LLVMConstInt(i8, 0, False); +- llvm::set_initializer(ll_g, llval); ++ // __rust_no_alloc_shim_is_unstable_v2 ++ create_wrapper_function( ++ tcx, ++ &cx, ++ &mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE), ++ None, ++ &[], ++ None, ++ false, ++ ); + } + + if tcx.sess.opts.debuginfo != DebugInfo::None { +@@ -99,7 +104,7 @@ fn create_wrapper_function( + tcx: TyCtxt<'_>, + cx: &SimpleCx<'_>, + from_name: &str, +- to_name: &str, ++ to_name: Option<&str>, + args: &[&Type], + output: Option<&Type>, + no_return: bool, +@@ -128,33 +133,38 @@ fn create_wrapper_function( + attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &[uwtable]); + } + +- let callee = declare_simple_fn( +- &cx, +- to_name, +- llvm::CallConv::CCallConv, +- llvm::UnnamedAddr::Global, +- llvm::Visibility::Hidden, +- ty, +- ); +- if let Some(no_return) = no_return { +- // -> ! DIFlagNoReturn +- attributes::apply_to_llfn(callee, llvm::AttributePlace::Function, &[no_return]); +- } +- llvm::set_visibility(callee, llvm::Visibility::Hidden); +- + let llbb = unsafe { llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, c"entry".as_ptr()) }; +- + let mut bx = SBuilder::build(&cx, llbb); +- let args = args +- .iter() +- .enumerate() +- .map(|(i, _)| llvm::get_param(llfn, i as c_uint)) +- .collect::>(); +- let ret = bx.call(ty, callee, &args, None); +- llvm::LLVMSetTailCall(ret, True); +- if output.is_some() { +- bx.ret(ret); ++ ++ if let Some(to_name) = to_name { ++ let callee = declare_simple_fn( ++ &cx, ++ to_name, ++ llvm::CallConv::CCallConv, ++ llvm::UnnamedAddr::Global, ++ llvm::Visibility::Hidden, ++ ty, ++ ); ++ if let Some(no_return) = no_return { ++ // -> ! DIFlagNoReturn ++ attributes::apply_to_llfn(callee, llvm::AttributePlace::Function, &[no_return]); ++ } ++ llvm::set_visibility(callee, llvm::Visibility::Hidden); ++ ++ let args = args ++ .iter() ++ .enumerate() ++ .map(|(i, _)| llvm::get_param(llfn, i as c_uint)) ++ .collect::>(); ++ let ret = bx.call(ty, callee, &args, None); ++ llvm::LLVMSetTailCall(ret, True); ++ if output.is_some() { ++ bx.ret(ret); ++ } else { ++ bx.ret_void() ++ } + } else { ++ assert!(output.is_none()); + bx.ret_void() + } + } +diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +index 92b9b6e132e74..d0b6c7470fb9a 100644 +--- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs ++++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +@@ -219,6 +219,7 @@ fn exported_symbols_provider_local<'tcx>( + .chain([ + mangle_internal_symbol(tcx, "__rust_alloc_error_handler"), + mangle_internal_symbol(tcx, OomStrategy::SYMBOL), ++ mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE), + ]) + { + let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name)); +@@ -232,19 +233,6 @@ fn exported_symbols_provider_local<'tcx>( + }, + )); + } +- +- let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new( +- tcx, +- &mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE), +- )); +- symbols.push(( +- exported_symbol, +- SymbolExportInfo { +- level: SymbolExportLevel::Rust, +- kind: SymbolExportKind::Data, +- used: false, +- }, +- )) + } + + if tcx.sess.instrument_coverage() || tcx.sess.opts.cg.profile_generate.enabled() { +diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs +index 49a5e20d7cf8b..1db8ad72b321c 100644 +--- a/compiler/rustc_symbol_mangling/src/v0.rs ++++ b/compiler/rustc_symbol_mangling/src/v0.rs +@@ -85,10 +85,6 @@ pub fn mangle_internal_symbol<'tcx>(tcx: TyCtxt<'tcx>, item_name: &str) -> Strin + if item_name == "rust_eh_personality" { + // rust_eh_personality must not be renamed as LLVM hard-codes the name + return "rust_eh_personality".to_owned(); +- } else if item_name == "__rust_no_alloc_shim_is_unstable" { +- // Temporary back compat hack to give people the chance to migrate to +- // include #[rustc_std_internal_symbol]. +- return "__rust_no_alloc_shim_is_unstable".to_owned(); + } + + let prefix = "_R"; +diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs +index e1cc4ba25c4ea..b4176e9c1f4d0 100644 +--- a/library/alloc/src/alloc.rs ++++ b/library/alloc/src/alloc.rs +@@ -31,8 +31,9 @@ unsafe extern "Rust" { + #[rustc_std_internal_symbol] + fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8; + ++ #[rustc_nounwind] + #[rustc_std_internal_symbol] +- static __rust_no_alloc_shim_is_unstable: u8; ++ fn __rust_no_alloc_shim_is_unstable_v2(); + } + + /// The global memory allocator. +@@ -88,7 +89,7 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 { + unsafe { + // Make sure we don't accidentally allow omitting the allocator shim in + // stable code until it is actually stabilized. +- core::ptr::read_volatile(&__rust_no_alloc_shim_is_unstable); ++ __rust_no_alloc_shim_is_unstable_v2(); + + __rust_alloc(layout.size(), layout.align()) + } +@@ -171,7 +172,7 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 { + unsafe { + // Make sure we don't accidentally allow omitting the allocator shim in + // stable code until it is actually stabilized. +- core::ptr::read_volatile(&__rust_no_alloc_shim_is_unstable); ++ __rust_no_alloc_shim_is_unstable_v2(); + + __rust_alloc_zeroed(layout.size(), layout.align()) + } +diff --git a/src/tools/miri/src/shims/extern_static.rs b/src/tools/miri/src/shims/extern_static.rs +index 2feed5a835228..a2ea3dbd88b11 100644 +--- a/src/tools/miri/src/shims/extern_static.rs ++++ b/src/tools/miri/src/shims/extern_static.rs +@@ -45,10 +45,6 @@ impl<'tcx> MiriMachine<'tcx> { + + /// Sets up the "extern statics" for this machine. + pub fn init_extern_statics(ecx: &mut MiriInterpCx<'tcx>) -> InterpResult<'tcx> { +- // "__rust_no_alloc_shim_is_unstable" +- let val = ImmTy::from_int(0, ecx.machine.layouts.u8); // always 0, value does not matter +- Self::alloc_extern_static(ecx, "__rust_no_alloc_shim_is_unstable", val)?; +- + // "__rust_alloc_error_handler_should_panic" + let val = ecx.tcx.sess.opts.unstable_opts.oom.should_panic(); + let val = ImmTy::from_int(val, ecx.machine.layouts.u8); +diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs +index 39b930fdeb92d..416cb1ab55e6a 100644 +--- a/src/tools/miri/src/shims/foreign_items.rs ++++ b/src/tools/miri/src/shims/foreign_items.rs +@@ -611,6 +611,10 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { + this.write_pointer(new_ptr, dest) + }); + } ++ name if name == this.mangle_internal_symbol("__rust_no_alloc_shim_is_unstable_v2") => { ++ // This is a no-op shim that only exists to prevent making the allocator shims instantly stable. ++ let [] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; ++ } + + // C memory handling functions + "memcmp" => { +diff --git a/tests/codegen/alloc-optimisation.rs b/tests/codegen/alloc-optimisation.rs +index 19f14647c1d7d..3735860d510fb 100644 +--- a/tests/codegen/alloc-optimisation.rs ++++ b/tests/codegen/alloc-optimisation.rs +@@ -5,7 +5,8 @@ + pub fn alloc_test(data: u32) { + // CHECK-LABEL: @alloc_test + // CHECK-NEXT: start: +- // CHECK-NEXT: {{.*}} load volatile i8, ptr @{{.*}}__rust_no_alloc_shim_is_unstable, align 1 ++ // CHECK-NEXT: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 ++ // CHECK-NEXT: tail call void @_R{{.+}}__rust_no_alloc_shim_is_unstable_v2() + // CHECK-NEXT: ret void + let x = Box::new(data); + drop(x); +diff --git a/tests/codegen/unwind-landingpad-inline.rs b/tests/codegen/unwind-landingpad-inline.rs +index 920774b340240..1cf606279e623 100644 +--- a/tests/codegen/unwind-landingpad-inline.rs ++++ b/tests/codegen/unwind-landingpad-inline.rs +@@ -10,8 +10,10 @@ + // See https://github.com/rust-lang/rust/issues/46515 + // CHECK-LABEL: @check_no_escape_in_landingpad + // CHECK: start: +-// CHECK-NEXT: __rust_no_alloc_shim_is_unstable +-// CHECK-NEXT: __rust_no_alloc_shim_is_unstable ++// CHECK-NEXT: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 ++// CHECK-NEXT: tail call void @[[NO_ALLOC_SHIM:_R.+__rust_no_alloc_shim_is_unstable_v2]]() ++// CHECK-NEXT: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 ++// CHECK-NEXT: tail call void @[[NO_ALLOC_SHIM]]() + // CHECK-NEXT: ret void + #[no_mangle] + pub fn check_no_escape_in_landingpad(f: fn()) { +diff --git a/tests/codegen/vec-iter-collect-len.rs b/tests/codegen/vec-iter-collect-len.rs +index a88573522d4d8..807548ef883f5 100644 +--- a/tests/codegen/vec-iter-collect-len.rs ++++ b/tests/codegen/vec-iter-collect-len.rs +@@ -4,7 +4,9 @@ + #[no_mangle] + pub fn get_len() -> usize { + // CHECK-LABEL: @get_len +- // CHECK-NOT: call +- // CHECK-NOT: invoke ++ // CHECK-NEXT: start: ++ // CHECK-NEXT: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 ++ // CHECK-NEXT: tail call void @_R{{.+}}__rust_no_alloc_shim_is_unstable_v2() ++ // CHECK-NEXT: ret i{{[0-9]+}} 3 + [1, 2, 3].iter().collect::>().len() + } +diff --git a/tests/codegen/vec-optimizes-away.rs b/tests/codegen/vec-optimizes-away.rs +index f6ed2898bdaaa..93b55454b108c 100644 +--- a/tests/codegen/vec-optimizes-away.rs ++++ b/tests/codegen/vec-optimizes-away.rs +@@ -5,7 +5,8 @@ + pub fn sum_me() -> i32 { + // CHECK-LABEL: @sum_me + // CHECK-NEXT: {{^.*:$}} +- // CHECK-NEXT: {{.*}} load volatile i8, ptr @{{.*}}__rust_no_alloc_shim_is_unstable, align 1 ++ // CHECK-NEXT: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 ++ // CHECK-NEXT: tail call void @_R{{.+}}__rust_no_alloc_shim_is_unstable_v2() + // CHECK-NEXT: ret i32 6 + vec![1, 2, 3].iter().sum::() + } +diff --git a/tests/run-make/no-alloc-shim/foo.rs b/tests/run-make/no-alloc-shim/foo.rs +index 42606961f8bb2..b5d0d394d2b9f 100644 +--- a/tests/run-make/no-alloc-shim/foo.rs ++++ b/tests/run-make/no-alloc-shim/foo.rs +@@ -1,4 +1,4 @@ +-#![feature(default_alloc_error_handler)] ++#![feature(rustc_attrs)] + #![no_std] + #![no_main] + +@@ -31,8 +31,8 @@ unsafe impl GlobalAlloc for Alloc { + } + + #[cfg(not(check_feature_gate))] +-#[no_mangle] +-static __rust_no_alloc_shim_is_unstable: u8 = 0; ++#[rustc_std_internal_symbol] ++fn __rust_no_alloc_shim_is_unstable_v2() {} + + #[no_mangle] + extern "C" fn main(_argc: core::ffi::c_int, _argv: *const *const i8) -> i32 { +diff --git a/tests/run-make/no-alloc-shim/rmake.rs b/tests/run-make/no-alloc-shim/rmake.rs +index d61ef5de8c56c..47cabfc208c77 100644 +--- a/tests/run-make/no-alloc-shim/rmake.rs ++++ b/tests/run-make/no-alloc-shim/rmake.rs +@@ -7,12 +7,6 @@ + //@ ignore-cross-compile + // Reason: the compiled binary is executed + +-//@ ignore-msvc +-//FIXME(Oneirical): Getting this to work on MSVC requires passing libcmt.lib to CC, +-// which is not trivial to do. +-// Tracking issue: https://github.com/rust-lang/rust/issues/128602 +-// Discussion: https://github.com/rust-lang/rust/pull/128407#discussion_r1702439172 +- + use run_make_support::{cc, has_extension, has_prefix, run, rustc, shallow_find_files}; + + fn main() { +@@ -30,15 +24,28 @@ fn main() { + has_prefix(path, "libcompiler_builtins") && has_extension(path, "rlib") + }); + ++ #[allow(unused_mut)] ++ let mut platform_args = Vec::::new(); ++ #[cfg(target_env = "msvc")] ++ { ++ platform_args.push("-MD".to_string()); ++ ++ // `/link` tells MSVC that the remaining arguments are linker options. ++ platform_args.push("/link".to_string()); ++ platform_args.push("vcruntime.lib".to_string()); ++ platform_args.push("msvcrt.lib".to_string()); ++ } ++ + cc().input("foo.o") + .out_exe("foo") ++ .args(&platform_args) + .args(&alloc_libs) + .args(&core_libs) + .args(&compiler_builtins_libs) + .run(); + run("foo"); + +- // Check that linking without __rust_no_alloc_shim_is_unstable defined fails ++ // Check that linking without __rust_no_alloc_shim_is_unstable_v2 defined fails + rustc() + .input("foo.rs") + .crate_type("bin") +@@ -48,6 +55,7 @@ fn main() { + .run(); + cc().input("foo.o") + .out_exe("foo") ++ .args(&platform_args) + .args(&alloc_libs) + .args(&core_libs) + .args(&compiler_builtins_libs) +diff --git a/tests/run-make/symbols-all-mangled/rmake.rs b/tests/run-make/symbols-all-mangled/rmake.rs +index 79ddd06bb94be..2cf579758002a 100644 +--- a/tests/run-make/symbols-all-mangled/rmake.rs ++++ b/tests/run-make/symbols-all-mangled/rmake.rs +@@ -35,10 +35,6 @@ fn symbols_check_archive(path: &str) { + continue; // All compiler-builtins symbols must remain unmangled + } + +- if name == "__rust_no_alloc_shim_is_unstable" { +- continue; // FIXME remove exception once we mangle this symbol +- } +- + if name.contains("rust_eh_personality") { + continue; // Unfortunately LLVM doesn't allow us to mangle this symbol + } +@@ -75,10 +71,6 @@ fn symbols_check(path: &str) { + continue; + } + +- if name == "__rust_no_alloc_shim_is_unstable" { +- continue; // FIXME remove exception once we mangle this symbol +- } +- + if name.contains("rust_eh_personality") { + continue; // Unfortunately LLVM doesn't allow us to mangle this symbol + } +diff --git a/tests/ui/sanitizer/dataflow-abilist.txt b/tests/ui/sanitizer/dataflow-abilist.txt +index fe04838f5493e..3d32397a175d4 100644 +--- a/tests/ui/sanitizer/dataflow-abilist.txt ++++ b/tests/ui/sanitizer/dataflow-abilist.txt +@@ -503,3 +503,4 @@ fun:__rust_realloc=uninstrumented + fun:_ZN4core*=uninstrumented + fun:_ZN3std*=uninstrumented + fun:rust_eh_personality=uninstrumented ++fun:_R*__rustc*=uninstrumented diff --git a/dev-lang/rust/rust-1.86.0-r991.ebuild b/dev-lang/rust/rust-1.86.0-r991.ebuild deleted file mode 100644 index 2f8bdf8..0000000 --- a/dev-lang/rust/rust-1.86.0-r991.ebuild +++ /dev/null @@ -1,816 +0,0 @@ -# Copyright 1999-2025 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -LLVM_COMPAT=( 19 ) -PYTHON_COMPAT=( python3_{10..13} ) - -RUST_MAX_VER=${PV%%_*} -if [[ ${PV} == *9999* ]]; then - RUST_MIN_VER="1.85.0" # Update this as new `beta` releases come out. -elif [[ ${PV} == *beta* ]]; then - # Enforce that `beta` is built from `stable`. - # While uncommon it is possible for feature changes within `beta` to result - # in an older snapshot being unable to build a newer one without modifying the sources. - # 'stable' releases should always be able to build a beta snapshot so just use those. - RUST_MAX_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).1" - RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0" -else - RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0" -fi - -inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing optfeature \ - multilib multilib-build python-any-r1 rust rust-toolchain toolchain-funcs verify-sig - -if [[ ${PV} = *9999* ]]; then - inherit git-r3 - EGIT_REPO_URI="https://github.com/rust-lang/rust.git" - EGIT_SUBMODULES=( - "*" - "-src/gcc" - ) -elif [[ ${PV} == *beta* ]]; then - # Identify the snapshot date of the beta release: - # curl -Ls static.rust-lang.org/dist/channel-rust-beta.toml | grep beta-src.tar.xz - betaver=${PV//*beta} - BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}" - MY_P="rustc-beta" - SRC_URI="https://static.rust-lang.org/dist/${BETA_SNAPSHOT}/rustc-beta-src.tar.xz -> rustc-${PV}-src.tar.xz - verify-sig? ( https://static.rust-lang.org/dist/${BETA_SNAPSHOT}/rustc-beta-src.tar.xz.asc - -> rustc-${PV}-src.tar.xz.asc ) - " - S="${WORKDIR}/${MY_P}-src" -else - MY_P="rustc-${PV}" - SRC_URI="https://static.rust-lang.org/dist/${MY_P}-src.tar.xz - verify-sig? ( https://static.rust-lang.org/dist/${MY_P}-src.tar.xz.asc ) - " - S="${WORKDIR}/${MY_P}-src" - KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86" -fi - -DESCRIPTION="Systems programming language originally developed by Mozilla" -HOMEPAGE="https://www.rust-lang.org/" - -# keep in sync with llvm ebuild of the same version as bundled one. -ALL_LLVM_TARGETS=( AArch64 AMDGPU ARC ARM AVR BPF CSKY DirectX Hexagon Lanai - LoongArch M68k Mips MSP430 NVPTX PowerPC RISCV Sparc SPIRV SystemZ VE - WebAssembly X86 XCore Xtensa ) -ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) -LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/(-)?} - -# https://github.com/rust-lang/llvm-project/blob/rustc-1.84.0/llvm/CMakeLists.txt -_ALL_RUST_EXPERIMENTAL_TARGETS=( ARC CSKY DirectX M68k SPIRV Xtensa ) -declare -A ALL_RUST_EXPERIMENTAL_TARGETS -for _x in "${_ALL_RUST_EXPERIMENTAL_TARGETS[@]}"; do - ALL_RUST_EXPERIMENTAL_TARGETS["llvm_targets_${_x}"]=0 -done - -LICENSE="|| ( MIT Apache-2.0 ) BSD BSD-1 BSD-2 BSD-4" -SLOT="${PV%%_*}" # Beta releases get to share the same SLOT as the eventual stable - -IUSE="big-endian clippy cpu_flags_x86_sse2 debug dist doc llvm-libunwind lto rustfmt rust-analyzer rust-src +system-llvm test wasm ${ALL_LLVM_TARGETS[*]}" -IUSE+=" nightly" - -if [[ ${PV} = *9999* ]]; then - # These USE flags require nightly rust - IUSE+=" miri" -fi - -LLVM_DEPEND=() -# splitting usedeps needed to avoid CI/pkgcheck's UncheckableDep limitation -for _x in "${ALL_LLVM_TARGETS[@]}"; do - LLVM_DEPEND+=( " ${_x}? ( $(llvm_gen_dep "llvm-core/llvm:\${LLVM_SLOT}[${_x}]") )" ) - if [[ -v ALL_RUST_EXPERIMENTAL_TARGETS["${_x}"] ]] ; then - ALL_RUST_EXPERIMENTAL_TARGETS["${_x}"]=1 - fi -done -LLVM_DEPEND+=( " wasm? ( $(llvm_gen_dep 'llvm-core/lld:${LLVM_SLOT}') )" ) -LLVM_DEPEND+=( " $(llvm_gen_dep 'llvm-core/llvm:${LLVM_SLOT}')" ) - -BDEPEND="${PYTHON_DEPS} - app-eselect/eselect-rust - || ( - >=sys-devel/gcc-4.7[cxx] - >=llvm-core/clang-3.5 - ) - lto? ( system-llvm? ( - || ( - $(llvm_gen_dep 'llvm-core/lld:${LLVM_SLOT}') - sys-devel/mold - ) - ) ) - !system-llvm? ( - >=dev-build/cmake-3.13.4 - app-alternatives/ninja - ) - test? ( dev-debug/gdb ) - verify-sig? ( sec-keys/openpgp-keys-rust ) -" - -DEPEND=" - >=app-arch/xz-utils-5.2 - net-misc/curl:=[http2,ssl] - sys-libs/zlib:= - dev-libs/openssl:0= - system-llvm? ( - ${LLVM_DEPEND[*]} - llvm-libunwind? ( llvm-runtimes/libunwind:= ) - ) - !system-llvm? ( - !llvm-libunwind? ( - elibc_musl? ( sys-libs/libunwind:= ) - ) - ) -" - -RDEPEND="${DEPEND} - app-eselect/eselect-rust - dev-lang/rust-common - sys-apps/lsb-release - !dev-lang/rust:stable - !dev-lang/rust:1.86 - !dev-lang/rust-bin:stable -" - -REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} ) - rust-analyzer? ( rust-src ) - test? ( ${ALL_LLVM_TARGETS[*]} ) - wasm? ( llvm_targets_WebAssembly ) - x86? ( cpu_flags_x86_sse2 ) -" - -# we don't use cmake.eclass, but can get a warning -CMAKE_WARN_UNUSED_CLI=no - -QA_FLAGS_IGNORED=" - usr/lib/${PN}/${SLOT}/bin/.* - usr/lib/${PN}/${SLOT}/libexec/.* - usr/lib/${PN}/${SLOT}/lib/lib.*.so - usr/lib/${PN}/${SLOT}/lib/rustlib/.*/bin/.* - usr/lib/${PN}/${SLOT}/lib/rustlib/.*/lib/lib.*.so -" - -QA_SONAME=" - usr/lib/${PN}/${SLOT}/lib/lib.*.so.* - usr/lib/${PN}/${SLOT}/lib/rustlib/.*/lib/lib.*.so -" - -QA_PRESTRIPPED=" - usr/lib/${PN}/${SLOT}/lib/rustlib/.*/bin/rust-llvm-dwp - usr/lib/${PN}/${SLOT}/lib/rustlib/.*/lib/self-contained/crtn.o -" - -# An rmeta file is custom binary format that contains the metadata for the crate. -# rmeta files do not support linking, since they do not contain compiled object files. -# so we can safely silence the warning for this QA check. -QA_EXECSTACK="usr/lib/${PN}/${SLOT}/lib/rustlib/*/lib*.rlib:lib.rmeta" - -# causes double bootstrap -RESTRICT="test" - -VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/rust.asc - -PATCHES=( - "${FILESDIR}"/1.85.0-cross-compile-libz.patch - "${FILESDIR}"/1.85.0-musl-dynamic-linking.patch - "${FILESDIR}"/1.67.0-doc-wasm.patch -) - -clear_vendor_checksums() { - sed -i 's/\("files":{\)[^}]*/\1/' "vendor/${1}/.cargo-checksum.json" || die -} - -toml_usex() { - usex "${1}" true false -} - -src_unpack() { - if [[ ${PV} = *9999* ]]; then - git-r3_src_unpack - mkdir "${S}/.cargo" || die # The vendor script has a check for .cargo/config{,.toml} - touch "${S}/.cargo/config.toml" || die - local rust_stage0_root="$(${RUSTC} --print sysroot || die "Can't determine rust's sysroot")" - local rust_build="" - local rust_host="" - # Configure vendor to use the portage-provided toolchain. This prevents it from - # attempting to fetch a `beta` toolchain from the internet. - cat <<- _EOF_ > "${T}/vendor-config.toml" - [build] - build = "$(rust_abi "${CBUILD}")" - host = ["$(rust_abi "${CHOST}")"] - target = ["$(rust_abi "${CHOST}")"] - cargo = "${rust_stage0_root}/bin/cargo" - rustc = "${rust_stage0_root}/bin/rustc" - rustfmt = "${rust_stage0_root}/bin/rustfmt" - _EOF_ - # We're using git sources so we need to run the Vendor script - # to ensure that all dependencies are present and up-to-date - mkdir "${S}/vendor" || die - # This also compiles the 'build helper', there's no way to avoid this. - ${EPYTHON} "${S}"/x.py vendor -vvv --config="${T}"/vendor-config.toml -j$(makeopts_jobs) || - die "Failed to vendor dependencies" - # TODO: This has to be generated somehow, this is from a 1.84.x tarball I had lying around. - cat <<- _EOF_ > "${S}/.cargo/config.toml" - [source.crates-io] - replace-with = "vendored-sources" - - [source."git+https://github.com/rust-lang/team"] - git = "https://github.com/rust-lang/team" - replace-with = "vendored-sources" - - [source.vendored-sources] - directory = "vendor" - _EOF_ - else - verify-sig_src_unpack - fi -} - -pre_build_checks() { - local M=9216 - # multiply requirements by 1.3 if we are doing x86-multilib - if use amd64; then - M=$(( $(usex abi_x86_32 13 10) * ${M} / 10 )) - fi - M=$(( $(usex clippy 128 0) + ${M} )) - if [[ ${PV} == *9999* ]]; then - M=$(( $(usex miri 128 0) + ${M} )) - fi - M=$(( $(usex rustfmt 256 0) + ${M} )) - # add 2G if we compile llvm and 256M per llvm_target - if ! use system-llvm; then - M=$(( 2048 + ${M} )) - local ltarget - for ltarget in ${ALL_LLVM_TARGETS[@]}; do - M=$(( $(usex ${ltarget} 256 0) + ${M} )) - done - fi - M=$(( $(usex wasm 256 0) + ${M} )) - M=$(( $(usex debug 2 1) * ${M} )) - eshopts_push -s extglob - if is-flagq '-g?(gdb)?([1-9])'; then - M=$(( 15 * ${M} / 10 )) - fi - eshopts_pop - M=$(( $(usex doc 256 0) + ${M} )) - CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE} -} - -llvm_check_deps() { - has_version -r "llvm-core/llvm:${LLVM_SLOT}[${LLVM_TARGET_USEDEPS// /,}]" -} - -# Is LLVM being linked against libc++? -is_libcxx_linked() { - local code='#include -#if defined(_LIBCPP_VERSION) - HAVE_LIBCXX -#endif -' - local out=$($(tc-getCXX) ${CXXFLAGS} ${CPPFLAGS} -x c++ -E -P - <<<"${code}") || return 1 - [[ ${out} == *HAVE_LIBCXX* ]] -} - -pkg_pretend() { - pre_build_checks -} - -pkg_setup() { - pre_build_checks - python-any-r1_pkg_setup - - export LIBGIT2_NO_PKG_CONFIG=1 #749381 - if tc-is-cross-compiler; then - use system-llvm && die "USE=system-llvm not allowed when cross-compiling" - local cross_llvm_target="$(llvm_tuple_to_target "${CBUILD}")" - use "llvm_targets_${cross_llvm_target}" || \ - die "Must enable LLVM_TARGETS=${cross_llvm_target} matching CBUILD=${CBUILD} when cross-compiling" - fi - - rust_pkg_setup - - if use system-llvm; then - llvm-r1_pkg_setup - - local llvm_config="$(get_llvm_prefix)/bin/llvm-config" - export LLVM_LINK_SHARED=1 - export RUSTFLAGS="${RUSTFLAGS} -Lnative=$("${llvm_config}" --libdir)" - fi -} - -src_prepare() { - if [[ ${PV} = *9999* ]]; then - # We need to update / generate lockfiles for the workspace - ${CARGO} generate-lockfile --offline - - fi - # Rust baselines to Pentium4 on x86, this patch lowers the baseline to i586 when sse2 is not set. - if use x86; then - if ! use cpu_flags_x86_sse2; then - eapply "${FILESDIR}/1.82.0-i586-baseline.patch" - #grep -rl cmd.args.push\(\"-march=i686\" . | xargs sed -i 's/march=i686/-march=i586/g' || die - fi - fi - - if use lto && tc-is-clang && ! tc-ld-is-lld && ! tc-ld-is-mold; then - export RUSTFLAGS+=" -C link-arg=-fuse-ld=lld" - fi - - default -} - -src_configure() { - if tc-is-cross-compiler; then - export PKG_CONFIG_ALLOW_CROSS=1 - export PKG_CONFIG_PATH="${ESYSROOT}/usr/$(get_libdir)/pkgconfig" - export OPENSSL_INCLUDE_DIR="${ESYSROOT}/usr/include" - export OPENSSL_LIB_DIR="${ESYSROOT}/usr/$(get_libdir)" - fi - - filter-lto # https://bugs.gentoo.org/862109 https://bugs.gentoo.org/866231 - - local rust_target="" rust_targets="" arch_cflags - - # Collect rust target names to compile standard libs for all ABIs. - for v in $(multilib_get_enabled_abi_pairs); do - rust_targets+=",\"$(rust_abi $(get_abi_CHOST ${v##*.}))\"" - done - if use wasm; then - rust_targets+=",\"wasm32-unknown-unknown\"" - if use system-llvm; then - # un-hardcode rust-lld linker for this target - # https://bugs.gentoo.org/715348 - sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/base/wasm.rs || die - fi - fi - rust_targets="${rust_targets#,}" - - # cargo and rustdoc are mandatory and should always be included - local tools='"cargo","rustdoc"' - use clippy && tools+=',"clippy"' - use rustfmt && tools+=',"rustfmt"' - use rust-analyzer && tools+=',"rust-analyzer","rust-analyzer-proc-macro-srv"' - use rust-src && tools+=',"src"' - - if [[ ${PV} == *9999* ]]; then - use miri && tools+=',"miri"' - fi - - local rust_stage0_root="$(${RUSTC} --print sysroot || die "Can't determine rust's sysroot")" - # in case of prefix it will be already prefixed, as --print sysroot returns full path - [[ -d ${rust_stage0_root} ]] || die "${rust_stage0_root} is not a directory" - - rust_target="$(rust_abi)" - rust_build="$(rust_abi "${CBUILD}")" - rust_host="$(rust_abi "${CHOST}")" - - RUST_EXPERIMENTAL_TARGETS=() - for _x in "${!ALL_RUST_EXPERIMENTAL_TARGETS[@]}"; do - if [[ ${ALL_RUST_EXPERIMENTAL_TARGETS[${_x}]} == 1 ]] && use ${_x} ; then - RUST_EXPERIMENTAL_TARGETS+=( ${_x#llvm_targets_} ) - fi - done - RUST_EXPERIMENTAL_TARGETS=${RUST_EXPERIMENTAL_TARGETS[@]} - - local cm_btype="$(usex debug DEBUG RELEASE)" - local build_channel - local build_miri="false" - case "${PV}" in - *9999*) - build_channel="nightly" - ;; - *beta*) - build_channel="beta" - ;; - *) - build_channel="stable" - ;; - esac - use nightly && build_channel="nightly" - cat <<- _EOF_ > "${S}"/config.toml - # https://github.com/rust-lang/rust/issues/135358 (bug #947897) - profile = "dist" - [llvm] - download-ci-llvm = false - optimize = $(toml_usex !debug) - release-debuginfo = $(toml_usex debug) - assertions = $(toml_usex debug) - ninja = true - targets = "${LLVM_TARGETS// /;}" - experimental-targets = "${RUST_EXPERIMENTAL_TARGETS// /;}" - link-shared = $(toml_usex system-llvm) - $(if is_libcxx_linked; then - # https://bugs.gentoo.org/732632 - echo "use-libcxx = true" - echo "static-libstdcpp = false" - fi) - $(case "${rust_target}" in - i586-*-linux-*) - # https://github.com/rust-lang/rust/issues/93059 - echo 'cflags = "-fcf-protection=none"' - echo 'cxxflags = "-fcf-protection=none"' - echo 'ldflags = "-fcf-protection=none"' - ;; - *) - ;; - esac) - enable-warnings = false - [llvm.build-config] - CMAKE_VERBOSE_MAKEFILE = "ON" - $(if ! tc-is-cross-compiler; then - # When cross-compiling, LLVM is compiled twice, once for host and - # once for target. Unfortunately, this build configuration applies - # to both, which means any flags applicable to one target but not - # the other will break. Conditionally disable respecting user - # flags when cross-compiling. - echo "CMAKE_C_FLAGS_${cm_btype} = \"${CFLAGS}\"" - echo "CMAKE_CXX_FLAGS_${cm_btype} = \"${CXXFLAGS}\"" - echo "CMAKE_EXE_LINKER_FLAGS_${cm_btype} = \"${LDFLAGS}\"" - echo "CMAKE_MODULE_LINKER_FLAGS_${cm_btype} = \"${LDFLAGS}\"" - echo "CMAKE_SHARED_LINKER_FLAGS_${cm_btype} = \"${LDFLAGS}\"" - echo "CMAKE_STATIC_LINKER_FLAGS_${cm_btype} = \"${ARFLAGS}\"" - fi) - [build] - build-stage = 2 - test-stage = 2 - build = "${rust_build}" - host = ["${rust_host}"] - target = [${rust_targets}] - cargo = "${rust_stage0_root}/bin/cargo" - rustc = "${rust_stage0_root}/bin/rustc" - rustfmt = "${rust_stage0_root}/bin/rustfmt" - docs = $(toml_usex doc) - compiler-docs = false - submodules = false - python = "${EPYTHON}" - locked-deps = true - vendor = true - extended = true - tools = [${tools}] - verbose = 2 - sanitizers = false - profiler = true - cargo-native-static = false - [install] - prefix = "${EPREFIX}/usr/lib/${PN}/${SLOT}" - sysconfdir = "etc" - docdir = "share/doc/rust" - bindir = "bin" - libdir = "lib" - mandir = "share/man" - [rust] - # https://github.com/rust-lang/rust/issues/54872 - codegen-units-std = 1 - optimize = true - debug = $(toml_usex debug) - debug-assertions = $(toml_usex debug) - debug-assertions-std = $(toml_usex debug) - debuginfo-level = $(usex debug 2 0) - debuginfo-level-rustc = $(usex debug 2 0) - debuginfo-level-std = $(usex debug 2 0) - debuginfo-level-tools = $(usex debug 2 0) - debuginfo-level-tests = 0 - backtrace = true - incremental = false - $(if ! tc-is-cross-compiler; then - echo "default-linker = \"${CHOST}-cc\"" - fi) - channel = "${build_channel}" - description = "gentoo" - rpath = true - verbose-tests = true - optimize-tests = $(toml_usex !debug) - codegen-tests = true - dist-src = false - remap-debuginfo = true - lld = $(usex system-llvm false $(toml_usex wasm)) - $(if use lto && tc-is-clang && ! tc-ld-is-mold; then - echo "use-lld = true" - fi) - # only deny warnings if doc+wasm are NOT requested, documenting stage0 wasm std fails without it - # https://github.com/rust-lang/rust/issues/74976 - # https://github.com/rust-lang/rust/issues/76526 - deny-warnings = $(usex wasm $(usex doc false true) true) - backtrace-on-ice = true - jemalloc = false - # See https://github.com/rust-lang/rust/issues/121124 - lto = "$(usex lto thin off)" - [dist] - src-tarball = false - compression-formats = ["xz"] - compression-profile = "balanced" - _EOF_ - - for v in $(multilib_get_enabled_abi_pairs); do - rust_target=$(rust_abi $(get_abi_CHOST ${v##*.})) - arch_cflags="$(get_abi_CFLAGS ${v##*.})" - - export CFLAGS_${rust_target//-/_}="${arch_cflags}" - - cat <<- _EOF_ >> "${S}"/config.toml - [target.${rust_target}] - ar = "$(tc-getAR)" - cc = "$(tc-getCC)" - cxx = "$(tc-getCXX)" - linker = "$(tc-getCC)" - ranlib = "$(tc-getRANLIB)" - llvm-libunwind = "$(usex llvm-libunwind $(usex system-llvm system in-tree) no)" - _EOF_ - if use system-llvm; then - cat <<- _EOF_ >> "${S}"/config.toml - llvm-config = "$(get_llvm_prefix)/bin/llvm-config" - _EOF_ - fi - # by default librustc_target/spec/linux_musl_base.rs sets base.crt_static_default = true; - # but we patch it and set to false here as well - if use elibc_musl; then - cat <<- _EOF_ >> "${S}"/config.toml - crt-static = false - musl-root = "$($(tc-getCC) -print-sysroot)/usr" - _EOF_ - fi - done - if use wasm; then - wasm_target="wasm32-unknown-unknown" - export CFLAGS_${wasm_target//-/_}="$(filter-flags '-mcpu*' '-march*' '-mtune*'; echo "$CFLAGS")" - cat <<- _EOF_ >> "${S}"/config.toml - [target.wasm32-unknown-unknown] - linker = "$(usex system-llvm lld rust-lld)" - # wasm target does not have profiler_builtins https://bugs.gentoo.org/848483 - profiler = false - _EOF_ - fi - - if [[ -n ${I_KNOW_WHAT_I_AM_DOING_CROSS} ]]; then # whitespace intentionally shifted below - # experimental cross support - # discussion: https://bugs.gentoo.org/679878 - # TODO: c*flags, clang, system-llvm, cargo.eclass target support - # it would be much better if we could split out stdlib - # complilation to separate ebuild and abuse CATEGORY to - # just install to /usr/lib/rustlib/ - - # extra targets defined as a bash array - # spec format: :: - # best place would be /etc/portage/env/dev-lang/rust - # Example: - # RUST_CROSS_TARGETS=( - # "AArch64:aarch64-unknown-linux-gnu:aarch64-unknown-linux-gnu" - # ) - # no extra hand holding is done, no target transformations, all - # values are passed as-is with just basic checks, so it's up to user to supply correct values - # valid rust targets can be obtained with - # rustc --print target-list - # matching cross toolchain has to be installed - # matching LLVM_TARGET has to be enabled for both rust and llvm (if using system one) - # only gcc toolchains installed with crossdev are checked for now. - - # BUG: we can't pass host flags to cross compiler, so just filter for now - # BUG: this should be more fine-grained. - filter-flags '-mcpu=*' '-march=*' '-mtune=*' - - local cross_target_spec - for cross_target_spec in "${RUST_CROSS_TARGETS[@]}";do - # extracts first element form :: - local cross_llvm_target="${cross_target_spec%%:*}" - # extracts toolchain triples, : - local cross_triples="${cross_target_spec#*:}" - # extracts first element after before : separator - local cross_rust_target="${cross_triples%%:*}" - # extracts last element after : separator - local cross_toolchain="${cross_triples##*:}" - use llvm_targets_${cross_llvm_target} || die "need llvm_targets_${cross_llvm_target} target enabled" - command -v ${cross_toolchain}-gcc > /dev/null 2>&1 || die "need ${cross_toolchain} cross toolchain" - - cat <<- _EOF_ >> "${S}"/config.toml - [target.${cross_rust_target}] - ar = "${cross_toolchain}-ar" - cc = "${cross_toolchain}-gcc" - cxx = "${cross_toolchain}-g++" - linker = "${cross_toolchain}-gcc" - ranlib = "${cross_toolchain}-ranlib" - _EOF_ - if use system-llvm; then - cat <<- _EOF_ >> "${S}"/config.toml - llvm-config = "$(get_llvm_prefix)/bin/llvm-config" - _EOF_ - fi - if [[ "${cross_toolchain}" == *-musl* ]]; then - cat <<- _EOF_ >> "${S}"/config.toml - musl-root = "$(${cross_toolchain}-gcc -print-sysroot)/usr" - _EOF_ - fi - - # append cross target to "normal" target list - # example 'target = ["powerpc64le-unknown-linux-gnu"]' - # becomes 'target = ["powerpc64le-unknown-linux-gnu","aarch64-unknown-linux-gnu"]' - - rust_targets="${rust_targets},\"${cross_rust_target}\"" - sed -i "/^target = \[/ s#\[.*\]#\[${rust_targets}\]#" config.toml || die - - ewarn - ewarn "Enabled ${cross_rust_target} rust target" - ewarn "Using ${cross_toolchain} cross toolchain" - ewarn - if ! has_version -b 'sys-devel/binutils[multitarget]' ; then - ewarn "'sys-devel/binutils[multitarget]' is not installed" - ewarn "'strip' will be unable to strip cross libraries" - ewarn "cross targets will be installed with full debug information" - ewarn "enable 'multitarget' USE flag for binutils to be able to strip object files" - ewarn - ewarn "Alternatively llvm-strip can be used, it supports stripping any target" - ewarn "define STRIP=\"llvm-strip\" to use it (experimental)" - ewarn - fi - done - fi # I_KNOW_WHAT_I_AM_DOING_CROSS - - einfo "Rust configured with the following flags:" - echo - echo RUSTFLAGS="\"${RUSTFLAGS}\"" - echo RUSTFLAGS_BOOTSTRAP="\"${RUSTFLAGS_BOOTSTRAP}\"" - echo RUSTFLAGS_NOT_BOOTSTRAP="\"${RUSTFLAGS_NOT_BOOTSTRAP}\"" - echo MAGIC_EXTRA_RUSTFLAGS="\"${MAGIC_EXTRA_RUSTFLAGS}\"" - env | grep "CARGO_TARGET_.*_RUSTFLAGS=" - env | grep "CFLAGS_.*" - echo - einfo "config.toml contents:" - cat "${S}"/config.toml || die - echo -} - -src_compile() { - RUST_BACKTRACE=1 "${EPYTHON}" ./x.py build -vvv --config="${S}"/config.toml -j$(makeopts_jobs) || die -} - -src_test() { - # https://rustc-dev-guide.rust-lang.org/tests/intro.html - - # those are basic and codegen tests. - local tests=( - codegen - codegen-units - compile-fail - incremental - mir-opt - pretty - run-make - ) - - # fails if llvm is not built with ALL targets. - # and known to fail with system llvm sometimes. - use system-llvm || tests+=( assembly ) - - # fragile/expensive/less important tests - # or tests that require extra builds - # TODO: instead of skipping, just make some nonfatal. - if [[ ${ERUST_RUN_EXTRA_TESTS:-no} != no ]]; then - tests+=( - rustdoc - rustdoc-js - rustdoc-js-std - rustdoc-ui - run-make-fulldeps - ui - ui-fulldeps - ) - fi - - local i failed=() - einfo "rust_src_test: enabled tests ${tests[@]/#/src/test/}" - for i in "${tests[@]}"; do - local t="src/test/${i}" - einfo "rust_src_test: running ${t}" - if ! RUST_BACKTRACE=1 "${EPYTHON}" ./x.py test -vv --config="${S}"/config.toml \ - -j$(makeopts_jobs) --no-doc --no-fail-fast "${t}" - then - failed+=( "${t}" ) - eerror "rust_src_test: ${t} failed" - fi - done - - if [[ ${#failed[@]} -ne 0 ]]; then - eerror "rust_src_test: failure summary: ${failed[@]}" - die "aborting due to test failures" - fi -} - -src_install() { - DESTDIR="${D}" "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die - - docompress /usr/lib/${PN}/${SLOT}/share/man/ - - # bug #689562, #689160 - rm -v "${ED}/usr/lib/${PN}/${SLOT}/etc/bash_completion.d/cargo" || die - rmdir -v "${ED}/usr/lib/${PN}/${SLOT}"/etc{/bash_completion.d,} || die - - local symlinks=( - cargo - rustc - rustdoc - rust-gdb - rust-gdbgui - rust-lldb - ) - - use clippy && symlinks+=( clippy-driver cargo-clippy ) - if [[ ${PV} = *9999* ]]; then - use miri && symlinks+=( miri cargo-miri ) - fi - use rustfmt && symlinks+=( rustfmt cargo-fmt ) - use rust-analyzer && symlinks+=( rust-analyzer ) - - einfo "installing eselect-rust symlinks and paths: ${symlinks[@]}" - local i - for i in "${symlinks[@]}"; do - # we need realpath on /usr/bin/* symlink return version-appended binary path. - # so /usr/bin/rustc should point to /usr/lib/rust//bin/rustc- - # need to fix eselect-rust to remove this hack. - local ver_i="${i}-${PV%%_*}" - if [[ -f "${ED}/usr/lib/${PN}/${SLOT}/bin/${i}" ]]; then - einfo "Installing ${i} symlink" - ln -v "${ED}/usr/lib/${PN}/${SLOT}/bin/${i}" "${ED}/usr/lib/${PN}/${SLOT}/bin/${ver_i}" || die - else - ewarn "${i} symlink requested, but source file not found" - ewarn "please report this" - fi - dosym "../lib/${PN}/${SLOT}/bin/${ver_i}" "/usr/bin/${ver_i}" - done - - # symlinks to switch components to active rust in eselect - dosym "${SLOT}/lib" "/usr/lib/${PN}/lib-${SLOT}" - use rust-analyzer && dosym "${SLOT}/libexec" "/usr/lib/${PN}/libexec-${SLOT}" - dosym "${SLOT}/share/man" "/usr/lib/${PN}/man-${SLOT}" - dosym "rust/${SLOT}/lib/rustlib" "/usr/lib/rustlib-${SLOT}" - dosym "../../lib/${PN}/${SLOT}/share/doc/rust" "/usr/share/doc/${P}" - - newenvd - "50${P}" <<-_EOF_ - MANPATH="${EPREFIX}/usr/lib/rust/man-${SLOT}" - _EOF_ - - rm -rf "${ED}/usr/lib/${PN}/${SLOT}"/*.old || die - rm -rf "${ED}/usr/lib/${PN}/${SLOT}/bin"/*.old || die - rm -rf "${ED}/usr/lib/${PN}/${SLOT}/doc"/*.old || die - - # note: eselect-rust adds EROOT to all paths below - cat <<-_EOF_ > "${T}/provider-${PN}-${SLOT}" - /usr/bin/cargo - /usr/bin/rustdoc - /usr/bin/rust-gdb - /usr/bin/rust-gdbgui - /usr/bin/rust-lldb - /usr/lib/rustlib - /usr/lib/rust/lib - /usr/lib/rust/man - /usr/share/doc/rust - _EOF_ - - if use clippy; then - echo /usr/bin/clippy-driver >> "${T}/provider-${P}" - echo /usr/bin/cargo-clippy >> "${T}/provider-${P}" - fi - if [[ ${SLOT} == *9999* ]] && use miri; then - echo /usr/bin/miri >> "${T}/provider-${P}" - echo /usr/bin/cargo-miri >> "${T}/provider-${P}" - fi - if use rustfmt; then - echo /usr/bin/rustfmt >> "${T}/provider-${P}" - echo /usr/bin/cargo-fmt >> "${T}/provider-${P}" - fi - if use rust-analyzer; then - echo /usr/lib/rust/libexec >> "${T}/provider-${P}" - echo /usr/bin/rust-analyzer >> "${T}/provider-${P}" - fi - - insinto /etc/env.d/rust - doins "${T}/provider-${PN}-${SLOT}" - - if use dist; then - "${EPYTHON}" ./x.py dist -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die - insinto "/usr/lib/${PN}/${SLOT}/dist" - doins -r "${S}/build/dist/." - fi -} - -pkg_postinst() { - - eselect rust update - - if has_version dev-debug/gdb || has_version llvm-core/lldb; then - elog "Rust installs helper scripts for calling GDB and LLDB," - elog "for convenience they are installed under /usr/bin/rust-{gdb,lldb}-${PV}." - fi - - if has_version app-editors/emacs; then - optfeature "emacs support for rust" app-emacs/rust-mode - fi - - if has_version app-editors/gvim || has_version app-editors/vim; then - optfeature "vim support for rust" app-vim/rust-vim - fi -} - -pkg_postrm() { - eselect rust cleanup -} diff --git a/dev-lang/rust/rust-1.88.0-r991.ebuild b/dev-lang/rust/rust-1.88.0-r991.ebuild new file mode 100644 index 0000000..79072ef --- /dev/null +++ b/dev-lang/rust/rust-1.88.0-r991.ebuild @@ -0,0 +1,838 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +LLVM_COMPAT=( 20 ) +PYTHON_COMPAT=( python3_{11..14} ) + +RUST_PATCH_VER="1.88.0" + +RUST_MAX_VER=${PV%%_*} +if [[ ${PV} == *9999* ]]; then + RUST_MIN_VER="1.88.0" # Update this as new `beta` releases come out. +elif [[ ${PV} == *beta* ]]; then + RUST_MAX_VER="$(ver_cut 1).$(ver_cut 2).0" + RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0" +else + RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0" +fi + +inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing optfeature \ + multilib multilib-build python-any-r1 rust rust-toolchain toolchain-funcs verify-sig + +if [[ ${PV} = *9999* ]]; then + inherit git-r3 +elif [[ ${PV} == *beta* ]]; then + # Identify the snapshot date of the beta release: + # curl -Ls static.rust-lang.org/dist/channel-rust-beta.toml | grep beta-src.tar.xz + betaver=${PV//*beta} + BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}" + MY_P="rustc-beta" + SRC_URI="https://static.rust-lang.org/dist/${BETA_SNAPSHOT}/rustc-beta-src.tar.xz -> rustc-${PV}-src.tar.xz + https://gitweb.gentoo.org/proj/rust-patches.git/snapshot/rust-patches-${RUST_PATCH_VER}.tar.bz2 + verify-sig? ( https://static.rust-lang.org/dist/${BETA_SNAPSHOT}/rustc-beta-src.tar.xz.asc + -> rustc-${PV}-src.tar.xz.asc ) + " + S="${WORKDIR}/${MY_P}-src" +else + MY_P="rustc-${PV}" + SRC_URI="https://static.rust-lang.org/dist/${MY_P}-src.tar.xz + https://gitweb.gentoo.org/proj/rust-patches.git/snapshot/rust-patches-${RUST_PATCH_VER}.tar.bz2 + verify-sig? ( https://static.rust-lang.org/dist/${MY_P}-src.tar.xz.asc ) + " + S="${WORKDIR}/${MY_P}-src" + KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86" +fi + +DESCRIPTION="Systems programming language originally developed by Mozilla" +HOMEPAGE="https://www.rust-lang.org/" + +# keep in sync with llvm ebuild of the same version as bundled one. +ALL_LLVM_TARGETS=( AArch64 AMDGPU ARC ARM AVR BPF CSKY DirectX Hexagon Lanai + LoongArch M68k Mips MSP430 NVPTX PowerPC RISCV Sparc SPIRV SystemZ VE + WebAssembly X86 XCore Xtensa ) +ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) +LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/(-)?} + +# https://github.com/rust-lang/llvm-project/blob/rustc-1.84.0/llvm/CMakeLists.txt +_ALL_RUST_EXPERIMENTAL_TARGETS=( ARC CSKY DirectX M68k SPIRV Xtensa ) +declare -A ALL_RUST_EXPERIMENTAL_TARGETS +for _x in "${_ALL_RUST_EXPERIMENTAL_TARGETS[@]}"; do + ALL_RUST_EXPERIMENTAL_TARGETS["llvm_targets_${_x}"]=0 +done + +LICENSE="|| ( MIT Apache-2.0 ) BSD BSD-1 BSD-2 BSD-4" +SLOT="${PV%%_*}" # Beta releases get to share the same SLOT as the eventual stable + +IUSE="big-endian clippy cpu_flags_x86_sse2 debug dist doc llvm-libunwind lto rustfmt rust-analyzer rust-src +system-llvm test wasm ${ALL_LLVM_TARGETS[*]}" + +if [[ ${PV} = *9999* ]]; then + # These USE flags require nightly rust + IUSE+=" miri" +fi +IUSE+=" nightly" + +LLVM_DEPEND=() +# splitting usedeps needed to avoid CI/pkgcheck's UncheckableDep limitation +for _x in "${ALL_LLVM_TARGETS[@]}"; do + LLVM_DEPEND+=( " ${_x}? ( $(llvm_gen_dep "llvm-core/llvm:\${LLVM_SLOT}[${_x}]") )" ) + if [[ -v ALL_RUST_EXPERIMENTAL_TARGETS["${_x}"] ]] ; then + ALL_RUST_EXPERIMENTAL_TARGETS["${_x}"]=1 + fi +done +LLVM_DEPEND+=( " wasm? ( $(llvm_gen_dep 'llvm-core/lld:${LLVM_SLOT}') )" ) +LLVM_DEPEND+=( " $(llvm_gen_dep 'llvm-core/llvm:${LLVM_SLOT}')" ) + +# dev-libs/oniguruma is used for documentation +BDEPEND="${PYTHON_DEPS} + app-eselect/eselect-rust + dev-libs/oniguruma + || ( + >=sys-devel/gcc-4.7[cxx] + >=llvm-core/clang-3.5 + ) + lto? ( system-llvm? ( + || ( + $(llvm_gen_dep 'llvm-core/lld:${LLVM_SLOT}') + sys-devel/mold + ) + ) ) + !system-llvm? ( + >=dev-build/cmake-3.13.4 + app-alternatives/ninja + ) + test? ( dev-debug/gdb ) + verify-sig? ( sec-keys/openpgp-keys-rust ) +" + +DEPEND=" + >=app-arch/xz-utils-5.2 + net-misc/curl:=[http2,ssl] + sys-libs/zlib:= + dev-libs/openssl:0= + system-llvm? ( + ${LLVM_DEPEND[*]} + llvm-libunwind? ( llvm-runtimes/libunwind:= ) + ) + !system-llvm? ( + !llvm-libunwind? ( + elibc_musl? ( sys-libs/libunwind:= ) + ) + ) +" + +RDEPEND="${DEPEND} + app-eselect/eselect-rust + dev-lang/rust-common + sys-apps/lsb-release + !dev-lang/rust:stable + !dev-lang/rust-bin:stable +" + +REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} ) + rust-analyzer? ( rust-src ) + test? ( ${ALL_LLVM_TARGETS[*]} ) + wasm? ( llvm_targets_WebAssembly ) + x86? ( cpu_flags_x86_sse2 ) +" + +# we don't use cmake.eclass, but can get a warning +CMAKE_WARN_UNUSED_CLI=no + +QA_FLAGS_IGNORED=" + usr/lib/${PN}/${SLOT}/bin/.* + usr/lib/${PN}/${SLOT}/libexec/.* + usr/lib/${PN}/${SLOT}/lib/lib.*.so + usr/lib/${PN}/${SLOT}/lib/rustlib/.*/bin/.* + usr/lib/${PN}/${SLOT}/lib/rustlib/.*/lib/lib.*.so +" + +QA_SONAME=" + usr/lib/${PN}/${SLOT}/lib/lib.*.so.* + usr/lib/${PN}/${SLOT}/lib/rustlib/.*/lib/lib.*.so +" + +QA_PRESTRIPPED=" + usr/lib/${PN}/${SLOT}/lib/rustlib/.*/bin/rust-llvm-dwp + usr/lib/${PN}/${SLOT}/lib/rustlib/.*/lib/self-contained/crtn.o +" + +# An rmeta file is custom binary format that contains the metadata for the crate. +# rmeta files do not support linking, since they do not contain compiled object files. +# so we can safely silence the warning for this QA check. +QA_EXECSTACK="usr/lib/${PN}/${SLOT}/lib/rustlib/*/lib*.rlib:lib.rmeta" + +# causes double bootstrap +RESTRICT="test" + +VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/rust.asc + +clear_vendor_checksums() { + sed -i 's/\("files":{\)[^}]*/\1/' "vendor/${1}/.cargo-checksum.json" || die +} + +toml_usex() { + usex "${1}" true false +} + +pre_build_checks() { + local M=9216 + # multiply requirements by 1.3 if we are doing x86-multilib + if use amd64; then + M=$(( $(usex abi_x86_32 13 10) * ${M} / 10 )) + fi + M=$(( $(usex clippy 128 0) + ${M} )) + if [[ ${PV} == *9999* ]]; then + M=$(( $(usex miri 128 0) + ${M} )) + fi + M=$(( $(usex rustfmt 256 0) + ${M} )) + # add 2G if we compile llvm and 256M per llvm_target + if ! use system-llvm; then + M=$(( 2048 + ${M} )) + local ltarget + for ltarget in ${ALL_LLVM_TARGETS[@]}; do + M=$(( $(usex ${ltarget} 256 0) + ${M} )) + done + fi + M=$(( $(usex wasm 256 0) + ${M} )) + M=$(( $(usex debug 2 1) * ${M} )) + eshopts_push -s extglob + if is-flagq '-g?(gdb)?([1-9])'; then + M=$(( 15 * ${M} / 10 )) + fi + eshopts_pop + M=$(( $(usex doc 256 0) + ${M} )) + CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE} +} + +llvm_check_deps() { + has_version -r "llvm-core/llvm:${LLVM_SLOT}[${LLVM_TARGET_USEDEPS// /,}]" +} + +# Is LLVM being linked against libc++? +is_libcxx_linked() { + local code='#include +#if defined(_LIBCPP_VERSION) + HAVE_LIBCXX +#endif +' + local out=$($(tc-getCXX) ${CXXFLAGS} ${CPPFLAGS} -x c++ -E -P - <<<"${code}") || return 1 + [[ ${out} == *HAVE_LIBCXX* ]] +} + +pkg_pretend() { + pre_build_checks +} + +pkg_setup() { + pre_build_checks + python-any-r1_pkg_setup + + export LIBGIT2_NO_PKG_CONFIG=1 #749381 + if tc-is-cross-compiler; then + use system-llvm && die "USE=system-llvm not allowed when cross-compiling" + local cross_llvm_target="$(llvm_tuple_to_target "${CBUILD}")" + use "llvm_targets_${cross_llvm_target}" || \ + die "Must enable LLVM_TARGETS=${cross_llvm_target} matching CBUILD=${CBUILD} when cross-compiling" + fi + + rust_pkg_setup + + if use system-llvm; then + llvm-r1_pkg_setup + + local llvm_config="$(get_llvm_prefix)/bin/llvm-config" + export LLVM_LINK_SHARED=1 + export RUSTFLAGS="${RUSTFLAGS} -Lnative=$("${llvm_config}" --libdir)" + fi +} + +rust_live_get_sources() { + EGIT_REPO_URI=" + https://anongit.gentoo.org/git/proj/rust-patches.git + " + EGIT_CHECKOUT_DIR="${WORKDIR}/rust-patches-${RUST_PATCH_VER}" + git-r3_src_unpack + + EGIT_REPO_URI=" + https://github.com/rust-lang/rust.git + " + EGIT_SUBMODULES=( + "*" + "-src/gcc" + ) + S="${WORKDIR}/rust" + EGIT_CHECKOUT_DIR="${S}" + git-r3_src_unpack +} + +src_unpack() { + if [[ ${PV} == *9999* ]] ; then + rust_live_get_sources + + # Vendor dependencies + mkdir "${S}/.cargo" || die # The vendor script has a check for .cargo/config{,.toml} + touch "${S}/.cargo/bootstrap.toml" || die + local rust_stage0_root="$(${RUSTC} --print sysroot || die "Can't determine rust's sysroot")" + # Configure vendor to use the portage-provided toolchain. This prevents it from + # attempting to fetch a `beta` toolchain from the internet. + cat <<- _EOF_ > "${T}/vendor-bootstrap.toml" + # Suppresses a warning about tracking changes which we don't care about. + change-id = "ignore" + [build] + build = "$(rust_abi "${CBUILD}")" + host = ["$(rust_abi "${CHOST}")"] + target = ["$(rust_abi "${CHOST}")"] + cargo = "${rust_stage0_root}/bin/cargo" + rustc = "${rust_stage0_root}/bin/rustc" + rustfmt = "${rust_stage0_root}/bin/rustfmt" + _EOF_ + # We're using git sources so we need to run the Vendor script + # to ensure that all dependencies are present and up-to-date + mkdir "${S}/vendor" || die + # This also compiles the 'build helper', there's no way to avoid this. + ${EPYTHON} "${S}"/x.py vendor -v --config="${T}"/vendor-bootstrap.toml -j$(makeopts_jobs) || + die "Failed to vendor dependencies" + # TODO: This has to be generated somehow, this is from a 1.84.x tarball I had lying around. + cat <<- _EOF_ > "${S}/.cargo/config.toml" + [source.crates-io] + replace-with = "vendored-sources" + + [source."git+https://github.com/rust-lang/team"] + git = "https://github.com/rust-lang/team" + replace-with = "vendored-sources" + + [source.vendored-sources] + directory = "vendor" + _EOF_ + elif use verify-sig ; then + # Patch tarballs are not signed (but we trust Gentoo infra) + verify-sig_verify_detached "${DISTDIR}"/rustc-${PV}-src.tar.xz{,.asc} + default + else + default + fi +} + +src_prepare() { + if [[ ${PV} = *9999* ]]; then + # We need to update / generate lockfiles for the workspace + ${CARGO} generate-lockfile --offline || die "Failed to generate lockfiles" + fi + + PATCHES=( + "${WORKDIR}/rust-patches-${RUST_PATCH_VER}/" + "${FILESDIR}/rust-no-alloc-shim-func.patch" + ) + + if use lto && tc-is-clang && ! tc-ld-is-lld && ! tc-ld-is-mold; then + export RUSTFLAGS+=" -C link-arg=-fuse-ld=lld" + fi + + default +} + +src_configure() { + if tc-is-cross-compiler; then + export PKG_CONFIG_ALLOW_CROSS=1 + export PKG_CONFIG_PATH="${ESYSROOT}/usr/$(get_libdir)/pkgconfig" + export OPENSSL_INCLUDE_DIR="${ESYSROOT}/usr/include" + export OPENSSL_LIB_DIR="${ESYSROOT}/usr/$(get_libdir)" + fi + + # Avoid bundled copies of libraries + export RUSTONIG_SYSTEM_LIBONIG=1 + # Need to check if these can be optional + #export LIBSQLITE3_SYS_USE_PKG_CONFIG=1 + #export LIBSSH2_SYS_USE_PKG_CONFIG=1 + + filter-lto # https://bugs.gentoo.org/862109 https://bugs.gentoo.org/866231 + + local rust_target="" rust_targets="" arch_cflags + + # Collect rust target names to compile standard libs for all ABIs. + for v in $(multilib_get_enabled_abi_pairs); do + rust_targets+=",\"$(rust_abi $(get_abi_CHOST ${v##*.}))\"" + done + if use wasm; then + rust_targets+=",\"wasm32-unknown-unknown\"" + if use system-llvm; then + # un-hardcode rust-lld linker for this target + # https://bugs.gentoo.org/715348 + sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/base/wasm.rs || die + fi + fi + rust_targets="${rust_targets#,}" + + # cargo and rustdoc are mandatory and should always be included + local tools='"cargo","rustdoc"' + use clippy && tools+=',"clippy"' + use rustfmt && tools+=',"rustfmt"' + use rust-analyzer && tools+=',"rust-analyzer","rust-analyzer-proc-macro-srv"' + use rust-src && tools+=',"src"' + + if [[ ${PV} == *9999* ]]; then + use miri && tools+=',"miri"' + fi + + local rust_stage0_root="$(${RUSTC} --print sysroot || die "Can't determine rust's sysroot")" + use nightly && build_channel="nightly" + # in case of prefix it will be already prefixed, as --print sysroot returns full path + [[ -d ${rust_stage0_root} ]] || die "${rust_stage0_root} is not a directory" + + rust_target="$(rust_abi)" + rust_build="$(rust_abi "${CBUILD}")" + rust_host="$(rust_abi "${CHOST}")" + + RUST_EXPERIMENTAL_TARGETS=() + for _x in "${!ALL_RUST_EXPERIMENTAL_TARGETS[@]}"; do + if [[ ${ALL_RUST_EXPERIMENTAL_TARGETS[${_x}]} == 1 ]] && use ${_x} ; then + RUST_EXPERIMENTAL_TARGETS+=( ${_x#llvm_targets_} ) + fi + done + RUST_EXPERIMENTAL_TARGETS=${RUST_EXPERIMENTAL_TARGETS[@]} + + local cm_btype="$(usex debug DEBUG RELEASE)" + local build_channel + local build_miri="false" + case "${PV}" in + *9999*) + build_channel="nightly" + ;; + *beta*) + build_channel="beta" + ;; + *) + build_channel="stable" + ;; + esac + cat <<- _EOF_ > "${S}"/bootstrap.toml + # Suppresses a warning about tracking changes which we don't care about. + change-id = "ignore" + # https://github.com/rust-lang/rust/issues/135358 (bug #947897) + profile = "dist" + [llvm] + download-ci-llvm = false + optimize = $(toml_usex !debug) + release-debuginfo = $(toml_usex debug) + assertions = $(toml_usex debug) + ninja = true + targets = "${LLVM_TARGETS// /;}" + experimental-targets = "${RUST_EXPERIMENTAL_TARGETS// /;}" + link-shared = $(toml_usex system-llvm) + $(if is_libcxx_linked; then + # https://bugs.gentoo.org/732632 + echo "use-libcxx = true" + echo "static-libstdcpp = false" + fi) + $(case "${rust_target}" in + i586-*-linux-*) + # https://github.com/rust-lang/rust/issues/93059 + echo 'cflags = "-fcf-protection=none"' + echo 'cxxflags = "-fcf-protection=none"' + echo 'ldflags = "-fcf-protection=none"' + ;; + *) + ;; + esac) + enable-warnings = false + [llvm.build-config] + CMAKE_VERBOSE_MAKEFILE = "ON" + $(if ! tc-is-cross-compiler; then + # When cross-compiling, LLVM is compiled twice, once for host and + # once for target. Unfortunately, this build configuration applies + # to both, which means any flags applicable to one target but not + # the other will break. Conditionally disable respecting user + # flags when cross-compiling. + echo "CMAKE_C_FLAGS_${cm_btype} = \"${CFLAGS}\"" + echo "CMAKE_CXX_FLAGS_${cm_btype} = \"${CXXFLAGS}\"" + echo "CMAKE_EXE_LINKER_FLAGS_${cm_btype} = \"${LDFLAGS}\"" + echo "CMAKE_MODULE_LINKER_FLAGS_${cm_btype} = \"${LDFLAGS}\"" + echo "CMAKE_SHARED_LINKER_FLAGS_${cm_btype} = \"${LDFLAGS}\"" + echo "CMAKE_STATIC_LINKER_FLAGS_${cm_btype} = \"${ARFLAGS}\"" + fi) + [build] + build-stage = 2 + test-stage = 2 + build = "${rust_build}" + host = ["${rust_host}"] + target = [${rust_targets}] + cargo = "${rust_stage0_root}/bin/cargo" + rustc = "${rust_stage0_root}/bin/rustc" + rustfmt = "${rust_stage0_root}/bin/rustfmt" + docs = $(toml_usex doc) + compiler-docs = false + submodules = false + python = "${EPYTHON}" + locked-deps = true + vendor = true + extended = true + tools = [${tools}] + verbose = 2 + sanitizers = false + profiler = true + cargo-native-static = false + [install] + prefix = "${EPREFIX}/usr/lib/${PN}/${SLOT}" + sysconfdir = "etc" + docdir = "share/doc/rust" + bindir = "bin" + libdir = "lib" + mandir = "share/man" + [rust] + # https://github.com/rust-lang/rust/issues/54872 + codegen-units-std = 1 + optimize = true + debug = $(toml_usex debug) + debug-assertions = $(toml_usex debug) + debug-assertions-std = $(toml_usex debug) + debuginfo-level = $(usex debug 2 0) + debuginfo-level-rustc = $(usex debug 2 0) + debuginfo-level-std = $(usex debug 2 0) + debuginfo-level-tools = $(usex debug 2 0) + debuginfo-level-tests = 0 + backtrace = true + incremental = false + $(if ! tc-is-cross-compiler; then + echo "default-linker = \"${CHOST}-cc\"" + fi) + channel = "${build_channel}" + description = "gentoo" + rpath = true + verbose-tests = true + optimize-tests = $(toml_usex !debug) + codegen-tests = true + omit-git-hash = false + dist-src = false + remap-debuginfo = true + lld = $(usex system-llvm false $(toml_usex wasm)) + $(if use lto && tc-is-clang && ! tc-ld-is-mold; then + echo "use-lld = true" + fi) + # only deny warnings if doc+wasm are NOT requested, documenting stage0 wasm std fails without it + # https://github.com/rust-lang/rust/issues/74976 + # https://github.com/rust-lang/rust/issues/76526 + deny-warnings = $(usex wasm $(usex doc false true) true) + backtrace-on-ice = true + jemalloc = false + # See https://github.com/rust-lang/rust/issues/121124 + lto = "$(usex lto thin off)" + [dist] + src-tarball = false + compression-formats = ["xz"] + compression-profile = "balanced" + _EOF_ + + for v in $(multilib_get_enabled_abi_pairs); do + rust_target=$(rust_abi $(get_abi_CHOST ${v##*.})) + arch_cflags="$(get_abi_CFLAGS ${v##*.})" + + export CFLAGS_${rust_target//-/_}="${arch_cflags}" + + cat <<- _EOF_ >> "${S}"/bootstrap.toml + [target.${rust_target}] + ar = "$(tc-getAR)" + cc = "$(tc-getCC)" + cxx = "$(tc-getCXX)" + linker = "$(tc-getCC)" + ranlib = "$(tc-getRANLIB)" + llvm-libunwind = "$(usex llvm-libunwind $(usex system-llvm system in-tree) no)" + _EOF_ + if use system-llvm; then + cat <<- _EOF_ >> "${S}"/bootstrap.toml + llvm-config = "$(get_llvm_prefix)/bin/llvm-config" + _EOF_ + fi + # by default librustc_target/spec/linux_musl_base.rs sets base.crt_static_default = true; + # but we patch it and set to false here as well + if use elibc_musl; then + cat <<- _EOF_ >> "${S}"/bootstrap.toml + crt-static = false + musl-root = "$($(tc-getCC) -print-sysroot)/usr" + _EOF_ + fi + done + if use wasm; then + wasm_target="wasm32-unknown-unknown" + export CFLAGS_${wasm_target//-/_}="$(filter-flags '-mcpu*' '-march*' '-mtune*'; echo "$CFLAGS")" + cat <<- _EOF_ >> "${S}"/bootstrap.toml + [target.wasm32-unknown-unknown] + linker = "$(usex system-llvm lld rust-lld)" + # wasm target does not have profiler_builtins https://bugs.gentoo.org/848483 + profiler = false + _EOF_ + fi + + if [[ -n ${I_KNOW_WHAT_I_AM_DOING_CROSS} ]]; then # whitespace intentionally shifted below + # experimental cross support + # discussion: https://bugs.gentoo.org/679878 + # TODO: c*flags, clang, system-llvm, cargo.eclass target support + # it would be much better if we could split out stdlib + # complilation to separate ebuild and abuse CATEGORY to + # just install to /usr/lib/rustlib/ + + # extra targets defined as a bash array + # spec format: :: + # best place would be /etc/portage/env/dev-lang/rust + # Example: + # RUST_CROSS_TARGETS=( + # "AArch64:aarch64-unknown-linux-gnu:aarch64-unknown-linux-gnu" + # ) + # no extra hand holding is done, no target transformations, all + # values are passed as-is with just basic checks, so it's up to user to supply correct values + # valid rust targets can be obtained with + # rustc --print target-list + # matching cross toolchain has to be installed + # matching LLVM_TARGET has to be enabled for both rust and llvm (if using system one) + # only gcc toolchains installed with crossdev are checked for now. + + # BUG: we can't pass host flags to cross compiler, so just filter for now + # BUG: this should be more fine-grained. + filter-flags '-mcpu=*' '-march=*' '-mtune=*' + + local cross_target_spec + for cross_target_spec in "${RUST_CROSS_TARGETS[@]}";do + # extracts first element form :: + local cross_llvm_target="${cross_target_spec%%:*}" + # extracts toolchain triples, : + local cross_triples="${cross_target_spec#*:}" + # extracts first element after before : separator + local cross_rust_target="${cross_triples%%:*}" + # extracts last element after : separator + local cross_toolchain="${cross_triples##*:}" + use llvm_targets_${cross_llvm_target} || die "need llvm_targets_${cross_llvm_target} target enabled" + command -v ${cross_toolchain}-gcc > /dev/null 2>&1 || die "need ${cross_toolchain} cross toolchain" + + cat <<- _EOF_ >> "${S}"/bootstrap.toml + [target.${cross_rust_target}] + ar = "${cross_toolchain}-ar" + cc = "${cross_toolchain}-gcc" + cxx = "${cross_toolchain}-g++" + linker = "${cross_toolchain}-gcc" + ranlib = "${cross_toolchain}-ranlib" + _EOF_ + if use system-llvm; then + cat <<- _EOF_ >> "${S}"/bootstrap.toml + llvm-config = "$(get_llvm_prefix)/bin/llvm-config" + _EOF_ + fi + if [[ "${cross_toolchain}" == *-musl* ]]; then + cat <<- _EOF_ >> "${S}"/bootstrap.toml + musl-root = "$(${cross_toolchain}-gcc -print-sysroot)/usr" + _EOF_ + fi + + # append cross target to "normal" target list + # example 'target = ["powerpc64le-unknown-linux-gnu"]' + # becomes 'target = ["powerpc64le-unknown-linux-gnu","aarch64-unknown-linux-gnu"]' + + rust_targets="${rust_targets},\"${cross_rust_target}\"" + sed -i "/^target = \[/ s#\[.*\]#\[${rust_targets}\]#" bootstrap.toml || die + + ewarn + ewarn "Enabled ${cross_rust_target} rust target" + ewarn "Using ${cross_toolchain} cross toolchain" + ewarn + if ! has_version -b 'sys-devel/binutils[multitarget]' ; then + ewarn "'sys-devel/binutils[multitarget]' is not installed" + ewarn "'strip' will be unable to strip cross libraries" + ewarn "cross targets will be installed with full debug information" + ewarn "enable 'multitarget' USE flag for binutils to be able to strip object files" + ewarn + ewarn "Alternatively llvm-strip can be used, it supports stripping any target" + ewarn "define STRIP=\"llvm-strip\" to use it (experimental)" + ewarn + fi + done + fi # I_KNOW_WHAT_I_AM_DOING_CROSS + + einfo "Rust configured with the following flags:" + echo + echo RUSTFLAGS="\"${RUSTFLAGS}\"" + echo RUSTFLAGS_BOOTSTRAP="\"${RUSTFLAGS_BOOTSTRAP}\"" + echo RUSTFLAGS_NOT_BOOTSTRAP="\"${RUSTFLAGS_NOT_BOOTSTRAP}\"" + echo MAGIC_EXTRA_RUSTFLAGS="\"${MAGIC_EXTRA_RUSTFLAGS}\"" + env | grep "CARGO_TARGET_.*_RUSTFLAGS=" + env | grep "CFLAGS_.*" + echo + einfo "bootstrap.toml contents:" + cat "${S}"/bootstrap.toml || die + echo +} + +src_compile() { + # -v will show invocations, -vv "very verbose" is overkill, -vvv "very very verbose" is insane + RUST_BACKTRACE=1 "${EPYTHON}" ./x.py build -v --config="${S}"/bootstrap.toml -j$(makeopts_jobs) || die +} + +src_test() { + # https://rustc-dev-guide.rust-lang.org/tests/intro.html + + # those are basic and codegen tests. + local tests=( + codegen + codegen-units + compile-fail + incremental + mir-opt + pretty + run-make + ) + + # fails if llvm is not built with ALL targets. + # and known to fail with system llvm sometimes. + use system-llvm || tests+=( assembly ) + + # fragile/expensive/less important tests + # or tests that require extra builds + # TODO: instead of skipping, just make some nonfatal. + if [[ ${ERUST_RUN_EXTRA_TESTS:-no} != no ]]; then + tests+=( + rustdoc + rustdoc-js + rustdoc-js-std + rustdoc-ui + run-make-fulldeps + ui + ui-fulldeps + ) + fi + + local i failed=() + einfo "rust_src_test: enabled tests ${tests[@]/#/src/test/}" + for i in "${tests[@]}"; do + local t="src/test/${i}" + einfo "rust_src_test: running ${t}" + if ! RUST_BACKTRACE=1 "${EPYTHON}" ./x.py test -vv --config="${S}"/bootstrap.toml \ + -j$(makeopts_jobs) --no-doc --no-fail-fast "${t}" + then + failed+=( "${t}" ) + eerror "rust_src_test: ${t} failed" + fi + done + + if [[ ${#failed[@]} -ne 0 ]]; then + eerror "rust_src_test: failure summary: ${failed[@]}" + die "aborting due to test failures" + fi +} + +src_install() { + DESTDIR="${D}" "${EPYTHON}" ./x.py install -v --config="${S}"/bootstrap.toml -j$(makeopts_jobs) || die + + docompress /usr/lib/${PN}/${SLOT}/share/man/ + + # bug #689562, #689160 + rm -v "${ED}/usr/lib/${PN}/${SLOT}/etc/bash_completion.d/cargo" || die + rmdir -v "${ED}/usr/lib/${PN}/${SLOT}"/etc{/bash_completion.d,} || die + + local symlinks=( + cargo + rustc + rustdoc + rust-gdb + rust-gdbgui + rust-lldb + ) + + use clippy && symlinks+=( clippy-driver cargo-clippy ) + if [[ ${PV} = *9999* ]]; then + use miri && symlinks+=( miri cargo-miri ) + fi + use rustfmt && symlinks+=( rustfmt cargo-fmt ) + use rust-analyzer && symlinks+=( rust-analyzer ) + + einfo "installing eselect-rust symlinks and paths: ${symlinks[@]}" + local i + for i in "${symlinks[@]}"; do + # we need realpath on /usr/bin/* symlink return version-appended binary path. + # so /usr/bin/rustc should point to /usr/lib/rust//bin/rustc- + # need to fix eselect-rust to remove this hack. + local ver_i="${i}-${PV%%_*}" + if [[ -f "${ED}/usr/lib/${PN}/${SLOT}/bin/${i}" ]]; then + einfo "Installing ${i} symlink" + ln -v "${ED}/usr/lib/${PN}/${SLOT}/bin/${i}" "${ED}/usr/lib/${PN}/${SLOT}/bin/${ver_i}" || die + else + ewarn "${i} symlink requested, but source file not found" + ewarn "please report this" + fi + dosym "../lib/${PN}/${SLOT}/bin/${ver_i}" "/usr/bin/${ver_i}" + done + + # symlinks to switch components to active rust in eselect + dosym "${SLOT}/lib" "/usr/lib/${PN}/lib-${SLOT}" + use rust-analyzer && dosym "${SLOT}/libexec" "/usr/lib/${PN}/libexec-${SLOT}" + dosym "${SLOT}/share/man" "/usr/lib/${PN}/man-${SLOT}" + dosym "rust/${SLOT}/lib/rustlib" "/usr/lib/rustlib-${SLOT}" + dosym "../../lib/${PN}/${SLOT}/share/doc/rust" "/usr/share/doc/${P}" + + newenvd - "50${P}" <<-_EOF_ + MANPATH="${EPREFIX}/usr/lib/rust/man-${SLOT}" + _EOF_ + + rm -rf "${ED}/usr/lib/${PN}/${SLOT}"/*.old || die + rm -rf "${ED}/usr/lib/${PN}/${SLOT}/bin"/*.old || die + rm -rf "${ED}/usr/lib/${PN}/${SLOT}/doc"/*.old || die + + # note: eselect-rust adds EROOT to all paths below + cat <<-_EOF_ > "${T}/provider-${PN}-${SLOT}" + /usr/bin/cargo + /usr/bin/rustdoc + /usr/bin/rust-gdb + /usr/bin/rust-gdbgui + /usr/bin/rust-lldb + /usr/lib/rustlib + /usr/lib/rust/lib + /usr/lib/rust/man + /usr/share/doc/rust + _EOF_ + + if use clippy; then + echo /usr/bin/clippy-driver >> "${T}/provider-${P}" + echo /usr/bin/cargo-clippy >> "${T}/provider-${P}" + fi + if [[ ${SLOT} == *9999* ]] && use miri; then + echo /usr/bin/miri >> "${T}/provider-${P}" + echo /usr/bin/cargo-miri >> "${T}/provider-${P}" + fi + if use rustfmt; then + echo /usr/bin/rustfmt >> "${T}/provider-${P}" + echo /usr/bin/cargo-fmt >> "${T}/provider-${P}" + fi + if use rust-analyzer; then + echo /usr/lib/rust/libexec >> "${T}/provider-${P}" + echo /usr/bin/rust-analyzer >> "${T}/provider-${P}" + fi + + insinto /etc/env.d/rust + doins "${T}/provider-${PN}-${SLOT}" + + if use dist; then + "${EPYTHON}" ./x.py dist -v --config="${S}"/bootstrap.toml -j$(makeopts_jobs) || die + insinto "/usr/lib/${PN}/${SLOT}/dist" + doins -r "${S}/build/dist/." + fi +} + +pkg_postinst() { + + eselect rust update + + if has_version dev-debug/gdb || has_version llvm-core/lldb; then + elog "Rust installs helper scripts for calling GDB and LLDB," + elog "for convenience they are installed under /usr/bin/rust-{gdb,lldb}-${PV}." + fi + + if has_version app-editors/emacs; then + optfeature "emacs support for rust" app-emacs/rust-mode + fi + + if has_version app-editors/gvim || has_version app-editors/vim; then + optfeature "vim support for rust" app-vim/rust-vim + fi +} + +pkg_postrm() { + eselect rust cleanup +} -- cgit v1.2.3