commit:     fa9d9ec18a62e14cd7f06ad703e989fcaa3bb907
Author:     orbea <orbea <AT> riseup <DOT> net>
AuthorDate: Wed Jun  1 22:29:42 2022 +0000
Commit:     Quentin Retornaz <gentoo <AT> retornaz <DOT> com>
CommitDate: Thu Jun  2 01:43:58 2022 +0000
URL:        https://gitweb.gentoo.org/repo/proj/libressl.git/commit/?id=fa9d9ec1

dev-lang/rust: Updated for version 1.61.0-r1

Signed-off-by: orbea <orbea <AT> riseup.net>
Signed-off-by: Quentin Retornaz <gentoo <AT> retornaz.com>

 dev-lang/rust/Manifest                             |  34 +
 .../files/1.61.0-gentoo-musl-target-specs.patch    | 166 +++++
 .../rust/files/1.61.0-llvm_addrspacecast.patch     |  52 ++
 .../files/1.61.0-llvm_selectInterleaveCount.patch  |  66 ++
 dev-lang/rust/files/1.61.0-miri-cow.patch          |  98 +++
 dev-lang/rust/rust-1.61.0-r1.ebuild                | 730 +++++++++++++++++++++
 6 files changed, 1146 insertions(+)

diff --git a/dev-lang/rust/Manifest b/dev-lang/rust/Manifest
index 69aba14..b10f97d 100644
--- a/dev-lang/rust/Manifest
+++ b/dev-lang/rust/Manifest
@@ -94,9 +94,43 @@ DIST rust-1.59.0-x86_64-unknown-linux-gnu.tar.xz 151858140 
BLAKE2B 80eda8c19361b
 DIST rust-1.59.0-x86_64-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
cd4387ad25b7f000395e336cdc92916ee7260cbf98a397ce02514444c8d2b35c653012ae6a9f1d5598155c06db573e1fe1a3f0bde1693863855dc17c18b478f5
 SHA512 
0b6790f0aa531a8251e1a19e0adfdb16bfd39fcec40b83094c26b7169f833114cc8679e2955fcc5359b05cd67564827aa231c521f81d4c41d561e9ef44eea713
 DIST rust-1.59.0-x86_64-unknown-linux-musl.tar.xz 246630236 BLAKE2B 
c9fe24e92055b2e765a8d96181c7c14a0db329f98e006ea2ade285078cad64fa2ef3419d26f30339685cfbcee672bb5e263dd183c960aa0067a27a0b36fe6fbd
 SHA512 
40a711c015fa8eb07aaa11b0698f20886928230a8441cc7523572c7c2768a52557daf5c02bdf61430dcb9a912b8eeda499794af28f269b319ca7fef848ae4cdd
 DIST rust-1.59.0-x86_64-unknown-linux-musl.tar.xz.asc 801 BLAKE2B 
1a96c49754b8670d243d1ad43478d4df8b4f4997490fa9691e3947260d469c7dc9bab192a20fd2ee0592e15785fb059644404d77d716d86b54038d0a76feaf6e
 SHA512 
0c67f2be31fae00a318b5a6184c60f10f80ca5275a5d9dad4459d94aef2fe65624dd7789987d506b691666ac8f7357143fa6bb8207cd5b13b28692aa909a1636
+DIST rust-1.60.0-aarch64-unknown-linux-gnu.tar.xz 225778104 BLAKE2B 
fafd690b1d6b161ba12f2e885e8dacd672999e34523634a2dc198363b6d46c9a5df9628052d4c76fe9c179f0d2d21eed6c9986cbf1cad0d95f42ec89edd6bcb3
 SHA512 
0357abc2f0e3512cbb0b113a7e80e5475ecaaa18f4713d08c1923567ba7ee35cb286e0b62ef564f56b88b183d31462743d041bc733b86c91eccaea29c9bdd61f
+DIST rust-1.60.0-aarch64-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
7ee4ca6c179fa41841b8da143582f3454073c62286043cc395611495149a097a48fd885f56ae3dd62220788cc4e235e0a2af9400797090e0e027f4133af275a4
 SHA512 
9059bf5cae423d0dcfaaed56f03a30c998962af3c0f84377bc3af9fed25afedb91f4dc2f40c51fa8d1360330c1a8fccba88b94f069500894fcd7b8ce7fc9b736
+DIST rust-1.60.0-aarch64-unknown-linux-musl.tar.xz 218828768 BLAKE2B 
b6cef5702c0bdc53cad81eb06b09213e90c1ecb89e2734b5bdbbf93969f809d5eec03f802cbaa15ddcd6b0a4a8f02b6027e232a13111a0002efac455ca42e8e7
 SHA512 
39de2073c1c393f4675c374b0bd7a75daa7c84e5635b9c50606da0ad7478e828120319a9fc79b534b88570a0408eb1745dbc0f7f4d15825e5f995e16752c5d10
+DIST rust-1.60.0-aarch64-unknown-linux-musl.tar.xz.asc 801 BLAKE2B 
655bb6cccc79034f83557b1336d6052523dd25420f9b54ca746946c259026a1e9dce8b5e84d6800dfbbc423dce3413d566de45c9f3424f24330d732f3702d2b5
 SHA512 
ce3131c15a31eb41b6905c3197bd3989a436ea503f9285146dc1c87c1e1f5bc6a606fb3a7ee52fe564bf8196d5eb71fd8325f63a36956d1a2b29d285ff84874f
+DIST rust-1.60.0-arm-unknown-linux-gnueabi.tar.xz 199199568 BLAKE2B 
9fbae45558e5b5ee6c0f025430e355ccf2c9bcf8584eb3ca763e5eccd19a9a89b5b466fbcfa0182810b2bdf764a8ece9277a7bf9b9ae1792e442b6930d769c76
 SHA512 
b14e1e6e3ca58840f2b44473ea7e20afe61f813c6bce7a380d97cf32d9e915a0e369ca1709b2d7207f38ccc4d19db8268412e4dc991cb23612989111677d9fac
+DIST rust-1.60.0-arm-unknown-linux-gnueabi.tar.xz.asc 801 BLAKE2B 
c79602c7ebfd8789d5c4a8800462b62104f20bfbb9cd07a62ea02faa4721c291de0cd2e877ccaa586c83efd60daaeeb9bf1b6aa0d50c9e8cbbf1e1c76beb8f8b
 SHA512 
58ac1ceec97354aeb020bb8380c0950237052c84188259740335cac235556e7db620ac17861adb065adf4eb90f5dd67af64c7f5247fc5d965633a949eac41de2
+DIST rust-1.60.0-arm-unknown-linux-gnueabihf.tar.xz 199155728 BLAKE2B 
d7bb8b89acc6ae96e9dc88753e03d213456204f1e42e9142c3cf307e68c3fe9039271a87b95f2dd37255249e91239d28571b0eacfaee533c8be2f1f33ee0ed09
 SHA512 
8b4e8fc0824001973bb508341d10b81b5c9ca785e07be2bd9a9cd14a4337983a75dd0e224518adea717a6645a94a7af9c3a51f226acada05d98dc2ee925753c1
+DIST rust-1.60.0-arm-unknown-linux-gnueabihf.tar.xz.asc 801 BLAKE2B 
3976db6e470d120b17b782eb47e8b13d019891a9ae77d0c160ab00dad266a285e72426f4918e0918817243e77f5243a1d840190611d906a259de0592e85b1eae
 SHA512 
e363c8e0dfde0b044a3f7a3a7d9b0f589684019f4a7a81ad5d39ca40662c8b9350dffe26cd8e7f7df5b39b04cb543777e066b71b0b5da393bb2310c51720e3c9
+DIST rust-1.60.0-armv7-unknown-linux-gnueabihf.tar.xz 204846992 BLAKE2B 
1781fcc2f7e079c68230154523e69d4211aac4248a09e10ff05237f67c6d82db91aa3e933d057f68a9c2adbf71be0dd91a053442e0777862f597a7202909c62c
 SHA512 
