diff --git a/0001-Revert-Auto-merge-of-79547.patch b/0001-Revert-Auto-merge-of-79547.patch new file mode 100644 index 0000000000000000000000000000000000000000..b2e58a1b523ff05375e101702c451148a90d6984 --- /dev/null +++ b/0001-Revert-Auto-merge-of-79547.patch @@ -0,0 +1,102 @@ +From eaf7ea1fc339e1ff348ed941ed2e8c4d66f3e458 Mon Sep 17 00:00:00 2001 +From: Josh Stone +Date: Thu, 18 Feb 2021 19:14:58 -0800 +Subject: [PATCH] Revert "Auto merge of #79547 - erikdesjardins:byval, + r=nagisa" + +This reverts commit a094ff9590b83c8f94d898f92c2964a5803ded06, reversing +changes made to d37afad0cc87bf709ad10c85319296ac53030f03. +--- + compiler/rustc_middle/src/ty/layout.rs | 12 ++++++------ + ...return-value-in-reg.rs => return-value-in-reg.rs} | 4 ++-- + src/test/codegen/union-abi.rs | 11 +++-------- + 3 files changed, 11 insertions(+), 16 deletions(-) + rename src/test/codegen/{arg-return-value-in-reg.rs => return-value-in-reg.rs} (74%) + +diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs +index b545b92c9252..545f6aee1a21 100644 +--- a/compiler/rustc_middle/src/ty/layout.rs ++++ b/compiler/rustc_middle/src/ty/layout.rs +@@ -2849,7 +2849,7 @@ fn adjust_for_abi(&mut self, cx: &C, abi: SpecAbi) { + || abi == SpecAbi::RustIntrinsic + || abi == SpecAbi::PlatformIntrinsic + { +- let fixup = |arg: &mut ArgAbi<'tcx, Ty<'tcx>>| { ++ let fixup = |arg: &mut ArgAbi<'tcx, Ty<'tcx>>, is_ret: bool| { + if arg.is_ignore() { + return; + } +@@ -2887,9 +2887,9 @@ fn adjust_for_abi(&mut self, cx: &C, abi: SpecAbi) { + _ => return, + } + +- // Pass and return structures up to 2 pointers in size by value, matching `ScalarPair`. +- // LLVM will usually pass these in 2 registers, which is more efficient than by-ref. +- let max_by_val_size = Pointer.size(cx) * 2; ++ // Return structures up to 2 pointers in size by value, matching `ScalarPair`. LLVM ++ // will usually return these in 2 registers, which is more efficient than by-ref. ++ let max_by_val_size = if is_ret { Pointer.size(cx) * 2 } else { Pointer.size(cx) }; + let size = arg.layout.size; + + if arg.layout.is_unsized() || size > max_by_val_size { +@@ -2901,9 +2901,9 @@ fn adjust_for_abi(&mut self, cx: &C, abi: SpecAbi) { + arg.cast_to(Reg { kind: RegKind::Integer, size }); + } + }; +- fixup(&mut self.ret); ++ fixup(&mut self.ret, true); + for arg in &mut self.args { +- fixup(arg); ++ fixup(arg, false); + } + return; + } +diff --git a/src/test/codegen/arg-return-value-in-reg.rs b/src/test/codegen/return-value-in-reg.rs +similarity index 74% +rename from src/test/codegen/arg-return-value-in-reg.rs +rename to src/test/codegen/return-value-in-reg.rs +index a69291d47821..4bc0136c5e32 100644 +--- a/src/test/codegen/arg-return-value-in-reg.rs ++++ b/src/test/codegen/return-value-in-reg.rs +@@ -1,4 +1,4 @@ +-//! Check that types of up to 128 bits are passed and returned by-value instead of via pointer. ++//! This test checks that types of up to 128 bits are returned by-value instead of via out-pointer. + + // compile-flags: -C no-prepopulate-passes -O + // only-x86_64 +@@ -11,7 +11,7 @@ pub struct S { + c: u32, + } + +-// CHECK: define i128 @modify(i128{{( %0)?}}) ++// CHECK: define i128 @modify(%S* noalias nocapture dereferenceable(16) %s) + #[no_mangle] + pub fn modify(s: S) -> S { + S { a: s.a + s.a, b: s.b + s.b, c: s.c + s.c } +diff --git a/src/test/codegen/union-abi.rs b/src/test/codegen/union-abi.rs +index f282fd237054..afea01e9a2d0 100644 +--- a/src/test/codegen/union-abi.rs ++++ b/src/test/codegen/union-abi.rs +@@ -63,16 +63,11 @@ pub union UnionU128{a:u128} + #[no_mangle] + pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} } + +-pub union UnionU128x2{a:(u128, u128)} +-// CHECK: define void @test_UnionU128x2(i128 %_1.0, i128 %_1.1) +-#[no_mangle] +-pub fn test_UnionU128x2(_: UnionU128x2) { loop {} } +- + #[repr(C)] +-pub union CUnionU128x2{a:(u128, u128)} +-// CHECK: define void @test_CUnionU128x2(%CUnionU128x2* {{.*}} %_1) ++pub union CUnionU128{a:u128} ++// CHECK: define void @test_CUnionU128(%CUnionU128* {{.*}} %_1) + #[no_mangle] +-pub fn test_CUnionU128x2(_: CUnionU128x2) { loop {} } ++pub fn test_CUnionU128(_: CUnionU128) { loop {} } + + pub union UnionBool { b:bool } + // CHECK: define zeroext i1 @test_UnionBool(i8 %b) +-- +2.29.2 + diff --git a/0001-Set-more-llvm-function-attributes-for-__rust_try.patch b/0001-Set-more-llvm-function-attributes-for-__rust_try.patch deleted file mode 100644 index 36bb15c04cc150363654eb5ddf2e034556231402..0000000000000000000000000000000000000000 --- a/0001-Set-more-llvm-function-attributes-for-__rust_try.patch +++ /dev/null @@ -1,186 +0,0 @@ -From 4b95b1a4fd035a73998dc21b265ce4594e35f8ae Mon Sep 17 00:00:00 2001 -From: Alex Crichton -Date: Thu, 16 Aug 2018 13:19:04 -0700 -Subject: [PATCH] Set more llvm function attributes for __rust_try - -This shim is generated elsewhere in the compiler so this commit adds support to -ensure it goes through similar paths as the rest of the compiler to set llvm -function attributes like target features. - -cc #53372 ---- - src/librustc_codegen_llvm/attributes.rs | 52 +++++++++++++++++++------ - src/librustc_codegen_llvm/base.rs | 21 ---------- - src/librustc_codegen_llvm/callee.rs | 2 +- - src/librustc_codegen_llvm/intrinsic.rs | 2 + - src/librustc_codegen_llvm/mono_item.rs | 2 +- - 5 files changed, 44 insertions(+), 35 deletions(-) - -diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs -index 3b5f927d52f0..2a79ce2f2285 100644 ---- a/src/librustc_codegen_llvm/attributes.rs -+++ b/src/librustc_codegen_llvm/attributes.rs -@@ -11,7 +11,7 @@ - - use std::ffi::{CStr, CString}; - --use rustc::hir::CodegenFnAttrFlags; -+use rustc::hir::{CodegenFnAttrFlags, CodegenFnAttrs}; - use rustc::hir::def_id::{DefId, LOCAL_CRATE}; - use rustc::session::Session; - use rustc::session::config::Sanitizer; -@@ -123,11 +123,37 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator { - - /// Composite function which sets LLVM attributes for function depending on its AST (#[attribute]) - /// attributes. --pub fn from_fn_attrs(cx: &CodegenCx, llfn: ValueRef, id: DefId) { -- let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(id); -+pub fn from_fn_attrs( -+ cx: &CodegenCx, -+ llfn: ValueRef, -+ id: Option, -+) { -+ let codegen_fn_attrs = id.map(|id| cx.tcx.codegen_fn_attrs(id)) -+ .unwrap_or(CodegenFnAttrs::new()); - - inline(llfn, codegen_fn_attrs.inline); - -+ // The `uwtable` attribute according to LLVM is: -+ // -+ // This attribute indicates that the ABI being targeted requires that an -+ // unwind table entry be produced for this function even if we can show -+ // that no exceptions passes by it. This is normally the case for the -+ // ELF x86-64 abi, but it can be disabled for some compilation units. -+ // -+ // Typically when we're compiling with `-C panic=abort` (which implies this -+ // `no_landing_pads` check) we don't need `uwtable` because we can't -+ // generate any exceptions! On Windows, however, exceptions include other -+ // events such as illegal instructions, segfaults, etc. This means that on -+ // Windows we end up still needing the `uwtable` attribute even if the `-C -+ // panic=abort` flag is passed. -+ // -+ // You can also find more info on why Windows is whitelisted here in: -+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1302078 -+ if !cx.sess().no_landing_pads() || -+ cx.sess().target.target.options.requires_uwtable { -+ attributes::emit_uwtable(llfn, true); -+ } -+ - set_frame_pointer_elimination(cx, llfn); - set_probestack(cx, llfn); - -@@ -151,7 +177,7 @@ pub fn from_fn_attrs(cx: &CodegenCx, llfn: ValueRef, id: DefId) { - // *in Rust code* may unwind. Foreign items like `extern "C" { - // fn foo(); }` are assumed not to unwind **unless** they have - // a `#[unwind]` attribute. -- } else if !cx.tcx.is_foreign_item(id) { -+ } else if id.map(|id| !cx.tcx.is_foreign_item(id)).unwrap_or(false) { - Some(true) - } else { - None -@@ -188,14 +214,16 @@ pub fn from_fn_attrs(cx: &CodegenCx, llfn: ValueRef, id: DefId) { - // Note that currently the `wasm-import-module` doesn't do anything, but - // eventually LLVM 7 should read this and ferry the appropriate import - // module to the output file. -- if cx.tcx.sess.target.target.arch == "wasm32" { -- if let Some(module) = wasm_import_module(cx.tcx, id) { -- llvm::AddFunctionAttrStringValue( -- llfn, -- llvm::AttributePlace::Function, -- cstr("wasm-import-module\0"), -- &module, -- ); -+ if let Some(id) = id { -+ if cx.tcx.sess.target.target.arch == "wasm32" { -+ if let Some(module) = wasm_import_module(cx.tcx, id) { -+ llvm::AddFunctionAttrStringValue( -+ llfn, -+ llvm::AttributePlace::Function, -+ cstr("wasm-import-module\0"), -+ &module, -+ ); -+ } - } - } - } -diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs -index 223c04f420f3..b0461582ddcb 100644 ---- a/src/librustc_codegen_llvm/base.rs -+++ b/src/librustc_codegen_llvm/base.rs -@@ -486,27 +486,6 @@ pub fn codegen_instance<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, instance: Instance<' - - cx.stats.borrow_mut().n_closures += 1; - -- // The `uwtable` attribute according to LLVM is: -- // -- // This attribute indicates that the ABI being targeted requires that an -- // unwind table entry be produced for this function even if we can show -- // that no exceptions passes by it. This is normally the case for the -- // ELF x86-64 abi, but it can be disabled for some compilation units. -- // -- // Typically when we're compiling with `-C panic=abort` (which implies this -- // `no_landing_pads` check) we don't need `uwtable` because we can't -- // generate any exceptions! On Windows, however, exceptions include other -- // events such as illegal instructions, segfaults, etc. This means that on -- // Windows we end up still needing the `uwtable` attribute even if the `-C -- // panic=abort` flag is passed. -- // -- // You can also find more info on why Windows is whitelisted here in: -- // https://bugzilla.mozilla.org/show_bug.cgi?id=1302078 -- if !cx.sess().no_landing_pads() || -- cx.sess().target.target.options.requires_uwtable { -- attributes::emit_uwtable(lldecl, true); -- } -- - let mir = cx.tcx.instance_mir(instance.def); - mir::codegen_mir(cx, lldecl, &mir, instance, sig); - } -diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs -index 2c01bd42cc77..97f07792ede8 100644 ---- a/src/librustc_codegen_llvm/callee.rs -+++ b/src/librustc_codegen_llvm/callee.rs -@@ -97,7 +97,7 @@ pub fn get_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, - if instance.def.is_inline(tcx) { - attributes::inline(llfn, attributes::InlineAttr::Hint); - } -- attributes::from_fn_attrs(cx, llfn, instance.def.def_id()); -+ attributes::from_fn_attrs(cx, llfn, Some(instance.def.def_id())); - - let instance_def_id = instance.def_id(); - -diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs -index 9c5c0f730c16..f69fce15dc55 100644 ---- a/src/librustc_codegen_llvm/intrinsic.rs -+++ b/src/librustc_codegen_llvm/intrinsic.rs -@@ -10,6 +10,7 @@ - - #![allow(non_upper_case_globals)] - -+use attributes; - use intrinsics::{self, Intrinsic}; - use llvm; - use llvm::{ValueRef}; -@@ -936,6 +937,7 @@ fn gen_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, - Abi::Rust - ))); - let llfn = declare::define_internal_fn(cx, name, rust_fn_ty); -+ attributes::from_fn_attrs(cx, llfn, None); - let bx = Builder::new_block(cx, llfn, "entry-block"); - codegen(bx); - llfn -diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs -index a528008e3b4b..32d8b24e3c15 100644 ---- a/src/librustc_codegen_llvm/mono_item.rs -+++ b/src/librustc_codegen_llvm/mono_item.rs -@@ -183,7 +183,7 @@ fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, - if instance.def.is_inline(cx.tcx) { - attributes::inline(lldecl, attributes::InlineAttr::Hint); - } -- attributes::from_fn_attrs(cx, lldecl, instance.def.def_id()); -+ attributes::from_fn_attrs(cx, lldecl, Some(instance.def.def_id())); - - cx.instances.borrow_mut().insert(instance, lldecl); - } --- -2.17.1 - diff --git a/0001-std-stop-backtracing-when-the-frames-are-full.patch b/0001-std-stop-backtracing-when-the-frames-are-full.patch deleted file mode 100644 index aa1b9a5130e495f469cfc6a72c1404c69ba35572..0000000000000000000000000000000000000000 --- a/0001-std-stop-backtracing-when-the-frames-are-full.patch +++ /dev/null @@ -1,122 +0,0 @@ -From f4e8d57b6ad6f599de54c020ba185db83cb011a3 Mon Sep 17 00:00:00 2001 -From: Josh Stone -Date: Thu, 16 Aug 2018 11:26:27 -0700 -Subject: [PATCH] std: stop backtracing when the frames are full - ---- - src/libstd/sys/cloudabi/backtrace.rs | 18 ++++++++++-------- - src/libstd/sys/redox/backtrace/tracing.rs | 18 ++++++++++-------- - src/libstd/sys/unix/backtrace/tracing/gcc_s.rs | 18 ++++++++++-------- - 3 files changed, 30 insertions(+), 24 deletions(-) - -diff --git a/src/libstd/sys/cloudabi/backtrace.rs b/src/libstd/sys/cloudabi/backtrace.rs -index 1b970187558c..2c43b5937ce5 100644 ---- a/src/libstd/sys/cloudabi/backtrace.rs -+++ b/src/libstd/sys/cloudabi/backtrace.rs -@@ -64,6 +64,10 @@ extern "C" fn trace_fn( - arg: *mut libc::c_void, - ) -> uw::_Unwind_Reason_Code { - let cx = unsafe { &mut *(arg as *mut Context) }; -+ if cx.idx >= cx.frames.len() { -+ return uw::_URC_NORMAL_STOP; -+ } -+ - let mut ip_before_insn = 0; - let mut ip = unsafe { uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void }; - if !ip.is_null() && ip_before_insn == 0 { -@@ -73,14 +77,12 @@ extern "C" fn trace_fn( - } - - let symaddr = unsafe { uw::_Unwind_FindEnclosingFunction(ip) }; -- if cx.idx < cx.frames.len() { -- cx.frames[cx.idx] = Frame { -- symbol_addr: symaddr as *mut u8, -- exact_position: ip as *mut u8, -- inline_context: 0, -- }; -- cx.idx += 1; -- } -+ cx.frames[cx.idx] = Frame { -+ symbol_addr: symaddr as *mut u8, -+ exact_position: ip as *mut u8, -+ inline_context: 0, -+ }; -+ cx.idx += 1; - - uw::_URC_NO_REASON - } -diff --git a/src/libstd/sys/redox/backtrace/tracing.rs b/src/libstd/sys/redox/backtrace/tracing.rs -index bb70ca360370..c0414b78f8d6 100644 ---- a/src/libstd/sys/redox/backtrace/tracing.rs -+++ b/src/libstd/sys/redox/backtrace/tracing.rs -@@ -68,6 +68,10 @@ pub fn unwind_backtrace(frames: &mut [Frame]) - extern fn trace_fn(ctx: *mut uw::_Unwind_Context, - arg: *mut libc::c_void) -> uw::_Unwind_Reason_Code { - let cx = unsafe { &mut *(arg as *mut Context) }; -+ if cx.idx >= cx.frames.len() { -+ return uw::_URC_NORMAL_STOP; -+ } -+ - let mut ip_before_insn = 0; - let mut ip = unsafe { - uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void -@@ -94,14 +98,12 @@ extern fn trace_fn(ctx: *mut uw::_Unwind_Context, - unsafe { uw::_Unwind_FindEnclosingFunction(ip) } - }; - -- if cx.idx < cx.frames.len() { -- cx.frames[cx.idx] = Frame { -- symbol_addr: symaddr as *mut u8, -- exact_position: ip as *mut u8, -- inline_context: 0, -- }; -- cx.idx += 1; -- } -+ cx.frames[cx.idx] = Frame { -+ symbol_addr: symaddr as *mut u8, -+ exact_position: ip as *mut u8, -+ inline_context: 0, -+ }; -+ cx.idx += 1; - - uw::_URC_NO_REASON - } -diff --git a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs -index 1b92fc0e6ad0..6e8415686792 100644 ---- a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs -+++ b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs -@@ -68,6 +68,10 @@ pub fn unwind_backtrace(frames: &mut [Frame]) - extern fn trace_fn(ctx: *mut uw::_Unwind_Context, - arg: *mut libc::c_void) -> uw::_Unwind_Reason_Code { - let cx = unsafe { &mut *(arg as *mut Context) }; -+ if cx.idx >= cx.frames.len() { -+ return uw::_URC_NORMAL_STOP; -+ } -+ - let mut ip_before_insn = 0; - let mut ip = unsafe { - uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void -@@ -94,14 +98,12 @@ extern fn trace_fn(ctx: *mut uw::_Unwind_Context, - unsafe { uw::_Unwind_FindEnclosingFunction(ip) } - }; - -- if cx.idx < cx.frames.len() { -- cx.frames[cx.idx] = Frame { -- symbol_addr: symaddr as *mut u8, -- exact_position: ip as *mut u8, -- inline_context: 0, -- }; -- cx.idx += 1; -- } -+ cx.frames[cx.idx] = Frame { -+ symbol_addr: symaddr as *mut u8, -+ exact_position: ip as *mut u8, -+ inline_context: 0, -+ }; -+ cx.idx += 1; - - uw::_URC_NO_REASON - } --- -2.17.1 - diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 7ee7af526b55293db11a87e824f409ec83a14312..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# rust - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md deleted file mode 100644 index d1494d98752b5c13fc52ecf81926234c9e7f2640..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# rust - -#### 介绍 -{**以下是码云平台说明,您可以替换此简介** -码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} - -#### 软件架构 -软件架构说明 - - -#### 安装教程 - -1. xxxx -2. xxxx -3. xxxx - -#### 使用说明 - -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 码云特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 -5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/rust-52876-const-endianess.patch b/rust-52876-const-endianess.patch deleted file mode 100644 index 1e844e8274b84540ecf9fb25e64d0782da9f68f9..0000000000000000000000000000000000000000 --- a/rust-52876-const-endianess.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 1ea2765918d1212a07e1359537470c477d82a681 Mon Sep 17 00:00:00 2001 -From: Josh Stone -Date: Mon, 30 Jul 2018 13:08:56 -0700 -Subject: [PATCH] run-pass/const-endianness: negate before to_le() - -`const LE_I128` needs parentheses to negate the value *before* calling -`to_le()`, otherwise it doesn't match the operations performed in the -black-boxed part of the test. This only makes a tangible difference on -big-endian targets. ---- - src/test/run-pass/const-endianess.rs | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/test/run-pass/const-endianess.rs b/src/test/run-pass/const-endianess.rs -index fa34b49210a6..95c738d3ec49 100644 ---- a/src/test/run-pass/const-endianess.rs -+++ b/src/test/run-pass/const-endianess.rs -@@ -25,7 +25,7 @@ fn main() { - #[cfg(not(target_arch = "asmjs"))] - { - const BE_U128: u128 = 999999u128.to_be(); -- const LE_I128: i128 = -999999i128.to_le(); -+ const LE_I128: i128 = (-999999i128).to_le(); - assert_eq!(BE_U128, b(999999u128).to_be()); - assert_eq!(LE_I128, b(-999999i128).to_le()); - } diff --git a/rust.spec b/rust.spec index 016069a825a0d640bbcd840d1608360ae54a4647..1f538aa779ec6a682b29f6c40629259bd2ca52d4 100644 --- a/rust.spec +++ b/rust.spec @@ -1,223 +1,390 @@ -%global rustlibdir %{_prefix}/lib/rustlib -%global rust_triple %{_target_cpu}-unknown-linux-gnu +%global rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x +%{!?channel: %global channel stable} +%global bootstrap_rust 1.50.0 +%global bootstrap_cargo 1.50.0 +%global bootstrap_channel 1.50.0 +%global bootstrap_date 2021-02-11 +%bcond_with llvm_static +%bcond_with bundled_llvm +%bcond_without bundled_libgit2 +%bcond_with disabled_libssh2 +%bcond_without curl_http2 +%bcond_without lldb +Name: rust +Version: 1.51.0 +Release: 1 +Summary: The Rust Programming Language +License: (ASL 2.0 or MIT) and (BSD and MIT) +URL: https://www.rust-lang.org +ExclusiveArch: %{rust_arches} +%if "%{channel}" == "stable" +%global rustc_package rustc-%{version}-src +%else +%global rustc_package rustc-%{channel}-src +%endif +Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz +Source1: rustc-%{version}-src.tar.xz.aa +Source2: rustc-%{version}-src.tar.xz.ab + +Patch0001: 0001-Revert-Auto-merge-of-79547.patch +Patch0002: rustc-1.51.0-backport-pr81741.patch +Patch0003: rustc-1.51.0-backport-pr82289.patch +Patch0004: rustc-1.51.0-backport-pr82292.patch +Patch0005: rustc-1.51.0-backport-pr81910.patch +Patch0006: rustc-1.51.0-backport-pr81728.patch +Patch0007: rustc-1.51.0-backport-pr83629.patch +Patch0008: rustc-1.48.0-disable-libssh2.patch +Patch0009: rustc-1.51.0-disable-http2.patch +%{lua: function rust_triple(arch) + local abi = "gnu" + if arch == "armv7hl" then + arch = "armv7" + abi = "gnueabihf" + elseif arch == "ppc64" then + arch = "powerpc64" + elseif arch == "ppc64le" then + arch = "powerpc64le" + elseif arch == "riscv64" then + arch = "riscv64gc" + end + return arch.."-unknown-linux-"..abi +end} +%global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))} +%if %defined bootstrap_arches +%{lua: do + local bootstrap_arches = {} + for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do + table.insert(bootstrap_arches, arch) + end + local base = rpm.expand("https://static.rust-lang.org/dist/%{bootstrap_date}" + .."/rust-%{bootstrap_channel}") + local target_arch = rpm.expand("%{_target_cpu}") + for i, arch in ipairs(bootstrap_arches) do + print(string.format("Source%d: %s-%s.tar.xz\n", + i, base, rust_triple(arch))) + if arch == target_arch then + rpm.define("bootstrap_source "..i) + end + end +end} +%endif +%ifarch %{bootstrap_arches} +%global bootstrap_root rust-%{bootstrap_channel}-%{rust_triple} +%global local_rust_root %{_builddir}/%{bootstrap_root}/usr +Provides: bundled(%{name}-bootstrap) = %{bootstrap_rust} +%else +BuildRequires: cargo >= %{bootstrap_cargo} +BuildRequires: (%{name} >= %{bootstrap_rust} with %{name} <= %{version}) +%global local_rust_root %{_prefix} +%endif +BuildRequires: make gcc gcc-c++ ncurses-devel curl curl-devel pkgconfig(libcurl) pkgconfig(liblzma) +BuildRequires: pkgconfig(openssl) pkgconfig(zlib) pkgconfig(libssh2) >= 1.6.0 +%global python python3 +BuildRequires: %{python} +%if %with bundled_llvm +BuildRequires: cmake3 >= 3.4.3 +Provides: bundled(llvm) = 11.0.1 +%else +BuildRequires: cmake >= 2.8.11 +%if %defined llvm +%global llvm_root %{_libdir}/%{llvm} +%else +%global llvm llvm +%global llvm_root %{_prefix} +%endif +BuildRequires: %{llvm}-devel >= 9.0 +%if %with llvm_static +BuildRequires: %{llvm}-static libffi-devel +%endif +%endif +BuildRequires: procps-ng gdb +Provides: rustc = %{version}-%{release} +Provides: rustc%{?_isa} = %{version}-%{release} +Requires: %{name}-std-static%{?_isa} = %{version}-%{release} +Requires: /usr/bin/cc %global _privatelibs lib(.*-[[:xdigit:]]{16}*|rustc.*)[.]so.* %global __provides_exclude ^(%{_privatelibs})$ %global __requires_exclude ^(%{_privatelibs})$ %global __provides_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$ %global __requires_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$ %global _find_debuginfo_opts --keep-section .rustc - -Name: rust -Version: 1.29.1 -Release: 3 -Summary: A systems programming language -License: (ASL 2.0 or MIT) and (BSD and MIT) -URL: https://www.rust-lang.org -Source0: https://static.rust-lang.org/dist/rustc-1.29.1-src.tar.xz -Patch0000: rust-52876-const-endianess.patch -Patch0001: 0001-std-stop-backtracing-when-the-frames-are-full.patch -Patch0002: 0001-Set-more-llvm-function-attributes-for-__rust_try.patch -BuildRequires: cargo >= 1.28.0 (%{name} >= 1.28.0 with %{name} <= 1.29.1) -BuildRequires: make gcc-c++ ncurses-devel curl python3 cmake3 >= 3.4.3 procps-ng -BuildRequires: pkgconfig(libcurl) pkgconfig(liblzma) pkgconfig(openssl) pkgconfig(zlib) gdb -Requires: %{name}-devel = 1.29.1-%{release} -Provides: bundled(llvm) = 7.0 bundled(libbacktrace) = 8.1.0 bundled(miniz) = 1.16~beta+r1 -Provides: rustc = 1.29.1-%{release} - +%global rustflags -Clink-arg=-Wl,-z,relro,-z,now +%if %{without bundled_llvm} +%if "%{llvm_root}" == "%{_prefix}" || 0%{?scl:1} +%global llvm_has_filecheck 1 +%endif +%endif %description -Rust is a systems programming language focused on three goals:safety, -speed,and concurrency.It maintains these goals without having a garbage -collector, making it a useful language for a number of use cases other -languages are not good at: embedding in other languages, programs with -specific space and time requirements,and writing low-level code, like -device drivers and operating systems. It improves on current languages -targeting this space by having a number of compile-time safety checks -that produce no runtime overhead,while eliminating all data races. - -%package devel -Summary: Libraries and header files for developing applications that use appstream-glib -Provides: %{name}-std-static = %{version}-%{release} -Obsoletes: %{name}-std-static < %{version}-%{release} - -%description devel -Libraries and header files for developing applications that use appstream-glib. +Rust is a systems programming language that runs blazingly fast, prevents +segfaults, and guarantees thread safety. +This package includes the Rust compiler and documentation generator. -%package debugger-common -Summary: Common debugger pretty printers for Rust -BuildArch: noarch +%package std-static +Summary: Standard library for Rust +%description std-static +This package includes the standard libraries for building applications +written in Rust. +%package debugger-common +Summary: Common debugger pretty printers for Rust +BuildArch: noarch %description debugger-common This package includes the common functionality for %{name}-gdb and %{name}-lldb. %package gdb -Summary: GDB pretty printers for Rust -BuildArch: noarch -Requires: gdb -Requires: %{name}-debugger-common = 1.29.1-%{release} - +Summary: GDB pretty printers for Rust +BuildArch: noarch +Requires: gdb %{name}-debugger-common = %{version}-%{release} %description gdb This package includes the rust-gdb script, which allows easier debugging of Rust programs. -%package -n cargo -Summary: Rust's package manager and build tool -Version: 1.29.0 -BuildRequires: git -Requires: rust -Provides: bundled(libgit2) = 0.27 bundled(libssh2) = 1.8.1 +%package lldb +Summary: LLDB pretty printers for Rust +BuildArch: noarch +Requires: lldb %{python}-lldb +Requires: %{name}-debugger-common = %{version}-%{release} +%description lldb +This package includes the rust-lldb script, which allows easier debugging of Rust +programs. + +%package doc +Summary: Documentation for Rust +%description doc +This package includes HTML documentation for the Rust programming language and +its standard library. + +%package -n cargo +Summary: Rust's package manager and build tool +%if %with bundled_libgit2 +Provides: bundled(libgit2) = 1.1.0 +%endif +BuildRequires: git +Requires: rust +Obsoletes: cargo-vendor <= 0.1.23 +Provides: cargo-vendor = %{version}-%{release} %description -n cargo Cargo is a tool that allows Rust projects to declare their various dependencies and ensure that you'll always get a repeatable build. -%package -n rustfmt-preview -Summary: Tool to find and fix Rust formatting issues -Version: 0.99.1 -Requires: cargo -Provides: rustfmt = 0.99.1 -Obsoletes: rustfmt <= 0.9.0 - -%description -n rustfmt-preview +%package -n cargo-doc +Summary: Documentation for Cargo +BuildArch: noarch +Requires: rust-doc = %{version}-%{release} +%description -n cargo-doc +This package includes HTML documentation for Cargo. + +%package -n rustfmt +Summary: Tool to find and fix Rust formatting issues +Requires: cargo +Obsoletes: rustfmt-preview < 1.0.0 +Provides: rustfmt-preview = %{version}-%{release} +%description -n rustfmt A tool for formatting Rust code according to style guidelines. -%package -n rls-preview -Summary: Rust Language Server for IDE integration -Version: 0.130.0 -Provides: rls = 0.130.0 bundled(libgit2) = 0.27 bundled(libssh2) = 1.8.1 -Requires: rust-analysis %{name} = 1.29.1-%{release} - -%description -n rls-preview +%package -n rls +Summary: Rust Language Server for IDE integration +%if %with bundled_libgit2 +Provides: bundled(libgit2) = 1.1.0 +%endif +Requires: rust-analysis %{name}%{?_isa} = %{version}-%{release} +Obsoletes: rls-preview < 1.31.6 +Provides: rls-preview = %{version}-%{release} +%description -n rls The Rust Language Server provides a server that runs in the background, providing IDEs, editors, and other tools with information about Rust programs. It supports functionality such as 'goto definition', symbol search, reformatting, and code completion, and enables renaming and refactorings. -%package -n clippy-preview -Summary: Lints to catch common mistakes and improve your Rust code -Version: 0.0.212 -License: MPLv2.0 -Provides: clippy = 0.0.212 -Requires: cargo %{name} = 1.29.1-%{release} - -%description -n clippy-preview +%package -n clippy +Summary: Lints to catch common mistakes and improve your Rust code +Requires: cargo %{name}%{?_isa} = %{version}-%{release} +Obsoletes: clippy-preview <= 0.0.212 +Provides: clippy-preview = %{version}-%{release} +%description -n clippy A collection of lints to catch common mistakes and improve your Rust code. %package src -Summary: Sources for the Rust standard library -BuildArch: noarch - +Summary: Sources for the Rust standard library +BuildArch: noarch %description src -This package includes source files for the Rust standard library.It may be +This package includes source files for the Rust standard library. It may be useful as a reference for code completion tools in various editors. %package analysis -Summary: Compiler analysis data for the Rust standard library -Requires: rust-std-static = 1.29.1-%{release} - +Summary: Compiler analysis data for the Rust standard library +Requires: rust-std-static%{?_isa} = %{version}-%{release} %description analysis This package contains analysis data files produced with rustc's -Zsave-analysis feature for the Rust standard library. The RLS (Rust Language Server) uses this data to provide information about the Rust standard library. -%package help -Summary: Help documents for rust - -Provides: %{name}-doc = %{version}-%{release} %{name}-cargo-doc = %{version}-%{release} -Obsoletes: %{name}-doc < %{version}-%{release} %{name}-cargo-doc < %{version}-%{release} - -%description help -Man pages and other related help documents for rust. - %prep -%autosetup -n rustc-1.29.1-src -p1 - -sed -i.try-py3 -e '/try python2.7/i try python3 "$@"' ./configure - -rm -rf src/llvm-emscripten/ -sed -e '/*\//q' src/libbacktrace/backtrace.h >src/libbacktrace/LICENSE-libbacktrace - -sed -i.ignore -e '1i // ignore-test may still be exponential...' src/test/run-pass/issue-41696.rs - -find src/vendor -name .cargo-checksum.json -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+' +cd ../SOURCES +cat %{SOURCE1} %{SOURCE2} | tar xJ +cd .. + +%ifarch %{bootstrap_arches} +%setup -q -n %{bootstrap_root} -T -b %{bootstrap_source} +./install.sh --components=cargo,rustc,rust-std-%{rust_triple} \ + --prefix=%{local_rust_root} --disable-ldconfig +test -f '%{local_rust_root}/bin/cargo' +test -f '%{local_rust_root}/bin/rustc' +%endif +%setup -q -n %{rustc_package} +%patch0001 -p1 +%patch0002 -p1 +%patch0003 -p1 +%patch0004 -p1 +%patch0005 -p1 +%patch0006 -p1 +%patch0007 -p1 +%if %with disabled_libssh2 +%patch0008 -p1 +%endif +%if %without curl_http2 +%patch0009 -p1 +rm -rf vendor/libnghttp2-sys/ +%endif +%if "%{python}" != "python3" +sed -i.try-python -e '/^try python3 /i try "%{python}" "$@"' ./configure +%endif +%if %without bundled_llvm +rm -rf src/llvm-project/ +mkdir -p src/llvm-project/libunwind/ +%endif +rm -rf vendor/curl-sys/curl/ +rm -rf vendor/jemalloc-sys/jemalloc/ +rm -rf vendor/libssh2-sys/libssh2/ +rm -rf vendor/libz-sys/src/zlib/ +rm -rf vendor/libz-sys/src/zlib-ng/ +rm -rf vendor/lzma-sys/xz-*/ +rm -rf vendor/openssl-src/openssl/ +%if %without bundled_libgit2 +rm -rf vendor/libgit2-sys/libgit2/ +%endif +%if %with disabled_libssh2 +rm -rf vendor/libssh2-sys/ +%endif +sed -i.lzma -e '/LZMA_API_STATIC/d' src/bootstrap/tool.rs +%if %{without bundled_llvm} && %{with llvm_static} +sed -i.ffi -e '$a #[link(name = "ffi")] extern {}' \ + src/librustc_llvm/lib.rs +%endif +find vendor -name .cargo-checksum.json \ + -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+' +find -name '*.rs' -type f -perm /111 -exec chmod -v -x '{}' '+' +%global rust_env RUSTFLAGS="%{rustflags}" +%if 0%{?cmake_path:1} +%global rust_env %{rust_env} PATH="%{cmake_path}:$PATH" +%endif +%if %without bundled_libgit2 +%global rust_env %{rust_env} LIBGIT2_SYS_USE_PKG_CONFIG=1 +%endif +%if %without disabled_libssh2 +%global rust_env %{rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1 +%endif %build -%{?cmake_path:export PATH=%{cmake_path}:$PATH} -%{?library_path:export LIBRARY_PATH="%{library_path}"} -%{?rustflags:export RUSTFLAGS="-Clink-arg=-Wl,-z,relro,-z,now"} - -%configure --disable-option-checking --libdir=%{_prefix}/lib \ +export %{rust_env} +%global common_libdir %{_prefix}/lib +%global rustlibdir %{common_libdir}/rustlib +%ifarch %{arm} %{ix86} s390x +%define enable_debuginfo --debuginfo-level=0 --debuginfo-level-std=2 +%else +%define enable_debuginfo --debuginfo-level=2 +%endif +%ifnarch %{power64} +%define codegen_units_std --set rust.codegen-units-std=1 +%endif +ncpus=$(/usr/bin/getconf _NPROCESSORS_ONLN) +max_cpus=$(( ($(free -g | awk '/^Mem:/{print $2}') + 1) / 2 )) +if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then + ncpus="$max_cpus" +fi +%configure --disable-option-checking \ + --libdir=%{common_libdir} \ --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \ - --local-rust-root=%{_prefix} --disable-jemalloc --disable-rpath \ - --enable-debuginfo --disable-debuginfo-only-std --enable-debuginfo-tools --disable-debuginfo-lines \ - --enable-extended --enable-vendor --enable-verbose-tests --release-channel=stable - -python3 ./x.py build -python3 ./x.py doc + --python=%{python} \ + --local-rust-root=%{local_rust_root} \ + %{!?with_bundled_llvm: --llvm-root=%{llvm_root} \ + %{!?llvm_has_filecheck: --disable-codegen-tests} \ + %{!?with_llvm_static: --enable-llvm-link-shared } } \ + --disable-rpath \ + %{enable_debuginfo} \ + --enable-extended \ + --tools=analysis,cargo,clippy,rls,rustfmt,src \ + --enable-vendor \ + --enable-verbose-tests \ + %{?codegen_units_std} \ + --release-channel=%{channel} +%{python} ./x.py build -j "$ncpus" --stage 2 +%{python} ./x.py doc --stage 2 %install -%{?cmake_path:export PATH=%{cmake_path}:$PATH} -%{?library_path:export LIBRARY_PATH="%{library_path}"} -%{?rustflags:export RUSTFLAGS="-Clink-arg=-Wl,-z,relro,-z,now"} - -DESTDIR=%{buildroot} python3 ./x.py install - -install -d %{buildroot}%{_libdir} -find %{buildroot}%{_prefix}/lib -maxdepth 1 -type f -name '*.so' -exec mv -v -t %{buildroot}%{_libdir} '{}' '+' - -find %{buildroot}%{_libdir} -maxdepth 1 -type f -name '*.so' -exec chmod -v +x '{}' '+' - +export %{rust_env} +DESTDIR=%{buildroot} %{python} ./x.py install +%if "%{_libdir}" != "%{common_libdir}" +mkdir -p %{buildroot}%{_libdir} +find %{buildroot}%{common_libdir} -maxdepth 1 -type f -name '*.so' \ + -exec mv -v -t %{buildroot}%{_libdir} '{}' '+' +%endif +find %{buildroot}%{_libdir} -maxdepth 1 -type f -name '*.so' \ + -exec chmod -v +x '{}' '+' (cd "%{buildroot}%{rustlibdir}/%{rust_triple}/lib" && find ../../../../%{_lib} -maxdepth 1 -name '*.so' | while read lib; do - cmp "$lib" "${lib##*/}" - ln -v -f -s -t . "$lib" + if [ -f "${lib##*/}" ]; then + # make sure they're actually identical! + cmp "$lib" "${lib##*/}" + ln -v -f -s -t . "$lib" + fi done) - find %{buildroot}%{rustlibdir} -maxdepth 1 -type f -exec rm -v '{}' '+' find %{buildroot}%{rustlibdir} -type f -name '*.orig' -exec rm -v '{}' '+' find %{buildroot}%{rustlibdir}/src -type f -name '*.py' -exec rm -v '{}' '+' +rm -f %{buildroot}%{_docdir}/%{name}/README.md +rm -f %{buildroot}%{_docdir}/%{name}/COPYRIGHT +rm -f %{buildroot}%{_docdir}/%{name}/LICENSE +rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-APACHE +rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-MIT +rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-THIRD-PARTY +rm -f %{buildroot}%{_docdir}/%{name}/*.old find %{buildroot}%{_docdir}/%{name}/html -empty -delete find %{buildroot}%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+' - -install -d %{buildroot}%{_datadir}/cargo/registry -install -d %{buildroot}%{_docdir}/cargo +mkdir -p %{buildroot}%{_datadir}/cargo/registry +mkdir -p %{buildroot}%{_docdir}/cargo ln -sT ../rust/html/cargo/ %{buildroot}%{_docdir}/cargo/html +%if %without lldb +rm -f %{buildroot}%{_bindir}/rust-lldb +rm -f %{buildroot}%{rustlibdir}/etc/lldb_* +%endif +rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll* %check -%{?cmake_path:export PATH=%{cmake_path}:$PATH} -%{?library_path:export LIBRARY_PATH="%{library_path}"} -%{?rustflags:export RUSTFLAGS="-Clink-arg=-Wl,-z,relro,-z,now"} - -python3 ./x.py test --no-fail-fast || : -python3 ./x.py test --no-fail-fast cargo || : -python3 ./x.py test --no-fail-fast clippy || : -python3 ./x.py test --no-fail-fast rls || : -python3 ./x.py test --no-fail-fast rustfmt || : - -%post -/sbin/ldconfig -%postun -/sbin/ldconfig +export %{rust_env} +%{python} ./x.py test --no-fail-fast --stage 2 || : +%{python} ./x.py test --no-fail-fast --stage 2 cargo || : +%{python} ./x.py test --no-fail-fast --stage 2 clippy || : +%{python} ./x.py test --no-fail-fast --stage 2 rls || : +%{python} ./x.py test --no-fail-fast --stage 2 rustfmt || : +%ldconfig_scriptlets %files -%doc README.md %license COPYRIGHT LICENSE-APACHE LICENSE-MIT -%license src/libbacktrace/LICENSE-libbacktrace -%license %{_docdir}/%{name}/html/*.txt -%dir %{rustlibdir} -%dir %{rustlibdir}/%{rust_triple} -%dir %{rustlibdir}/%{rust_triple}/lib +%doc README.md %{_bindir}/rustc %{_bindir}/rustdoc %{_libdir}/*.so +%{_mandir}/man1/rustc.1* +%{_mandir}/man1/rustdoc.1* +%dir %{rustlibdir} +%dir %{rustlibdir}/%{rust_triple} +%dir %{rustlibdir}/%{rust_triple}/lib %{rustlibdir}/%{rust_triple}/lib/*.so -%{rustlibdir}/%{rust_triple}/codegen-backends/ -%exclude %{_docdir}/%{name}/{README.md,COPYRIGHT,LICENSE,*.old} -%exclude %{_docdir}/%{name}/LICENSE-{APACHE,MIT,THIRD-PARTY} -%exclude %{rustlibdir}/etc/lldb_*.py* -%exclude %{_bindir}/rust-lldb -%files devel +%files std-static %dir %{rustlibdir} %dir %{rustlibdir}/%{rust_triple} %dir %{rustlibdir}/%{rust_triple}/lib @@ -226,37 +393,65 @@ python3 ./x.py test --no-fail-fast rustfmt || : %files debugger-common %dir %{rustlibdir} %dir %{rustlibdir}/etc -%{rustlibdir}/etc/debugger_*.py* +%{rustlibdir}/etc/rust_*.py* %files gdb %{_bindir}/rust-gdb -%{rustlibdir}/etc/gdb_*.py* +%{rustlibdir}/etc/gdb_* +%exclude %{_bindir}/rust-gdbgui +%if %with lldb + +%files lldb +%{_bindir}/rust-lldb +%{rustlibdir}/etc/lldb_* +%endif + +%files doc +%docdir %{_docdir}/%{name} +%dir %{_docdir}/%{name} +%dir %{_docdir}/%{name}/html +%{_docdir}/%{name}/html/*/ +%{_docdir}/%{name}/html/*.html +%{_docdir}/%{name}/html/*.css +%{_docdir}/%{name}/html/*.js +%{_docdir}/%{name}/html/*.png +%{_docdir}/%{name}/html/*.svg +%{_docdir}/%{name}/html/*.woff +%license %{_docdir}/%{name}/html/*.txt +%license %{_docdir}/%{name}/html/*.md %files -n cargo -%doc src/tools/cargo/README.md %license src/tools/cargo/LICENSE-APACHE src/tools/cargo/LICENSE-MIT src/tools/cargo/LICENSE-THIRD-PARTY -%dir %{_datadir}/cargo -%dir %{_datadir}/cargo/registry +%doc src/tools/cargo/README.md %{_bindir}/cargo +%{_libexecdir}/cargo* +%{_mandir}/man1/cargo*.1* %{_sysconfdir}/bash_completion.d/cargo %{_datadir}/zsh/site-functions/_cargo +%dir %{_datadir}/cargo +%dir %{_datadir}/cargo/registry -%files -n rustfmt-preview -%doc src/tools/rustfmt/{README,CHANGELOG,Configurations}.md -%license src/tools/rustfmt/LICENSE-{APACHE,MIT} +%files -n cargo-doc +%docdir %{_docdir}/cargo +%dir %{_docdir}/cargo +%{_docdir}/cargo/html + +%files -n rustfmt %{_bindir}/rustfmt %{_bindir}/cargo-fmt +%doc src/tools/rustfmt/{README,CHANGELOG,Configurations}.md +%license src/tools/rustfmt/LICENSE-{APACHE,MIT} -%files -n rls-preview +%files -n rls +%{_bindir}/rls %doc src/tools/rls/{README.md,COPYRIGHT,debugging.md} %license src/tools/rls/LICENSE-{APACHE,MIT} -%{_bindir}/rls -%files -n clippy-preview -%doc src/tools/clippy/{README.md,CHANGELOG.md} -%license src/tools/clippy/LICENSE +%files -n clippy %{_bindir}/cargo-clippy %{_bindir}/clippy-driver +%doc src/tools/clippy/{README.md,CHANGELOG.md} +%license src/tools/clippy/LICENSE-{APACHE,MIT} %files src %dir %{rustlibdir} @@ -265,23 +460,18 @@ python3 ./x.py test --no-fail-fast rustfmt || : %files analysis %{rustlibdir}/%{rust_triple}/analysis/ -%files help -%dir %{_docdir}/%{name} -%dir %{_docdir}/cargo -%dir %{_docdir}/%{name}/html -%docdir %{_docdir}/%{name} -%docdir %{_docdir}/cargo -%{_docdir}/%{name}/html/*/ -%{_docdir}/%{name}/html/*.html -%{_docdir}/%{name}/html/*.css -%{_docdir}/%{name}/html/*.js -%{_docdir}/%{name}/html/*.svg -%{_docdir}/%{name}/html/*.woff -%{_docdir}/cargo/html -%{_mandir}/man1/rustc.1* -%{_mandir}/man1/rustdoc.1* -%{_mandir}/man1/cargo*.1* - %changelog +* Fri May 07 2021 wangyue - 1.51.0-1 +- Update to 1.51.0 + +* Mon Aug 17 2020 zhangjiapeng - 1.45.2-1 +- Update to 1.45.2 + +* Wed Jul 15 2020 yanan li - 1.38.0-1 +- Update to 1.38.0-1 + +* Fri Jun 5 2020 yaokai - 1.30.0-1 +- Update to 1.30.0-1 + * Thu Dec 5 2019 wutao - 1.29.1-3 - Package init diff --git a/rust.yaml b/rust.yaml new file mode 100644 index 0000000000000000000000000000000000000000..45b29fd1744c8224fae666e792583a1e0e5232e8 --- /dev/null +++ b/rust.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: rust-lang/rust +tag_prefix: ^ +seperator: . diff --git a/rustc-1.48.0-disable-libssh2.patch b/rustc-1.48.0-disable-libssh2.patch new file mode 100644 index 0000000000000000000000000000000000000000..6916e7408056d2e2bc809263d6ebf7b72f4b1769 --- /dev/null +++ b/rustc-1.48.0-disable-libssh2.patch @@ -0,0 +1,42 @@ +--- rustc-1.48.0-src/Cargo.lock.orig 2020-11-16 06:01:53.000000000 -0800 ++++ rustc-1.48.0-src/Cargo.lock 2020-11-16 09:27:44.425104404 -0800 +@@ -1676,7 +1676,6 @@ + dependencies = [ + "cc", + "libc", +- "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +@@ -1693,20 +1692,6 @@ + ] + + [[package]] +-name = "libssh2-sys" +-version = "0.2.19" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "ca46220853ba1c512fc82826d0834d87b06bcd3c2a42241b7de72f3d2fe17056" +-dependencies = [ +- "cc", +- "libc", +- "libz-sys", +- "openssl-sys", +- "pkg-config", +- "vcpkg", +-] +- +-[[package]] + name = "libz-sys" + version = "1.1.2" + source = "registry+https://github.com/rust-lang/crates.io-index" +--- rustc-1.48.0-src/vendor/git2/Cargo.toml.orig 2020-11-16 06:27:49.000000000 -0800 ++++ rustc-1.48.0-src/vendor/git2/Cargo.toml 2020-11-16 09:27:44.425104404 -0800 +@@ -49,7 +49,7 @@ + version = "0.1.39" + + [features] +-default = ["ssh", "https", "ssh_key_from_memory"] ++default = ["https"] + https = ["libgit2-sys/https", "openssl-sys", "openssl-probe"] + ssh = ["libgit2-sys/ssh"] + ssh_key_from_memory = ["libgit2-sys/ssh_key_from_memory"] diff --git a/rustc-1.51.0-backport-pr81728.patch b/rustc-1.51.0-backport-pr81728.patch new file mode 100644 index 0000000000000000000000000000000000000000..20373f42d307fe37ffcdae66dcfe04b948d5a756 --- /dev/null +++ b/rustc-1.51.0-backport-pr81728.patch @@ -0,0 +1,181 @@ +From 70f17ca715d3d7e2fd79cc909b95fd3a6357c13e Mon Sep 17 00:00:00 2001 +From: Yechan Bae +Date: Wed, 3 Feb 2021 16:36:33 -0500 +Subject: [PATCH 1/2] Fixes #80335 + +--- + library/alloc/src/str.rs | 42 ++++++++++++++++++++++---------------- + library/alloc/tests/str.rs | 30 +++++++++++++++++++++++++++ + 2 files changed, 54 insertions(+), 18 deletions(-) + +diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs +index 70e0c7dba5ea..a7584c6b6510 100644 +--- a/library/alloc/src/str.rs ++++ b/library/alloc/src/str.rs +@@ -90,8 +90,8 @@ fn join(slice: &Self, sep: &str) -> String { + } + } + +-macro_rules! spezialize_for_lengths { +- ($separator:expr, $target:expr, $iter:expr; $($num:expr),*) => { ++macro_rules! specialize_for_lengths { ++ ($separator:expr, $target:expr, $iter:expr; $($num:expr),*) => {{ + let mut target = $target; + let iter = $iter; + let sep_bytes = $separator; +@@ -102,7 +102,8 @@ macro_rules! spezialize_for_lengths { + $num => { + for s in iter { + copy_slice_and_advance!(target, sep_bytes); +- copy_slice_and_advance!(target, s.borrow().as_ref()); ++ let content_bytes = s.borrow().as_ref(); ++ copy_slice_and_advance!(target, content_bytes); + } + }, + )* +@@ -110,11 +111,13 @@ macro_rules! spezialize_for_lengths { + // arbitrary non-zero size fallback + for s in iter { + copy_slice_and_advance!(target, sep_bytes); +- copy_slice_and_advance!(target, s.borrow().as_ref()); ++ let content_bytes = s.borrow().as_ref(); ++ copy_slice_and_advance!(target, content_bytes); + } + } + } +- }; ++ target ++ }} + } + + macro_rules! copy_slice_and_advance { +@@ -153,7 +156,7 @@ fn join_generic_copy(slice: &[S], sep: &[T]) -> Vec + // if the `len` calculation overflows, we'll panic + // we would have run out of memory anyway and the rest of the function requires + // the entire Vec pre-allocated for safety +- let len = sep_len ++ let reserved_len = sep_len + .checked_mul(iter.len()) + .and_then(|n| { + slice.iter().map(|s| s.borrow().as_ref().len()).try_fold(n, usize::checked_add) +@@ -161,22 +164,25 @@ fn join_generic_copy(slice: &[S], sep: &[T]) -> Vec + .expect("attempt to join into collection with len > usize::MAX"); + + // crucial for safety +- let mut result = Vec::with_capacity(len); +- assert!(result.capacity() >= len); ++ let mut result = Vec::with_capacity(reserved_len); ++ debug_assert!(result.capacity() >= reserved_len); + + result.extend_from_slice(first.borrow().as_ref()); + + unsafe { +- { +- let pos = result.len(); +- let target = result.get_unchecked_mut(pos..len); +- +- // copy separator and slices over without bounds checks +- // generate loops with hardcoded offsets for small separators +- // massive improvements possible (~ x2) +- spezialize_for_lengths!(sep, target, iter; 0, 1, 2, 3, 4); +- } +- result.set_len(len); ++ let pos = result.len(); ++ let target = result.get_unchecked_mut(pos..reserved_len); ++ ++ // copy separator and slices over without bounds checks ++ // generate loops with hardcoded offsets for small separators ++ // massive improvements possible (~ x2) ++ let remain = specialize_for_lengths!(sep, target, iter; 0, 1, 2, 3, 4); ++ ++ // issue #80335: A weird borrow implementation can return different ++ // slices for the length calculation and the actual copy, so ++ // `remain.len()` might be non-zero. ++ let result_len = reserved_len - remain.len(); ++ result.set_len(result_len); + } + result + } +diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs +index 604835e6cc4a..6df8d8c2f354 100644 +--- a/library/alloc/tests/str.rs ++++ b/library/alloc/tests/str.rs +@@ -160,6 +160,36 @@ fn test_join_for_different_lengths_with_long_separator() { + test_join!("~~~~~a~~~~~bc", ["", "a", "bc"], "~~~~~"); + } + ++#[test] ++fn test_join_isue_80335() { ++ use core::{borrow::Borrow, cell::Cell}; ++ ++ struct WeirdBorrow { ++ state: Cell, ++ } ++ ++ impl Default for WeirdBorrow { ++ fn default() -> Self { ++ WeirdBorrow { state: Cell::new(false) } ++ } ++ } ++ ++ impl Borrow for WeirdBorrow { ++ fn borrow(&self) -> &str { ++ let state = self.state.get(); ++ if state { ++ "0" ++ } else { ++ self.state.set(true); ++ "123456" ++ } ++ } ++ } ++ ++ let arr: [WeirdBorrow; 3] = Default::default(); ++ test_join!("0-0-0", arr, "-"); ++} ++ + #[test] + #[cfg_attr(miri, ignore)] // Miri is too slow + fn test_unsafe_slice() { +-- +2.31.1 + + +From 10020817d2e6756be1ff2ac3c182af97cf7fe904 Mon Sep 17 00:00:00 2001 +From: Yechan Bae +Date: Sat, 20 Mar 2021 13:42:54 -0400 +Subject: [PATCH 2/2] Update the comment + +--- + library/alloc/src/str.rs | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs +index a7584c6b6510..4d1e876457b8 100644 +--- a/library/alloc/src/str.rs ++++ b/library/alloc/src/str.rs +@@ -163,7 +163,7 @@ fn join_generic_copy(slice: &[S], sep: &[T]) -> Vec + }) + .expect("attempt to join into collection with len > usize::MAX"); + +- // crucial for safety ++ // prepare an uninitialized buffer + let mut result = Vec::with_capacity(reserved_len); + debug_assert!(result.capacity() >= reserved_len); + +@@ -178,9 +178,9 @@ fn join_generic_copy(slice: &[S], sep: &[T]) -> Vec + // massive improvements possible (~ x2) + let remain = specialize_for_lengths!(sep, target, iter; 0, 1, 2, 3, 4); + +- // issue #80335: A weird borrow implementation can return different +- // slices for the length calculation and the actual copy, so +- // `remain.len()` might be non-zero. ++ // A weird borrow implementation may return different ++ // slices for the length calculation and the actual copy. ++ // Make sure we don't expose uninitialized bytes to the caller. + let result_len = reserved_len - remain.len(); + result.set_len(result_len); + } +-- +2.31.1 + diff --git a/rustc-1.51.0-backport-pr81741.patch b/rustc-1.51.0-backport-pr81741.patch new file mode 100644 index 0000000000000000000000000000000000000000..8ef22eea56fd38cc7de7133d8d2c86c1bc880730 --- /dev/null +++ b/rustc-1.51.0-backport-pr81741.patch @@ -0,0 +1,44 @@ +From 40d3f2d7ef5835317fe9df9ecc01f4c363def4fd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= +Date: Thu, 4 Feb 2021 10:23:01 +0200 +Subject: [PATCH] Increment `self.index` before calling + `Iterator::self.a.__iterator_get_unchecked` in `Zip` `TrustedRandomAccess` + specialization + +Otherwise if `Iterator::self.a.__iterator_get_unchecked` panics the +index would not have been incremented yet and another call to +`Iterator::next` would read from the same index again, which is not +allowed according to the API contract of `TrustedRandomAccess` for +`!Clone`. + +Fixes https://github.com/rust-lang/rust/issues/81740 + +(cherry picked from commit 86a4b27475aab52b998c15f5758540697cc9cff0) +--- + library/core/src/iter/adapters/zip.rs | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs +index 98b8dca96140..9f9835345200 100644 +--- a/library/core/src/iter/adapters/zip.rs ++++ b/library/core/src/iter/adapters/zip.rs +@@ -198,12 +198,13 @@ fn next(&mut self) -> Option<(A::Item, B::Item)> { + Some((self.a.__iterator_get_unchecked(i), self.b.__iterator_get_unchecked(i))) + } + } else if A::may_have_side_effect() && self.index < self.a.size() { ++ let i = self.index; ++ self.index += 1; + // match the base implementation's potential side effects +- // SAFETY: we just checked that `self.index` < `self.a.len()` ++ // SAFETY: we just checked that `i` < `self.a.len()` + unsafe { +- self.a.__iterator_get_unchecked(self.index); ++ self.a.__iterator_get_unchecked(i); + } +- self.index += 1; + None + } else { + None +-- +2.31.1 + diff --git a/rustc-1.51.0-backport-pr81910.patch b/rustc-1.51.0-backport-pr81910.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2f91b68d2a772202524d30fc2f9c1335b1274b2 --- /dev/null +++ b/rustc-1.51.0-backport-pr81910.patch @@ -0,0 +1,48 @@ +From 852684d306cee955ed751f1e8d8eec6adaecff3b Mon Sep 17 00:00:00 2001 +From: Joshua Nelson +Date: Mon, 8 Feb 2021 22:51:21 -0500 +Subject: [PATCH] Use format string in bootstrap panic instead of a string + directly + +This fixes the following warning when compiling with nightly: + +``` +warning: panic message is not a string literal + --> src/bootstrap/builder.rs:1515:24 + | +1515 | panic!(out); + | ^^^ + | + = note: `#[warn(non_fmt_panic)]` on by default + = note: this is no longer accepted in Rust 2021 +help: add a "{}" format string to Display the message + | +1515 | panic!("{}", out); + | ^^^^^ +help: or use std::panic::panic_any instead + | +1515 | std::panic::panic_any(out); + | ^^^^^^^^^^^^^^^^^^^^^^ +``` + +(cherry picked from commit 31c93397bde772764cda3058e16f9cef61895090) +--- + src/bootstrap/builder.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs +index f1a160250dbe..0f5fcb4af400 100644 +--- a/src/bootstrap/builder.rs ++++ b/src/bootstrap/builder.rs +@@ -1490,7 +1490,7 @@ pub fn ensure(&'a self, step: S) -> S::Output { + for el in stack.iter().rev() { + out += &format!("\t{:?}\n", el); + } +- panic!(out); ++ panic!("{}", out); + } + if let Some(out) = self.cache.get(&step) { + self.verbose(&format!("{}c {:?}", " ".repeat(stack.len()), step)); +-- +2.31.1 + diff --git a/rustc-1.51.0-backport-pr82289.patch b/rustc-1.51.0-backport-pr82289.patch new file mode 100644 index 0000000000000000000000000000000000000000..5cf5433197755cf5912642f9f397c869bfc24bda --- /dev/null +++ b/rustc-1.51.0-backport-pr82289.patch @@ -0,0 +1,96 @@ +From 5222e2ba2d97cd716a379b4ae6bc62c5f7c2dd36 Mon Sep 17 00:00:00 2001 +From: Giacomo Stevanato +Date: Fri, 19 Feb 2021 12:15:37 +0100 +Subject: [PATCH 1/3] Increment self.len in specialized ZipImpl to avoid + underflow in size_hint + +(cherry picked from commit 66a260617a88ed1ad55a46f03c5a90d5ad3004d3) +--- + library/core/src/iter/adapters/zip.rs | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs +index 9f9835345200..f08bfac837fe 100644 +--- a/library/core/src/iter/adapters/zip.rs ++++ b/library/core/src/iter/adapters/zip.rs +@@ -200,6 +200,7 @@ fn next(&mut self) -> Option<(A::Item, B::Item)> { + } else if A::may_have_side_effect() && self.index < self.a.size() { + let i = self.index; + self.index += 1; ++ self.len += 1; + // match the base implementation's potential side effects + // SAFETY: we just checked that `i` < `self.a.len()` + unsafe { +-- +2.31.1 + + +From d39669fc8282830a374d19d204f7b4ee8eb1e381 Mon Sep 17 00:00:00 2001 +From: Giacomo Stevanato +Date: Fri, 19 Feb 2021 12:16:12 +0100 +Subject: [PATCH 2/3] Add test for underflow in specialized Zip's size_hint + +(cherry picked from commit 8b9ac4d4155c74db5b317046033ab9c05a09e351) +--- + library/core/tests/iter/adapters/zip.rs | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/library/core/tests/iter/adapters/zip.rs b/library/core/tests/iter/adapters/zip.rs +index 1fce0951e365..a59771039295 100644 +--- a/library/core/tests/iter/adapters/zip.rs ++++ b/library/core/tests/iter/adapters/zip.rs +@@ -245,3 +245,23 @@ fn test_double_ended_zip() { + assert_eq!(it.next_back(), Some((3, 3))); + assert_eq!(it.next(), None); + } ++ ++#[test] ++fn test_issue_82282() { ++ fn overflowed_zip(arr: &[i32]) -> impl Iterator { ++ static UNIT_EMPTY_ARR: [(); 0] = []; ++ ++ let mapped = arr.into_iter().map(|i| *i); ++ let mut zipped = mapped.zip(UNIT_EMPTY_ARR.iter()); ++ zipped.next(); ++ zipped ++ } ++ ++ let arr = [1, 2, 3]; ++ let zip = overflowed_zip(&arr).zip(overflowed_zip(&arr)); ++ ++ assert_eq!(zip.size_hint(), (0, Some(0))); ++ for _ in zip { ++ panic!(); ++ } ++} +-- +2.31.1 + + +From 4b382167dd5ed5a6eac0cf314bfb86e3704b6e76 Mon Sep 17 00:00:00 2001 +From: Giacomo Stevanato +Date: Fri, 19 Feb 2021 12:17:48 +0100 +Subject: [PATCH 3/3] Remove useless comparison since now self.index <= + self.len is an invariant + +(cherry picked from commit aeb4ea739efb70e0002a4a9c4c7b8027dd0620b3) +--- + library/core/src/iter/adapters/zip.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs +index f08bfac837fe..dcbcb1ce7200 100644 +--- a/library/core/src/iter/adapters/zip.rs ++++ b/library/core/src/iter/adapters/zip.rs +@@ -261,7 +261,7 @@ fn next_back(&mut self) -> Option<(A::Item, B::Item)> + if sz_a != sz_b { + let sz_a = self.a.size(); + if a_side_effect && sz_a > self.len { +- for _ in 0..sz_a - cmp::max(self.len, self.index) { ++ for _ in 0..sz_a - self.len { + self.a.next_back(); + } + } +-- +2.31.1 + diff --git a/rustc-1.51.0-backport-pr82292.patch b/rustc-1.51.0-backport-pr82292.patch new file mode 100644 index 0000000000000000000000000000000000000000..4baf72a26190c86d34c8443564a8de30ddaec5df --- /dev/null +++ b/rustc-1.51.0-backport-pr82292.patch @@ -0,0 +1,120 @@ +From 0babb88efc4d36f3defafc3c3c0343793fa05d52 Mon Sep 17 00:00:00 2001 +From: Giacomo Stevanato +Date: Wed, 3 Mar 2021 21:09:01 +0100 +Subject: [PATCH 1/2] Prevent Zip specialization from calling + __iterator_get_unchecked twice with the same index after calling next_back + +(cherry picked from commit 2371914a05f8f2763dffe6e2511d0870bcd6b461) +--- + library/core/src/iter/adapters/zip.rs | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs +index dcbcb1ce7200..7dac0c63ca2d 100644 +--- a/library/core/src/iter/adapters/zip.rs ++++ b/library/core/src/iter/adapters/zip.rs +@@ -13,9 +13,10 @@ + pub struct Zip { + a: A, + b: B, +- // index and len are only used by the specialized version of zip ++ // index, len and a_len are only used by the specialized version of zip + index: usize, + len: usize, ++ a_len: usize, + } + impl Zip { + pub(in crate::iter) fn new(a: A, b: B) -> Zip { +@@ -110,6 +111,7 @@ impl ZipImpl for Zip + b, + index: 0, // unused + len: 0, // unused ++ a_len: 0, // unused + } + } + +@@ -184,8 +186,9 @@ impl ZipImpl for Zip + B: TrustedRandomAccess + Iterator, + { + fn new(a: A, b: B) -> Self { +- let len = cmp::min(a.size(), b.size()); +- Zip { a, b, index: 0, len } ++ let a_len = a.size(); ++ let len = cmp::min(a_len, b.size()); ++ Zip { a, b, index: 0, len, a_len } + } + + #[inline] +@@ -197,7 +200,7 @@ fn next(&mut self) -> Option<(A::Item, B::Item)> { + unsafe { + Some((self.a.__iterator_get_unchecked(i), self.b.__iterator_get_unchecked(i))) + } +- } else if A::may_have_side_effect() && self.index < self.a.size() { ++ } else if A::may_have_side_effect() && self.index < self.a_len { + let i = self.index; + self.index += 1; + self.len += 1; +@@ -264,6 +267,7 @@ fn next_back(&mut self) -> Option<(A::Item, B::Item)> + for _ in 0..sz_a - self.len { + self.a.next_back(); + } ++ self.a_len = self.len; + } + let sz_b = self.b.size(); + if b_side_effect && sz_b > self.len { +@@ -275,6 +279,7 @@ fn next_back(&mut self) -> Option<(A::Item, B::Item)> + } + if self.index < self.len { + self.len -= 1; ++ self.a_len -= 1; + let i = self.len; + // SAFETY: `i` is smaller than the previous value of `self.len`, + // which is also smaller than or equal to `self.a.len()` and `self.b.len()` +-- +2.31.1 + + +From 19af66a6f3e2bbb4780bb9eae7eb53bd13e3dd0f Mon Sep 17 00:00:00 2001 +From: Giacomo Stevanato +Date: Fri, 19 Feb 2021 15:25:09 +0100 +Subject: [PATCH 2/2] Add relevant test + +(cherry picked from commit c1bfb9a78db6d481be1d03355672712c766e20b0) +--- + library/core/tests/iter/adapters/zip.rs | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/library/core/tests/iter/adapters/zip.rs b/library/core/tests/iter/adapters/zip.rs +index a59771039295..000c15f72c88 100644 +--- a/library/core/tests/iter/adapters/zip.rs ++++ b/library/core/tests/iter/adapters/zip.rs +@@ -265,3 +265,26 @@ fn overflowed_zip(arr: &[i32]) -> impl Iterator { + panic!(); + } + } ++ ++#[test] ++fn test_issue_82291() { ++ use std::cell::Cell; ++ ++ let mut v1 = [()]; ++ let v2 = [()]; ++ ++ let called = Cell::new(0); ++ ++ let mut zip = v1 ++ .iter_mut() ++ .map(|r| { ++ called.set(called.get() + 1); ++ r ++ }) ++ .zip(&v2); ++ ++ zip.next_back(); ++ assert_eq!(called.get(), 1); ++ zip.next(); ++ assert_eq!(called.get(), 1); ++} +-- +2.31.1 + diff --git a/rustc-1.51.0-backport-pr83629.patch b/rustc-1.51.0-backport-pr83629.patch new file mode 100644 index 0000000000000000000000000000000000000000..7f68d95cc7f483a6ea1cbc2bd6ee3db0e258f6c6 --- /dev/null +++ b/rustc-1.51.0-backport-pr83629.patch @@ -0,0 +1,142 @@ +From 3834e7b7393bf1a0d7df02ccd1d2e896c1465769 Mon Sep 17 00:00:00 2001 +From: The8472 +Date: Mon, 29 Mar 2021 04:22:34 +0200 +Subject: [PATCH 1/2] add testcase for double-drop during Vec in-place + collection + +--- + library/alloc/tests/vec.rs | 38 +++++++++++++++++++++++++++++++++++++- + 1 file changed, 37 insertions(+), 1 deletion(-) + +diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs +index 5c7ff67bc621..4cdb7eefcdf1 100644 +--- a/library/alloc/tests/vec.rs ++++ b/library/alloc/tests/vec.rs +@@ -954,7 +954,7 @@ fn test_from_iter_specialization_head_tail_drop() { + } + + #[test] +-fn test_from_iter_specialization_panic_drop() { ++fn test_from_iter_specialization_panic_during_iteration_drops() { + let drop_count: Vec<_> = (0..=2).map(|_| Rc::new(())).collect(); + let src: Vec<_> = drop_count.iter().cloned().collect(); + let iter = src.into_iter(); +@@ -977,6 +977,42 @@ fn test_from_iter_specialization_panic_drop() { + ); + } + ++#[test] ++fn test_from_iter_specialization_panic_during_drop_leaks() { ++ static mut DROP_COUNTER: usize = 0; ++ ++ #[derive(Debug)] ++ enum Droppable { ++ DroppedTwice(Box), ++ PanicOnDrop, ++ } ++ ++ impl Drop for Droppable { ++ fn drop(&mut self) { ++ match self { ++ Droppable::DroppedTwice(_) => { ++ unsafe { ++ DROP_COUNTER += 1; ++ } ++ println!("Dropping!") ++ } ++ Droppable::PanicOnDrop => { ++ if !std::thread::panicking() { ++ panic!(); ++ } ++ } ++ } ++ } ++ } ++ ++ let _ = std::panic::catch_unwind(AssertUnwindSafe(|| { ++ let v = vec![Droppable::DroppedTwice(Box::new(123)), Droppable::PanicOnDrop]; ++ let _ = v.into_iter().take(0).collect::>(); ++ })); ++ ++ assert_eq!(unsafe { DROP_COUNTER }, 1); ++} ++ + #[test] + fn test_cow_from() { + let borrowed: &[_] = &["borrowed", "(slice)"]; +-- +2.31.1 + + +From 8e2706343e1ce1c5a2d3a2ceaaaa010aaeb21d93 Mon Sep 17 00:00:00 2001 +From: The8472 +Date: Mon, 29 Mar 2021 04:22:48 +0200 +Subject: [PATCH 2/2] fix double-drop in in-place collect specialization + +--- + library/alloc/src/vec/into_iter.rs | 27 ++++++++++++++------- + library/alloc/src/vec/source_iter_marker.rs | 4 +-- + 2 files changed, 20 insertions(+), 11 deletions(-) + +diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs +index f131d06bb18f..74adced53f6d 100644 +--- a/library/alloc/src/vec/into_iter.rs ++++ b/library/alloc/src/vec/into_iter.rs +@@ -85,20 +85,29 @@ fn as_raw_mut_slice(&mut self) -> *mut [T] { + ptr::slice_from_raw_parts_mut(self.ptr as *mut T, self.len()) + } + +- pub(super) fn drop_remaining(&mut self) { +- unsafe { +- ptr::drop_in_place(self.as_mut_slice()); +- } +- self.ptr = self.end; +- } ++ /// Drops remaining elements and relinquishes the backing allocation. ++ /// ++ /// This is roughly equivalent to the following, but more efficient ++ /// ++ /// ``` ++ /// # let mut into_iter = Vec::::with_capacity(10).into_iter(); ++ /// (&mut into_iter).for_each(core::mem::drop); ++ /// unsafe { core::ptr::write(&mut into_iter, Vec::new().into_iter()); } ++ /// ``` ++ pub(super) fn forget_allocation_drop_remaining(&mut self) { ++ let remaining = self.as_raw_mut_slice(); + +- /// Relinquishes the backing allocation, equivalent to +- /// `ptr::write(&mut self, Vec::new().into_iter())` +- pub(super) fn forget_allocation(&mut self) { ++ // overwrite the individual fields instead of creating a new ++ // struct and then overwriting &mut self. ++ // this creates less assembly + self.cap = 0; + self.buf = unsafe { NonNull::new_unchecked(RawVec::NEW.ptr()) }; + self.ptr = self.buf.as_ptr(); + self.end = self.buf.as_ptr(); ++ ++ unsafe { ++ ptr::drop_in_place(remaining); ++ } + } + } + +diff --git a/library/alloc/src/vec/source_iter_marker.rs b/library/alloc/src/vec/source_iter_marker.rs +index 8c0e95559fa1..9301f7a5184e 100644 +--- a/library/alloc/src/vec/source_iter_marker.rs ++++ b/library/alloc/src/vec/source_iter_marker.rs +@@ -78,9 +78,9 @@ impl SpecFromIter for Vec + } + + // drop any remaining values at the tail of the source +- src.drop_remaining(); + // but prevent drop of the allocation itself once IntoIter goes out of scope +- src.forget_allocation(); ++ // if the drop panics then we also leak any elements collected into dst_buf ++ src.forget_allocation_drop_remaining(); + + let vec = unsafe { + let len = dst.offset_from(dst_buf) as usize; +-- +2.31.1 + diff --git a/rustc-1.51.0-disable-http2.patch b/rustc-1.51.0-disable-http2.patch new file mode 100644 index 0000000000000000000000000000000000000000..2517a343aec839f6c476b7b5d36109f717dea747 --- /dev/null +++ b/rustc-1.51.0-disable-http2.patch @@ -0,0 +1,66 @@ +--- rustc-beta-src/Cargo.lock.orig 2021-03-09 10:30:08.626424998 -0800 ++++ rustc-beta-src/Cargo.lock 2021-03-09 10:32:38.096207704 -0800 +@@ -899,7 +899,6 @@ + dependencies = [ + "cc", + "libc", +- "libnghttp2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +@@ -1860,16 +1859,6 @@ + ] + + [[package]] +-name = "libnghttp2-sys" +-version = "0.1.4+1.41.0" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "03624ec6df166e79e139a2310ca213283d6b3c30810c54844f307086d4488df1" +-dependencies = [ +- "cc", +- "libc", +-] +- +-[[package]] + name = "libz-sys" + version = "1.1.2" + source = "registry+https://github.com/rust-lang/crates.io-index" +--- rustc-beta-src/src/tools/cargo/Cargo.toml.orig 2021-03-05 08:34:15.000000000 -0800 ++++ rustc-beta-src/src/tools/cargo/Cargo.toml 2021-03-09 10:32:38.096207704 -0800 +@@ -25,7 +25,7 @@ + crates-io = { path = "crates/crates-io", version = "0.33.0" } + crossbeam-utils = "0.8" + crypto-hash = "0.3.1" +-curl = { version = "0.4.23", features = ["http2"] } ++curl = { version = "0.4.23", features = [] } + curl-sys = "0.4.22" + env_logger = "0.8.1" + pretty_env_logger = { version = "0.4", optional = true } +--- rustc-beta-src/src/tools/cargo/src/cargo/core/package.rs.orig 2021-03-05 08:34:15.000000000 -0800 ++++ rustc-beta-src/src/tools/cargo/src/cargo/core/package.rs 2021-03-09 10:32:38.096207704 -0800 +@@ -412,14 +412,8 @@ + // Also note that pipelining is disabled as curl authors have indicated + // that it's buggy, and we've empirically seen that it's buggy with HTTP + // proxies. +- let mut multi = Multi::new(); +- let multiplexing = config.http_config()?.multiplexing.unwrap_or(true); +- multi +- .pipelining(false, multiplexing) +- .chain_err(|| "failed to enable multiplexing/pipelining in curl")?; +- +- // let's not flood crates.io with connections +- multi.set_max_host_connections(2)?; ++ let multi = Multi::new(); ++ let multiplexing = false; + + Ok(PackageSet { + packages: package_ids +@@ -592,7 +586,7 @@ + macro_rules! try_old_curl { + ($e:expr, $msg:expr) => { + let result = $e; +- if cfg!(target_os = "macos") { ++ if cfg!(any(target_os = "linux", target_os = "macos")) { + if let Err(e) = result { + warn!("ignoring libcurl {} error: {}", $msg, e); + } diff --git a/rustc-1.51.0-src.tar.xz b/rustc-1.51.0-src.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..209c4fd680e94b949b91366445c9cd7fb6e01318 Binary files /dev/null and b/rustc-1.51.0-src.tar.xz differ diff --git a/rustc-1.29.1-src.tar.xz b/rustc-1.51.0-src.tar.xz.aa similarity index 80% rename from rustc-1.29.1-src.tar.xz rename to rustc-1.51.0-src.tar.xz.aa index 6ecd27dd7a79602faf978bd1529d4c39a56997a8..7a258f811aa7a6f96cb737d9aa1b5348deb5ba46 100644 Binary files a/rustc-1.29.1-src.tar.xz and b/rustc-1.51.0-src.tar.xz.aa differ diff --git a/rustc-1.51.0-src.tar.xz.ab b/rustc-1.51.0-src.tar.xz.ab new file mode 100644 index 0000000000000000000000000000000000000000..2a167a3b43bf2e5ba487c79f9e49cbf42023019d Binary files /dev/null and b/rustc-1.51.0-src.tar.xz.ab differ