6cc28ac4430acef8929ec9f9acfef8fa3f0c79758fdd612eb3d0e762986ae7722c3b92dd687be754453a86ecc253341efe2e517e41510bed53e539e79ad21ecf
+DIST rust-1.60.0-armv7-unknown-linux-gnueabihf.tar.xz.asc 801 BLAKE2B 
e7adda090a966ad9a2a68b2f7ad3f1a22cee06a5ac02b5f949593e50eecc044dc13552a6299a9c0fb8383e839bb04a6ac16aecc4cc6735c2ffb91e3d244fd71d
 SHA512 
b1a471eaba9f9a4eeb066680b78f4b02cf9d0620b2bcf4e9f07112fb6100acad7f519e149a105fced5cb0e2a91b845d3d682af53ea135af9901dac973c4c5c7b
+DIST rust-1.60.0-i686-unknown-linux-gnu.tar.xz 217159392 BLAKE2B 
18321f1eeff6607eea9bc1f7de571062c3fac1a68bdfc694db8c504331119a86cf8c08f1e1ae32c855d37367bf92de70c9465404e51485d335c530dbadc90c66
 SHA512 
5a1e9f0d7f623af1c46884a23eb5c38927ab9a9b87c9b4f511aa727ee4bd77987358f6211f2a3c6743b01a9695f0823d443069d3020772a87c834141d73e3b05
+DIST rust-1.60.0-i686-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
09068dbc9cec3164beb94d667bb359295f98578e2eb31e5fde1fafefa58831c2858dc45736aea3daaf6cf3f3620bfc40c0af3a246655618cbca2b733f73ee171
 SHA512 
d237bda70a0b297505d6dcf968330ac8622af77a53241de707d57f265d4762fcbf34fae329c02d2f7f18b97df843f78938f4413425d0d57183cd5bf59aae3e3d
+DIST rust-1.60.0-mips-unknown-linux-gnu.tar.xz 155895536 BLAKE2B 
87fcc3fb92762e3e1e4e29eeff0c556a07b9fb36cc275cd1e74e4411e89a82d1aaf1cda7859b32696b239091758cc54f0d763b14ee1d42898cc4aa3fb37dc6ee
 SHA512 
28e28f4cf077f93a21282756bf69c3ccae2f9e975145cb35b36bf28a3a0ffdafd1dd9c775816f20a2aec557551efc3b4a9c644cff06473fab440e65357aec1b4
+DIST rust-1.60.0-mips-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
98d5e30917b86aa9bbdb2e0aaa98b19a946320f09331aa4194f1f1536148dc098aefb34646dfed7216d024db8d408901db24663e52414c1d618afc55bd12b97c
 SHA512 
b6e98fbda5d865b8766e62ab9d21bd8d0f1a0796748b12f59988fe66db26d0df3afbc8dbd5ef312224dc81778a799dca57cd05caf4e5f1560a8ff1eb4b3243b4
+DIST rust-1.60.0-mips64-unknown-linux-gnuabi64.tar.xz 161602984 BLAKE2B 
dd2cd07e800b8c53fc6f0fd1d932c58c1d23776a35ac7c10df7b79d8e3c3f401bfcfd87d2740053fcf6b30e314d248ad39f1084ec35008d58676c0c1ecffd323
 SHA512 
2074e4823d1c4f8e2730eca07f8f5d120a1212c67c374c9aa2a167e517779709ebe6b6c33113ac6048bd2ff28c63f6086a0c458830c6cce2e27a1e1ea0e7c9fb
+DIST rust-1.60.0-mips64-unknown-linux-gnuabi64.tar.xz.asc 801 BLAKE2B 
75d23db39da3fda6ac1cabbab84904d9f9a7c0b3c58081f8cfd6952a6df012aba1788a5008fba6156a410b28fd9aec8eb946e24a6217d35023579b8ceb362b63
 SHA512 
eeca039bc3a7610d7ef8a786fc280c18314aa5c5f83b2647fd5130d89b62eeef5e3bc73d140999c0e8b4b2af2efaed27c4dcb20b21a43ccec49c79c76573a73c
+DIST rust-1.60.0-mipsel-unknown-linux-gnu.tar.xz 160546356 BLAKE2B 
1e56b520727f7b6f1e2158db55638b4b8c3ce646ecfcc13a9c511defcfe3aca056ac002ea7e2d5c673594cc9b1611667b1d243766c8b53beefbee7e7f093cba4
 SHA512 
2c48d13fdaa1071f65796edc8193d1fb9be1a5bfb3e349a9bf5f518e02b9d8a0042c0c39ae159e914368f7150ac67b7be9fd115ef5e878bf06651a3f6760e4f5
+DIST rust-1.60.0-mipsel-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
2297dd2504735c78fcd6c7e69b1884215db06ae1fbcd31fc8b07586eba10a7f861ba16209be608e3302b3e48f9eaa748d2990fbc4cc21720b705ff67e4dad533
 SHA512 
2972c5ea07d7336c554a232fa7adef474fcdf1b5da8f584e200c303210d248d5acc963646e4fd7c3085fe74b96c6ed4d75607d6fe134247b7932a615b1bb15c9
+DIST rust-1.60.0-powerpc-unknown-linux-gnu.tar.xz 179198588 BLAKE2B 
ffb68761fce839412eb7147c44732f275e27c0e67894b41128936f1ef05e19c9120b3decab6fdb16924688799f035d0c261500651b6eacc415bf65759f246e53
 SHA512 
0233c9381ff27642fe76ad856af9f51257b25c6a428255dc9c1c9c9993fcc943f551244f07838541d63a99c0481d95fad3749921dbc6766378d313f49e7e1dc8
+DIST rust-1.60.0-powerpc-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
c35cb2d813e578464af34f5a3597d7a88009041c04ca32c57f0daf5953b27ee5c7ffde98da6d6ae85dda07559391c0bcbdb5c1c92d41159f8fa79d7a8d3c2345
 SHA512 
9fba91f8f84bd677ce44dbb3206e87308ac7337115b312904cb199caa3ebbf4d1efc53eb27da38829f5b41b6b6078309386be7f6dd8ee33f6f67e7aecd077c1f
+DIST rust-1.60.0-powerpc64-unknown-linux-gnu.tar.xz 185903604 BLAKE2B 
bea00626f9278c2f67ddd44dca6a7fd4931f1c3a5b76eb70a2b98717425a7f8439efc3de19d555ceba5b83e0262de77e043771e3c31cbc2a0e09264a5b607c7c
 SHA512 
002f8ea3d25ca9c57c66fd027a903cafdec199ab8d7f63c68b1d7b8bb9607b2eb69ce98d322ebcb8476bcb8e28d292f285925b7a2f2ffe23fc45b9a626420675
+DIST rust-1.60.0-powerpc64-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
419738f90082f4ff68f6b01c0d6ef467fb856dea7320cc70b07ce569adb712673e09d632156927603e9577d6c88d0b2409c9b9e5edce0a2ad60f17b7489d346c
 SHA512 
b060a7909ae72d7f92e0a99362c38be20ea4d2e2a68c3e502d1fcf1f667a8bf80d117e67c8ae3922dda35214b0cd091b53085603f89952c4647fced34c9d52fa
+DIST rust-1.60.0-powerpc64le-unknown-linux-gnu.tar.xz 195616532 BLAKE2B 
4f69ee1719874789b309f4ff098e96848e496acc1a5c126296ecaa3b021b5fca6c7b2995ea121482d7a282c86a988c0f28275f7474f7a63e5877819e3c8a57b2
 SHA512 
6259fa02a62008c63874405be80f3ab7b3d8564b71d18297857cf80db417792a3215fd85e53b297823bc9dc8968d5e035a1b959671a039391616ed62bd48cbd9
+DIST rust-1.60.0-powerpc64le-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
27461458d3fc0c65d25ed310269e52acb1d332411af32922a418dc32c9998653411e68daae8dee81f595b52a0176f517cb2d57ca7c438cd1cce91ad44c376b3e
 SHA512 
6edc6ced24d85faf12000cad3d21b8da93635f88c1e6c8ab0614313f04ca466489f84e6acc3f0d35e42f9430499123cddbd48c474554fc408d50df17714a65fa
+DIST rust-1.60.0-riscv64gc-unknown-linux-gnu.tar.xz 188464956 BLAKE2B 
ea9fb3e59ad558b0a704a84d54f555717d4f158b1d15e3577e6411becdebb86144cd78500521fdeacf38e4301ec86db088822c19a608a8808b9a7c2172befc41
 SHA512 
41c12e2a0a2a4f63d8ef321e30ded7cd9fedf732699e73e7ada32590c13ead6805cee7b089858eb7ce340ad6e55d364eb700c35efbd640b126b811f27ab6e395
+DIST rust-1.60.0-riscv64gc-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
9dca4b3ba2949e04c94ad57e14f576bb34e1c9966c9954ebee7549a5fa6a6fba57000138128bf12f93a0cec59715cd32dde7242c363c3de265e7f95ad8fd44b9
 SHA512 
2601feb20c211ae55fd051225d1b1c209e40c4d23c4dc79b5d85ca0b21de833fb8432fcd45fefc1484ca5987660e6625d1a6c69cdd4d05b2f84212bca1f82611
+DIST rust-1.60.0-s390x-unknown-linux-gnu.tar.xz 187797152 BLAKE2B 
5a86b4bce61d65d29769b652d030f936adf669986aba91f1cf09edcc346942acc2bfa26bd568635889e89a1059eea988eef9ad300469b416eaf87e8d97b2cd15
 SHA512 
6be266c6191f35c1525618e986e1725b0e8b306990deeef5cda7aff4f5999680e84597a00d4c2c38099131604f436529420ebf4515501df1328dbe3118637ae4
+DIST rust-1.60.0-s390x-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
5460b62ec3b461ce4d92b57debfc82329ec19ce5c38ce2a72e9700e9d4da767134738148d12fbeb0d6ef74f2dbfbba132571c9a8925b007d19432eecbf57b381
 SHA512 
1c285460c49be405361ef5ed2dbf9f720e7a9fce4d34b16aa5b2f29afa4fcc399f252b48cb4cf05e95a57869455a31ab5237deefe4e900c03ad3dd5887e70ea9
+DIST rust-1.60.0-x86_64-unknown-linux-gnu.tar.xz 154271340 BLAKE2B 
7ee48c165e6ec7a6cbc49c46bc4a7eee735988808866024de87eec2312427d939158e03e443cc537034110e640c19fc920458f8259ee022f3aa9eaa617207d55
 SHA512 
d27f1d78b2535f9acbd8af079b853f0590725c9f5db31ac074685f2722f0270a9f8d417abc6af8be413598315c568333e3011ea07eef9c47a5c4e328a39aee47
+DIST rust-1.60.0-x86_64-unknown-linux-gnu.tar.xz.asc 801 BLAKE2B 
7454407a16e2b6c89226252c7e706086c9bb8016183df1180c54e88ec0d6622a0829d4acda959a093702bb1d95d4f2678976ced69fcc219afb42ab631e459d40
 SHA512 
eb3550e27e361860075a22d9b4821c6d078d7e4c82ad688a64e813adbce9922b9ab2dc64d1fd4d74d20be9af122ff05819d521677a43ad1c1092bd498d325a8a
+DIST rust-1.60.0-x86_64-unknown-linux-musl.tar.xz 258420992 BLAKE2B 
6b446c06fd8d511910110eccfd55c1116f3468ffe87274d6b90c7a2a1ccd298471f62d1bfb807ddab2f66fbac58995e903414455c76fe2b14c9659f00e8413a0
 SHA512 
6f5a53968f44bf7be563d32eaddea439d8f388858db3d3b58a89b22cc2252e195b56b0e8895f4254c40274035e221657504958c8f1e331befca012d480118f3b
+DIST rust-1.60.0-x86_64-unknown-linux-musl.tar.xz.asc 801 BLAKE2B 
680e7267a188a5286938d9c3284968121a7783cba196bf863affd6b927344e1a88cf7b97016d53c74560179439fc7fe9dd700a295c7c00b139472320323861cb
 SHA512 
071efcfad0074a03de454835c512e98b466662b27bef2fb31def0bb82531b4048eba59a529621fda515800e19c4f3c62a33a364ecca8cecbaa09fae842b894b6
 DIST rustc-1.58.1-src.tar.xz 124353160 BLAKE2B 
686c7272db544ad46f7fb01b4e05f24f4e08ff959a000cadfaef5d8fc413b93f5ed839077bc9715defc7a0a179af091f65c7a5d7104b0b3153f0654c237c094b
 SHA512 
eff3279d2e519343cea542a9ae2daab592e44f35af344e33ff43ed55fc7c824511790d1991dd36a603d12465de8c3688e7194c2b9557f288c587ffa04738c2ce
 DIST rustc-1.58.1-src.tar.xz.asc 801 BLAKE2B 
f0b600a503b0ca777dd5d690dca7252ecc6d7d49ca4a9cc8edc0647038f727e9052a861f9868292f837d78d6b02efe9ed5efa85843262c44cf6f73254cc7c9b0
 SHA512 
983c1ffdc4febf8bce6efc123c76b13f233772bc0a152ffaeb7ebf8f1f7b82a6b5d653407a4d293953d6fbf62c0df4ff4d398a1133061b53ae0f85317a14380b
 DIST rustc-1.59.0-src.tar.xz 128942756 BLAKE2B 
b28114f14c9a0fec7db56fde79a985360fd8438c3b14eede49ed12e540c2636be960d0fd800c569af193886ac76fe8bf604d5dae59214ae08cb0cc6cc0ca404e
 SHA512 
acace866871d13a55d365f65d7e15c192c3cd33096862571df6317e066b7474d668b95ae281e0244967778c05f1e33966c3c55616218bd25d3770a2b2d4f0365
 DIST rustc-1.59.0-src.tar.xz.asc 801 BLAKE2B 
061701c4fdbde930798f9f938ca3642204ae4a2ad9396937ca7d604268813d6d68f4979f20d35abdbbfeec0bb389acd86c9d3d84256db85861f6b11e3dbef80e
 SHA512 
1b90bc01f9d68ba1f70591c4ae707295d7727b790d170a0b757d654684e59d3c26c45b66a21f9ac762debb6867494660c73daaf10be9bd567a38be44c0009f72
 DIST rustc-1.60.0-src.tar.xz 136183048 BLAKE2B 
8030f32c21f81af6abc7a282aab1189cb7d680c6bce58c119a1beaad71a3eeb36a696eef46a22d366e2c41a2f9182a9a5aa527426f2c8db05278184c37297dd0
 SHA512 
d0c113e8c2c67bf10773c9403dc4c4700c4deb2fb287bfec51e565d3473d2b481d8ae2c90b272cd67b3a87d7443ea25a34c7b40ba8cd7106bf5d71126ab141c3
 DIST rustc-1.60.0-src.tar.xz.asc 801 BLAKE2B 
02a2c140e091ea6913a760daa93aa57ba6a7631d0b99867669ce68641d562d436f13ed1f1578713184f06c9307d46e19dfd7c8d74a516b04293bc65c02b90707
 SHA512 
8136d19d4f3f4c45249b59b689f01d4edf108535ffe1f813771bd244cde1c66184a0bde5a0acfed4fb01015812458204244bbb54e6f5fa86e9b1ef5e92e805e3
+DIST rustc-1.61.0-src.tar.xz 136696780 BLAKE2B 
604299aa5c8dd7dff9802236898ca5d4fda8c54028d0aa557a6fe34c15941eb6e8c1dc5d2e172cd3680152ed1ff3fa9e58eb9b6a3b6f8f4ccccd949d810d31a7
 SHA512 
9bbdcc1c37f7b889be0c8d195963b4c3b65267a63ea309315eda12bd3b2cd36e0060301805dfc7da440c0a8702d085ccb0bf763155b27035a078769333637fb3
+DIST rustc-1.61.0-src.tar.xz.asc 801 BLAKE2B 
46384fd77c72ecf5cd7c783655f9345e4d52718c737470548a9f3498af9cbb93c3bf618464507cd10185c39a5207fd6669c6c82841c8c82fa325001cbe659cb0
 SHA512 
5ea807254f0d7c207f10f1fb224101d9ae3a3c81aff16d2ba2ea4af1fe92345d1a25336b5cff0964aba9ed249e38ab9d3df41eb1217e048988093cdb46da8962

diff --git a/dev-lang/rust/files/1.61.0-gentoo-musl-target-specs.patch 
b/dev-lang/rust/files/1.61.0-gentoo-musl-target-specs.patch
new file mode 100644
index 0000000..9701481
--- /dev/null
+++ b/dev-lang/rust/files/1.61.0-gentoo-musl-target-specs.patch
@@ -0,0 +1,166 @@
+From 331c3839ebb0099101e1d2f88205ea42f4e3b319 Mon Sep 17 00:00:00 2001
+From: Georgy Yakovlev <gyakov...@gentoo.org>
+Date: Tue, 24 May 2022 12:03:20 -0700
+Subject: [PATCH] add gentoo musl target specs
+
+---
+ .../src/spec/aarch64_gentoo_linux_musl.rs     |   11 +
+ .../src/spec/armv7_gentoo_linux_musleabihf.rs |   11 +
+ .../src/spec/i686_gentoo_linux_musl.rs        |   11 +
+ compiler/rustc_target/src/spec/mod.rs         |    8 +
+ compiler/rustc_target/src/spec/mod.rs.orig    | 2465 +++++++++++++++++
+ .../src/spec/powerpc64_gentoo_linux_musl.rs   |   11 +
+ .../src/spec/powerpc64le_gentoo_linux_musl.rs |   11 +
+ .../src/spec/powerpc_gentoo_linux_musl.rs     |   11 +
+ .../src/spec/x86_64_gentoo_linux_musl.rs      |   11 +
+ 9 files changed, 2550 insertions(+)
+ create mode 100644 compiler/rustc_target/src/spec/aarch64_gentoo_linux_musl.rs
+ create mode 100644 
compiler/rustc_target/src/spec/armv7_gentoo_linux_musleabihf.rs
+ create mode 100644 compiler/rustc_target/src/spec/i686_gentoo_linux_musl.rs
+ create mode 100644 compiler/rustc_target/src/spec/mod.rs.orig
+ create mode 100644 
compiler/rustc_target/src/spec/powerpc64_gentoo_linux_musl.rs
+ create mode 100644 
compiler/rustc_target/src/spec/powerpc64le_gentoo_linux_musl.rs
+ create mode 100644 compiler/rustc_target/src/spec/powerpc_gentoo_linux_musl.rs
+ create mode 100644 compiler/rustc_target/src/spec/x86_64_gentoo_linux_musl.rs
+
+diff --git a/compiler/rustc_target/src/spec/aarch64_gentoo_linux_musl.rs 
b/compiler/rustc_target/src/spec/aarch64_gentoo_linux_musl.rs
+new file mode 100644
+index 0000000..ca5f28f
+--- /dev/null
++++ b/compiler/rustc_target/src/spec/aarch64_gentoo_linux_musl.rs
+@@ -0,0 +1,11 @@
++use crate::spec::Target;
++
++pub fn target() -> Target {
++    let mut base = super::aarch64_unknown_linux_musl::target();
++
++    base.llvm_target = "aarch64-gentoo-linux-musl".into();
++    base.options.vendor = "gentoo".into();
++    base.options.crt_static_default = false;
++
++    base
++}
+diff --git a/compiler/rustc_target/src/spec/armv7_gentoo_linux_musleabihf.rs 
b/compiler/rustc_target/src/spec/armv7_gentoo_linux_musleabihf.rs
+new file mode 100644
+index 0000000..24b3b30
+--- /dev/null
++++ b/compiler/rustc_target/src/spec/armv7_gentoo_linux_musleabihf.rs
+@@ -0,0 +1,11 @@
++use crate::spec::Target;
++
++pub fn target() -> Target {
++    let mut base = super::armv7_unknown_linux_musleabihf::target();
++
++    base.llvm_target = "armv7-gentoo-linux-musleabihf".into();
++    base.options.vendor = "gentoo".into();
++    base.options.crt_static_default = false;
++
++    base
++}
+diff --git a/compiler/rustc_target/src/spec/i686_gentoo_linux_musl.rs 
b/compiler/rustc_target/src/spec/i686_gentoo_linux_musl.rs
+new file mode 100644
+index 0000000..cab0923
+--- /dev/null
++++ b/compiler/rustc_target/src/spec/i686_gentoo_linux_musl.rs
+@@ -0,0 +1,11 @@
++use crate::spec::Target;
++
++pub fn target() -> Target {
++    let mut base = super::i686_unknown_linux_musl::target();
++
++    base.llvm_target = "i686-gentoo-linux-musl".into();
++    base.options.vendor = "gentoo".into();
++    base.options.crt_static_default = false;
++
++    base
++}
+diff --git a/compiler/rustc_target/src/spec/mod.rs 
b/compiler/rustc_target/src/spec/mod.rs
+index bd5b712..34b923b 100644
+--- a/compiler/rustc_target/src/spec/mod.rs
++++ b/compiler/rustc_target/src/spec/mod.rs
+@@ -808,6 +808,14 @@ macro_rules! supported_targets {
+ }
+ 
+ supported_targets! {
++    ("aarch64-gentoo-linux-musl", aarch64_gentoo_linux_musl),
++    ("armv7-gentoo-linux-musleabihf", armv7_gentoo_linux_musleabihf),
++    ("i686-gentoo-linux-musl", i686_gentoo_linux_musl),
++    ("powerpc-gentoo-linux-musl", powerpc_gentoo_linux_musl),
++    ("powerpc64-gentoo-linux-musl", powerpc64_gentoo_linux_musl),
++    ("powerpc64le-gentoo-linux-musl", powerpc64le_gentoo_linux_musl),
++    ("x86_64-gentoo-linux-musl", x86_64_gentoo_linux_musl),
++
+     ("x86_64-unknown-linux-gnu", x86_64_unknown_linux_gnu),
+     ("x86_64-unknown-linux-gnux32", x86_64_unknown_linux_gnux32),
+     ("i686-unknown-linux-gnu", i686_unknown_linux_gnu),
+diff --git a/compiler/rustc_target/src/spec/powerpc64_gentoo_linux_musl.rs 
b/compiler/rustc_target/src/spec/powerpc64_gentoo_linux_musl.rs
+new file mode 100644
+index 0000000..b188a7c
+--- /dev/null
++++ b/compiler/rustc_target/src/spec/powerpc64_gentoo_linux_musl.rs
+@@ -0,0 +1,11 @@
++use crate::spec::Target;
++
++pub fn target() -> Target {
++    let mut base = super::powerpc64_unknown_linux_musl::target();
++
++    base.llvm_target = "powerpc64-gentoo-linux-musl".into();
++    base.options.vendor = "gentoo".into();
++    base.options.crt_static_default = false;
++
++    base
++}
+diff --git a/compiler/rustc_target/src/spec/powerpc64le_gentoo_linux_musl.rs 
b/compiler/rustc_target/src/spec/powerpc64le_gentoo_linux_musl.rs
+new file mode 100644
+index 0000000..395f603
+--- /dev/null
++++ b/compiler/rustc_target/src/spec/powerpc64le_gentoo_linux_musl.rs
+@@ -0,0 +1,11 @@
++use crate::spec::Target;
++
++pub fn target() -> Target {
++    let mut base = super::powerpc64le_unknown_linux_musl::target();
++
++    base.llvm_target = "powerpc64le-gentoo-linux-musl".into();
++    base.options.vendor = "gentoo".into();
++    base.options.crt_static_default = false;
++
++    base
++}
+diff --git a/compiler/rustc_target/src/spec/powerpc_gentoo_linux_musl.rs 
b/compiler/rustc_target/src/spec/powerpc_gentoo_linux_musl.rs
+new file mode 100644
+index 0000000..cb3121d
+--- /dev/null
++++ b/compiler/rustc_target/src/spec/powerpc_gentoo_linux_musl.rs
+@@ -0,0 +1,11 @@
++use crate::spec::Target;
++
++pub fn target() -> Target {
++    let mut base = super::powerpc_unknown_linux_musl::target();
++
++    base.llvm_target = "powerpc-gentoo-linux-musl".into();
++    base.options.vendor = "gentoo".into();
++    base.options.crt_static_default = false;
++
++    base
++}
+diff --git a/compiler/rustc_target/src/spec/x86_64_gentoo_linux_musl.rs 
b/compiler/rustc_target/src/spec/x86_64_gentoo_linux_musl.rs
+new file mode 100644
+index 0000000..2fcdb66
+--- /dev/null
++++ b/compiler/rustc_target/src/spec/x86_64_gentoo_linux_musl.rs
+@@ -0,0 +1,11 @@
++use crate::spec::Target;
++
++pub fn target() -> Target {
++    let mut base = super::x86_64_unknown_linux_musl::target();
++
++    base.llvm_target = "x86_64-gentoo-linux-musl".into();
++    base.options.vendor = "gentoo".into();
++    base.options.crt_static_default = false;
++
++    base
++}
+-- 
+2.35.1
+

diff --git a/dev-lang/rust/files/1.61.0-llvm_addrspacecast.patch 
b/dev-lang/rust/files/1.61.0-llvm_addrspacecast.patch
new file mode 100644
index 0000000..9f2ca6f
--- /dev/null
+++ b/dev-lang/rust/files/1.61.0-llvm_addrspacecast.patch
@@ -0,0 +1,52 @@
+From 67a290460c374d5e0d18a06c798896cac0b19e59 Mon Sep 17 00:00:00 2001
+From: Fraser Cormack <fra...@codeplay.com>
+Date: Wed, 16 Mar 2022 10:14:07 +0000
+Subject: [PATCH] [VectorCombine] Insert addrspacecast when crossing address
+ space boundaries
+
+We can not bitcast pointers across different address spaces. This was
+previously fixed in D89577 but then in D93229 an enhancement was added
+which peeks further through the ponter operand, opening up the
+possibility that address-space violations could be introduced.
+
+Instead of bailing as the previous fix did, simply insert an
+addrspacecast cast instruction.
+
+Reviewed By: lebedev.ri
+
+Differential Revision: https://reviews.llvm.org/D121787
+
+(cherry picked from commit 2e44b7872bc638ed884ae4aa86e38b3b47e0b65a)
+---
+ llvm/lib/Transforms/Vectorize/VectorCombine.cpp |  8 ++------
+ .../AMDGPU/as-transition-inseltpoison.ll        |  4 +---
+ .../VectorCombine/AMDGPU/as-transition.ll       |  4 +---
+ .../VectorCombine/X86/load-inseltpoison.ll      | 17 +++++++++++++++++
+ 4 files changed, 21 insertions(+), 12 deletions(-)
+
+diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp 
b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+index 620d388199e0..258f6c67e54d 100644
+--- a/src/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
++++ b/src/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+@@ -152,12 +152,7 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
+   Value *SrcPtr = Load->getPointerOperand()->stripPointerCasts();
+   assert(isa<PointerType>(SrcPtr->getType()) && "Expected a pointer type");
+ 
+-  // If original AS != Load's AS, we can't bitcast the original pointer and 
have
+-  // to use Load's operand instead. Ideally we would want to strip pointer 
casts
+-  // without changing AS, but there's no API to do that ATM.
+   unsigned AS = Load->getPointerAddressSpace();
+-  if (AS != SrcPtr->getType()->getPointerAddressSpace())
+-    SrcPtr = Load->getPointerOperand();
+ 
+   // We are potentially transforming byte-sized (8-bit) memory accesses, so 
make
+   // sure we have all of our type-based constraints in place for this target.
+@@ -245,7 +240,8 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
+   // It is safe and potentially profitable to load a vector directly:
+   // inselt undef, load Scalar, 0 --> load VecPtr
+   IRBuilder<> Builder(Load);
+-  Value *CastedPtr = Builder.CreateBitCast(SrcPtr, 
MinVecTy->getPointerTo(AS));
++  Value *CastedPtr = Builder.CreatePointerBitCastOrAddrSpaceCast(
++      SrcPtr, MinVecTy->getPointerTo(AS));
+   Value *VecLd = Builder.CreateAlignedLoad(MinVecTy, CastedPtr, Alignment);
+   VecLd = Builder.CreateShuffleVector(VecLd, Mask);

diff --git a/dev-lang/rust/files/1.61.0-llvm_selectInterleaveCount.patch 
b/dev-lang/rust/files/1.61.0-llvm_selectInterleaveCount.patch
new file mode 100644
index 0000000..71a4e8d
--- /dev/null
+++ b/dev-lang/rust/files/1.61.0-llvm_selectInterleaveCount.patch
@@ -0,0 +1,66 @@
+From fe8a27acd716a42667f5a572f52f2b04636010ff Mon Sep 17 00:00:00 2001
+From: Florian Hahn <f...@fhahn.com>
+Date: Tue, 29 Mar 2022 22:52:42 +0100
+Subject: [PATCH] [LV] Handle zero cost loops in selectInterleaveCount.
+
+In some case, like in the added test case, we can reach
+selectInterleaveCount with loops that actually have a cost of 0.
+
+Unfortunately a loop cost of 0 is also used to communicate that the cost
+has not been computed yet. To resolve the crash, bail out if the cost
+remains zero after computing it.
+
+This seems like the best option, as there are multiple code paths that
+return a cost of 0 to force a computation in selectInterleaveCount.
+Computing the cost at multiple places up front there would unnecessarily
+complicate the logic.
+
+Fixes #54413.
+
+(cherry picked from commit ecb4171dcbf1b433c9963fd605a74898303e850d)
+---
+ .../Transforms/Vectorize/LoopVectorize.cpp    | 22 ++++----
+ ...ct-interleave-count-loop-with-cost-zero.ll | 50 +++++++++++++++++++
+ 2 files changed, 62 insertions(+), 10 deletions(-)
+ create mode 100644 
llvm/test/Transforms/LoopVectorize/X86/pr54413-select-interleave-count-loop-with-cost-zero.ll
+
+diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+index 21c16f07e237..e1cc7946073e 100644
+--- a/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
++++ b/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+@@ -6035,6 +6035,18 @@ unsigned 
LoopVectorizationCostModel::selectInterleaveCount(ElementCount VF,
+       !(InterleaveSmallLoopScalarReduction && HasReductions && VF.isScalar()))
+     return 1;
+ 
++  // If we did not calculate the cost for VF (because the user selected the 
VF)
++  // then we calculate the cost of VF here.
++  if (LoopCost == 0) {
++    InstructionCost C = expectedCost(VF).first;
++    assert(C.isValid() && "Expected to have chosen a VF with valid cost");
++    LoopCost = *C.getValue();
++
++    // Loop body is free and there is no need for interleaving.
++    if (LoopCost == 0)
++      return 1;
++  }
++
+   RegisterUsage R = calculateRegisterUsage({VF})[0];
+   // We divide by these constants so assume that we have at least one
+   // instruction that uses at least one register.
+@@ -6126,16 +6138,6 @@ unsigned 
LoopVectorizationCostModel::selectInterleaveCount(ElementCount VF,
+ 
+   assert(IC > 0 && "Interleave count must be greater than 0.");
+ 
+-  // If we did not calculate the cost for VF (because the user selected the 
VF)
+-  // then we calculate the cost of VF here.
+-  if (LoopCost == 0) {
+-    InstructionCost C = expectedCost(VF).first;
+-    assert(C.isValid() && "Expected to have chosen a VF with valid cost");
+-    LoopCost = *C.getValue();
+-  }
+-
+-  assert(LoopCost && "Non-zero loop cost expected");
+-
+   // Interleave if we vectorized this loop and there is a reduction that could
+   // benefit from interleaving.
+   if (VF.isVector() && HasReductions) {

diff --git a/dev-lang/rust/files/1.61.0-miri-cow.patch 
b/dev-lang/rust/files/1.61.0-miri-cow.patch
new file mode 100644
index 0000000..fc46973
--- /dev/null
+++ b/dev-lang/rust/files/1.61.0-miri-cow.patch
@@ -0,0 +1,98 @@
+From 830cc58f8a10598f4caa337ca97be51741945499 Mon Sep 17 00:00:00 2001
+From: Ralf Jung <p...@ralfj.de>
+Date: Sun, 3 Apr 2022 20:00:03 -0400
+Subject: [PATCH] rustup
+
+gyakovlev: changed paths and removed irrelevant bits
+---
+ rust-version                     | 2 +-
+ src/helpers.rs                   | 4 ++--
+ src/machine.rs                   | 2 +-
+ src/shims/env.rs                 | 2 +-
+ src/shims/foreign_items.rs       | 4 ++--
+ src/shims/posix/foreign_items.rs | 2 +-
+ 6 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/src/helpers.rs b/src/helpers.rs
+index 3ffb983aa..7a63bb03d 100644
+--- a/src/tools/miri/src/helpers.rs
++++ b/src/tools/miri/src/helpers.rs
+@@ -510,7 +510,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: 
crate::MiriEvalContextExt<'mir, 'tcx
+         let this = self.eval_context_mut();
+         let target = &this.tcx.sess.target;
+         let target_os = &target.os;
+-        let last_error = if target.families.contains(&"unix".to_owned()) {
++        let last_error = if target.families.iter().any(|f| f == "unix") {
+             this.eval_libc(match err_kind {
+                 ConnectionRefused => "ECONNREFUSED",
+                 ConnectionReset => "ECONNRESET",
+@@ -534,7 +534,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: 
crate::MiriEvalContextExt<'mir, 'tcx
+                     )
+                 }
+             })?
+-        } else if target.families.contains(&"windows".to_owned()) {
++        } else if target.families.iter().any(|f| f == "windows") {
+             // FIXME: we have to finish implementing the Windows equivalent 
of this.
+             this.eval_windows(
+                 "c",
+diff --git a/src/machine.rs b/src/machine.rs
+index e9ed50724..b4b07a61a 100644
+--- a/src/tools/miri/src/machine.rs
++++ b/src/tools/miri/src/machine.rs
+@@ -227,7 +227,7 @@ impl MemoryExtra {
+     pub fn init_extern_statics<'tcx, 'mir>(
+         this: &mut MiriEvalContext<'mir, 'tcx>,
+     ) -> InterpResult<'tcx> {
+-        match this.tcx.sess.target.os.as_str() {
++        match this.tcx.sess.target.os.as_ref() {
+             "linux" => {
+                 // "environ"
+                 Self::add_extern_static(
+diff --git a/src/shims/env.rs b/src/shims/env.rs
+index c2050647a..822bef56c 100644
+--- a/src/tools/miri/src/shims/env.rs
++++ b/src/src/tools/miri/shims/env.rs
+@@ -41,7 +41,7 @@ impl<'tcx> EnvVars<'tcx> {
+         mut excluded_env_vars: Vec<String>,
+         forwarded_env_vars: Vec<String>,
+     ) -> InterpResult<'tcx> {
+-        let target_os = ecx.tcx.sess.target.os.as_str();
++        let target_os = ecx.tcx.sess.target.os.as_ref();
+         // HACK: Exclude `TERM` var to avoid terminfo trying to open the 
termcap file.
+         // This is (a) very slow and (b) does not work on Windows.
+         excluded_env_vars.push("TERM".to_owned());
+diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs
+index ecffd310d..d9e4d9382 100644
+--- a/src/tools/miri/src/shims/foreign_items.rs
++++ b/src/tools/miri/src/shims/foreign_items.rs
+@@ -46,7 +46,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: 
crate::MiriEvalContextExt<'mir, 'tcx
+     fn min_align(&self, size: u64, kind: MiriMemoryKind) -> Align {
+         let this = self.eval_context_ref();
+         // List taken from `libstd/sys_common/alloc.rs`.
+-        let min_align = match this.tcx.sess.target.arch.as_str() {
++        let min_align = match this.tcx.sess.target.arch.as_ref() {
+             "x86" | "arm" | "mips" | "powerpc" | "powerpc64" | "asmjs" | 
"wasm32" => 8,
+             "x86_64" | "aarch64" | "mips64" | "s390x" | "sparc64" => 16,
+             arch => bug!("Unsupported target architecture: {}", arch),
+@@ -695,7 +695,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: 
crate::MiriEvalContextExt<'mir, 'tcx
+             }
+ 
+             // Platform-specific shims
+-            _ => match this.tcx.sess.target.os.as_str() {
++            _ => match this.tcx.sess.target.os.as_ref() {
+                 "linux" | "macos" => return 
shims::posix::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this, 
link_name, abi, args, dest, ret),
+                 "windows" => return 
shims::windows::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this,
 link_name, abi, args, dest, ret),
+                 target => throw_unsup_format!("the target `{}` is not 
supported", target),
+diff --git a/src/shims/posix/foreign_items.rs 
b/src/shims/posix/foreign_items.rs
+index 02fb7089c..36bf53059 100644
+--- a/src/tools/miri/src/shims/posix/foreign_items.rs
++++ b/src/tools/miri/src/shims/posix/foreign_items.rs
+@@ -462,7 +462,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: 
crate::MiriEvalContextExt<'mir, 'tcx
+ 
+             // Platform-specific shims
+             _ => {
+-                match this.tcx.sess.target.os.as_str() {
++                match this.tcx.sess.target.os.as_ref() {
+                     "linux" => return 
shims::posix::linux::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this,
 link_name, abi, args, dest, ret),
+                     "macos" => return 
shims::posix::macos::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this,
 link_name, abi, args, dest, ret),
+                     _ => unreachable!(),

diff --git a/dev-lang/rust/rust-1.61.0-r1.ebuild 
b/dev-lang/rust/rust-1.61.0-r1.ebuild
new file mode 100644
index 0000000..724f325
--- /dev/null
+++ b/dev-lang/rust/rust-1.61.0-r1.ebuild
@@ -0,0 +1,730 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{8..10} )
+
+inherit bash-completion-r1 check-reqs estack flag-o-matic llvm multiprocessing 
\
+       multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs 
verify-sig
+
+if [[ ${PV} = *beta* ]]; then
+       betaver=${PV//*beta}
+       BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}"
+       MY_P="rustc-beta"
+       SLOT="beta/${PV}"
+       SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.xz -> rustc-${PV}-src.tar.xz"
+else
+       ABI_VER="$(ver_cut 1-2)"
+       SLOT="stable/${ABI_VER}"
+       MY_P="rustc-${PV}"
+       SRC="${MY_P}-src.tar.xz"
+       KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
+fi
+
+RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
+
+DESCRIPTION="Systems programming language from Mozilla"
+HOMEPAGE="https://www.rust-lang.org/";
+
+SRC_URI="
+       https://static.rust-lang.org/dist/${SRC}
+       verify-sig? ( https://static.rust-lang.org/dist/${SRC}.asc )
+       !system-bootstrap? ( $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION}) )
+"
+
+# keep in sync with llvm ebuild of the same version as bundled one.
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430
+       NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore )
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
+LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/(-)?}
+
+LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
+
+IUSE="clippy cpu_flags_x86_sse2 debug dist doc miri nightly parallel-compiler 
profiler rls rustfmt rust-src system-bootstrap system-llvm test wasm 
${ALL_LLVM_TARGETS[*]}"
+
+# Please keep the LLVM dependency block separate. Since LLVM is slotted,
+# we need to *really* make sure we're not pulling more than one slot
+# simultaneously.
+
+# How to use it:
+# List all the working slots in LLVM_VALID_SLOTS, newest first.
+LLVM_VALID_SLOTS=( 14 )
+LLVM_MAX_SLOT="${LLVM_VALID_SLOTS[0]}"
+
+# splitting usedeps needed to avoid CI/pkgcheck's UncheckableDep limitation
+# (-) usedep needed because we may build with older llvm without that target
+LLVM_DEPEND="|| ( "
+for _s in ${LLVM_VALID_SLOTS[@]}; do
+       LLVM_DEPEND+=" ( "
+       for _x in ${ALL_LLVM_TARGETS[@]}; do
+               LLVM_DEPEND+="
+                       ${_x}? ( sys-devel/llvm:${_s}[${_x}(-)] )"
+       done
+       LLVM_DEPEND+=" )"
+done
+unset _s _x
+LLVM_DEPEND+=" )
+       <sys-devel/llvm-$(( LLVM_MAX_SLOT + 1 )):=
+       wasm? ( sys-devel/lld )
+"
+
+# to bootstrap we need at least exactly previous version, or same.
+# most of the time previous versions fail to bootstrap with newer
+# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
+# but it fails to bootstrap with 1.48.x
+# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.txt
+RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
+RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
+BOOTSTRAP_DEPEND="||
+       (
+               =dev-lang/rust-"${RUST_DEP_PREV}"
+               =dev-lang/rust-bin-"${RUST_DEP_PREV}"
+               =dev-lang/rust-"${RUST_DEP_CURR}"
+               =dev-lang/rust-bin-"${RUST_DEP_CURR}"
+       )
+"
+
+BDEPEND="${PYTHON_DEPS}
+       app-eselect/eselect-rust
+       || (
+               >=sys-devel/gcc-4.7
+               >=sys-devel/clang-3.5
+       )
+       system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
+       !system-llvm? (
+               >=dev-util/cmake-3.13.4
+               dev-util/ninja
+       )
+       test? ( sys-devel/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=
+       elibc_musl? ( sys-libs/libunwind:= )
+       system-llvm? ( ${LLVM_DEPEND} )
+"
+
+RDEPEND="${DEPEND}
+       app-eselect/eselect-rust
+       sys-apps/lsb-release
+"
+
+REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )
+       miri? ( nightly )
+       parallel-compiler? ( nightly )
+       rls? ( 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}/${PV}/bin/.*
+       usr/lib/${PN}/${PV}/libexec/.*
+       usr/lib/${PN}/${PV}/lib/lib.*.so
+       usr/lib/${PN}/${PV}/lib/rustlib/.*/bin/.*
+       usr/lib/${PN}/${PV}/lib/rustlib/.*/lib/lib.*.so
+"
+
+QA_SONAME="
+       usr/lib/${PN}/${PV}/lib/lib.*.so.*
+       usr/lib/${PN}/${PV}/lib/rustlib/.*/lib/lib.*.so
+"
+
+QA_PRESTRIPPED="
+       usr/lib/${PN}/${PV}/lib/rustlib/.*/bin/rust-llvm-dwp
+"
+
+# 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}/${PV}/lib/rustlib/*/lib*.rlib:lib.rmeta"
+
+# causes double bootstrap
+RESTRICT="test"
+
+VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/rust.asc
+
+PATCHES=(
+       "${FILESDIR}"/1.59.0-libressl.patch
+       "${FILESDIR}"/1.55.0-ignore-broken-and-non-applicable-tests.patch
+       "${FILESDIR}"/1.61.0-gentoo-musl-target-specs.patch
+       "${FILESDIR}"/1.61.0-llvm_selectInterleaveCount.patch
+       "${FILESDIR}"/1.61.0-llvm_addrspacecast.patch
+       "${FILESDIR}"/1.61.0-miri-cow.patch
+)
+
+S="${WORKDIR}/${MY_P}-src"
+
+toml_usex() {
+       usex "${1}" true false
+}
+
+bootstrap_rust_version_check() {
+       # never call from pkg_pretend. eselect-rust may be not installed yet.
+       [[ ${MERGE_TYPE} == binary ]] && return
+       local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
+       local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
+       local rustc_version=( $(eselect --brief rust show 2>/dev/null) )
+       rustc_version=${rustc_version[0]#rust-bin-}
+       rustc_version=${rustc_version#rust-}
+
+       [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, 
check 'eselect rust' output"
+
+       if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
+               eerror "Rust >=${rustc_wanted} is required"
+               eerror "please run 'eselect rust' and set correct rust version"
+               die "selected rust version is too old"
+       elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
+               eerror "Rust <${rustc_toonew} is required"
+               eerror "please run 'eselect rust' and set correct rust version"
+               die "selected rust version is too new"
+       else
+               einfo "Using rust ${rustc_version} to build"
+       fi
+}
+
+pre_build_checks() {
+       local M=8192
+       # 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} ))
+       M=$(( $(usex miri 128 0) + ${M} ))
+       M=$(( $(usex rls 512 0) + ${M} ))
+       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 system-bootstrap 0 1024) + ${M} ))
+       M=$(( $(usex doc 256 0) + ${M} ))
+       CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE}
+}
+
+llvm_check_deps() {
+       has_version -r "sys-devel/llvm:${LLVM_SLOT}[${LLVM_TARGET_USEDEPS// 
/,}]"
+}
+
+pkg_pretend() {
+       pre_build_checks
+}
+
+pkg_setup() {
+       pre_build_checks
+       python-any-r1_pkg_setup
+
+       export LIBGIT2_NO_PKG_CONFIG=1 #749381
+
+       use system-bootstrap && bootstrap_rust_version_check
+
+       if use system-llvm; then
+               llvm_pkg_setup
+
+               local llvm_config="$(get_llvm_prefix 
"${LLVM_MAX_SLOT}")/bin/llvm-config"
+               export LLVM_LINK_SHARED=1
+               export RUSTFLAGS="${RUSTFLAGS} -Lnative=$("${llvm_config}" 
--libdir)"
+       fi
+}
+
+src_prepare() {
+       if ! use system-bootstrap; then
+               local rust_stage0_root="${WORKDIR}"/rust-stage0
+               local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)"
+
+               "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig \
+                       --without=rust-docs --destdir="${rust_stage0_root}" 
--prefix=/ || die
+       fi
+
+       default
+}
+
+src_configure() {
+       local rust_target="" rust_targets="" arch_cflags use_libcxx="false"
+
+       # Collect rust target names to compile standard libs for all ABIs.
+       for v in $(multilib_get_enabled_abi_pairs); do
+               rust_targets="${rust_targets},\"$(rust_abi $(get_abi_CHOST 
${v##*.}))\""
+       done
+       if use wasm; then
+               rust_targets="${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/wasm_base.rs || die
+               fi
+       fi
+       rust_targets="${rust_targets#,}"
+
+       local tools="\"cargo\","
+       if use clippy; then
+               tools="\"clippy\",$tools"
+       fi
+       if use miri; then
+               tools="\"miri\",$tools"
+       fi
+       if use profiler; then
+               tools="\"rust-demangler\",$tools"
+       fi
+       if use rls; then
+               tools="\"rls\",\"analysis\",$tools"
+       fi
+       if use rustfmt; then
+               tools="\"rustfmt\",$tools"
+       fi
+       if use rust-src; then
+               tools="\"src\",$tools"
+       fi
+
+       local rust_stage0_root
+       if use system-bootstrap; then
+               local printsysroot
+               printsysroot="$(rustc --print sysroot || die "Can't determine 
rust's sysroot")"
+               rust_stage0_root="${printsysroot}"
+       else
+               rust_stage0_root="${WORKDIR}"/rust-stage0
+       fi
+       # 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)"
+
+       # https://bugs.gentoo.org/732632
+       if tc-is-clang; then
+               local clang_slot="$(clang-major-version)"
+               if { has_version 
"sys-devel/clang:${clang_slot}[default-libcxx]" || is-flagq -stdlib=libc++; }; 
then
+                       use_libcxx="true"
+               fi
+       fi
+
+       cat <<- _EOF_ > "${S}"/config.toml
+               changelog-seen = 2
+               [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 = ""
+               link-shared = $(toml_usex system-llvm)
+               $(if [[ ${use_libcxx} == true ]]; then
+                       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)
+               [build]
+               build-stage = 2
+               test-stage = 2
+               doc-stage = 2
+               build = "${rust_target}"
+               host = ["${rust_target}"]
+               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 = $(toml_usex profiler)
+               cargo-native-static = false
+               [install]
+               prefix = "${EPREFIX}/usr/lib/${PN}/${PV}"
+               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
+               default-linker = "$(tc-getCC)"
+               parallel-compiler = $(toml_usex parallel-compiler)
+               channel = "$(usex nightly nightly stable)"
+               description = "gentoo"
+               rpath = false
+               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))
+               # 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
+               [dist]
+               src-tarball = false
+               compression-formats = ["xz"]
+       _EOF_
+
+       for v in $(multilib_get_enabled_abi_pairs); do
+               rust_target=$(rust_abi $(get_abi_CHOST ${v##*.}))
+               arch_cflags="$(get_abi_CFLAGS ${v##*.})"
+
+               cat <<- _EOF_ >> "${S}"/config.env
+                       CFLAGS_${rust_target}=${arch_cflags}
+               _EOF_
+
+               cat <<- _EOF_ >> "${S}"/config.toml
+                       [target.${rust_target}]
+                       ar = "$(tc-getAR)"
+                       cc = "$(tc-getCC)"
+                       cxx = "$(tc-getCXX)"
+                       linker = "$(tc-getCC)"
+                       ranlib = "$(tc-getRANLIB)"
+               _EOF_
+               # librustc_target/spec/linux_musl_base.rs sets 
base.crt_static_default = true;
+               if use elibc_musl; then
+                       cat <<- _EOF_ >> "${S}"/config.toml
+                               crt-static = false
+                       _EOF_
+               fi
+               if use system-llvm; then
+                       cat <<- _EOF_ >> "${S}"/config.toml
+                               llvm-config = "$(get_llvm_prefix 
"${LLVM_MAX_SLOT}")/bin/llvm-config"
+                       _EOF_
+               fi
+       done
+       if use wasm; then
+               cat <<- _EOF_ >> "${S}"/config.toml
+                       [target.wasm32-unknown-unknown]
+                       linker = "$(usex system-llvm lld rust-lld)"
+                       # 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/<target>
+
+       # extra targets defined as a bash array
+       # spec format:  <LLVM target>:<rust-target>:<CTARGET>
+       # 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 <LLVM 
target>:<rust-target>:<CTARGET>
+               local cross_llvm_target="${cross_target_spec%%:*}"
+               # extracts toolchain triples, <rust-target>:<CTARGET>
+               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 
"${LLVM_MAX_SLOT}")/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:-}"
+       env | grep "CARGO_TARGET_.*_RUSTFLAGS="
+       cat "${S}"/config.env || die
+       echo
+       einfo "config.toml contents:"
+       cat "${S}"/config.toml || die
+       echo
+}
+
+src_compile() {
+       # we need \n IFS to have config.env with spaces loaded properly. #734018
+       (
+       IFS=$'\n'
+       env $(cat "${S}"/config.env) RUST_BACKTRACE=1\
+               "${EPYTHON}" ./x.py build -vv --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 ! (
+                               IFS=$'\n'
+                               env $(cat "${S}"/config.env) 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() {
+       (
+       IFS=$'\n'
+       env $(cat "${S}"/config.env) DESTDIR="${D}" \
+               "${EPYTHON}" ./x.py install     -vv --config="${S}"/config.toml 
-j$(makeopts_jobs) || die
+       )
+
+       # bug #689562, #689160
+       rm -v "${ED}/usr/lib/${PN}/${PV}/etc/bash_completion.d/cargo" || die
+       rmdir -v "${ED}/usr/lib/${PN}/${PV}"/etc{/bash_completion.d,} || die
+       newbashcomp src/tools/cargo/src/etc/cargo.bashcomp.sh cargo
+
+       local symlinks=(
+               cargo
+               rustc
+               rustdoc
+               rust-gdb
+               rust-gdbgui
+               rust-lldb
+       )
+
+       use clippy && symlinks+=( clippy-driver cargo-clippy )
+       use miri && symlinks+=( miri cargo-miri )
+       use profiler && symlinks+=( rust-demangler )
+       use rls && symlinks+=( rls )
+       use rustfmt && symlinks+=( rustfmt cargo-fmt )
+
+       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/<ver>/bin/rustc-<ver>
+               # need to fix eselect-rust to remove this hack.
+               local ver_i="${i}-${PV}"
+               if [[ -f "${ED}/usr/lib/${PN}/${PV}/bin/${i}" ]]; then
+                       einfo "Installing ${i} symlink"
+                       ln -v "${ED}/usr/lib/${PN}/${PV}/bin/${i}" 
"${ED}/usr/lib/${PN}/${PV}/bin/${ver_i}" || die
+               else
+                       ewarn "${i} symlink requested, but source file not 
found"
+                       ewarn "please report this"
+               fi
+               dosym "../lib/${PN}/${PV}/bin/${ver_i}" "/usr/bin/${ver_i}"
+       done
+
+       # symlinks to switch components to active rust in eselect
+       dosym "${PV}/lib" "/usr/lib/${PN}/lib-${PV}"
+       dosym "${PV}/libexec" "/usr/lib/${PN}/libexec-${PV}"
+       dosym "${PV}/share/man" "/usr/lib/${PN}/man-${PV}"
+       dosym "rust/${PV}/lib/rustlib" "/usr/lib/rustlib-${PV}"
+       dosym "../../lib/${PN}/${PV}/share/doc/rust" "/usr/share/doc/${P}"
+
+       newenvd - "50${P}" <<-_EOF_
+               LDPATH="${EPREFIX}/usr/lib/rust/lib"
+               MANPATH="${EPREFIX}/usr/lib/rust/man"
+               $(use amd64 && usex elibc_musl 
'CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C 
target-feature=-crt-static"' '')
+               $(use arm64 && usex elibc_musl 
'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C 
target-feature=-crt-static"' '')
+       _EOF_
+
+       rm -rf "${ED}/usr/lib/${PN}/${PV}"/*.old || die
+       rm -rf "${ED}/usr/lib/${PN}/${PV}/doc"/*.old || die
+
+       # note: eselect-rust adds EROOT to all paths below
+       cat <<-_EOF_ > "${T}/provider-${P}"
+               /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/libexec
+               /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 use miri; then
+               echo /usr/bin/miri >> "${T}/provider-${P}"
+               echo /usr/bin/cargo-miri >> "${T}/provider-${P}"
+       fi
+       if use profiler; then
+               echo /usr/bin/rust-demangler >> "${T}/provider-${P}"
+       fi
+       if use rls; then
+               echo /usr/bin/rls >> "${T}/provider-${P}"
+       fi
+       if use rustfmt; then
+               echo /usr/bin/rustfmt >> "${T}/provider-${P}"
+               echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
+       fi
+
+       insinto /etc/env.d/rust
+       doins "${T}/provider-${P}"
+
+       if use dist; then
+               insinto "/usr/lib/${PN}/${PV}/dist"
+               doins -r "${S}/build/dist/."
+       fi
+}
+
+pkg_postinst() {
+       eselect rust update
+
+       if has_version sys-devel/gdb || has_version dev-util/lldb; then
+               elog "Rust installs a helper script for calling GDB and LLDB,"
+               elog "for your convenience it is installed under 
/usr/bin/rust-{gdb,lldb}-${PV}."
+       fi
+
+       if has_version app-editors/emacs; then
+               elog "install app-emacs/rust-mode to get emacs support for 
rust."
+       fi
+
+       if has_version app-editors/gvim || has_version app-editors/vim; then
+               elog "install app-vim/rust-vim to get vim support for rust."
+       fi
+}
+
+pkg_postrm() {
+       eselect rust cleanup
+}

Reply via email to