From 45dc2777fc70e368d123f80d5b962eba9dbdc39c Mon Sep 17 00:00:00 2001 From: Jan Palus Date: Thu, 1 Jun 2023 23:07:43 +0200 Subject: [PATCH] up to 1.70.0 --- 111167.patch | 248 --------------------------------------- llvm-tools-install.patch | 31 ----- rust.spec | 24 ++-- 3 files changed, 10 insertions(+), 293 deletions(-) delete mode 100644 111167.patch delete mode 100644 llvm-tools-install.patch diff --git a/111167.patch b/111167.patch deleted file mode 100644 index 3dc75ed..0000000 --- a/111167.patch +++ /dev/null @@ -1,248 +0,0 @@ -From 10b69dde3fd15334ea2382d2dc9e9a261de1afaf Mon Sep 17 00:00:00 2001 -From: Josh Stone -Date: Wed, 3 May 2023 15:52:31 -0700 -Subject: [PATCH] debuginfo: split method declaration and definition - -When we're adding a method to a type DIE, we only want a DW_AT_declaration -there, because LLVM LTO can't unify type definitions when a child DIE is a -full subprogram definition. Now the subprogram definition gets added at the -CU level with a specification link back to the abstract declaration. ---- - .../rustc_codegen_llvm/src/debuginfo/mod.rs | 85 +++++++++++-------- - compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 15 ++++ - .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 22 +++++ - .../issue-109934-lto-debuginfo/Makefile | 12 +++ - .../issue-109934-lto-debuginfo/lib.rs | 9 ++ - 5 files changed, 109 insertions(+), 34 deletions(-) - create mode 100644 tests/run-make/issue-109934-lto-debuginfo/Makefile - create mode 100644 tests/run-make/issue-109934-lto-debuginfo/lib.rs - -diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs -index 2e9f89f419696..b138b0c0e70a1 100644 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs -@@ -322,7 +322,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { - let tcx = self.tcx; - - let def_id = instance.def_id(); -- let containing_scope = get_containing_scope(self, instance); -+ let (containing_scope, is_method) = get_containing_scope(self, instance); - let span = tcx.def_span(def_id); - let loc = self.lookup_debug_loc(span.lo()); - let file_metadata = file_metadata(self, &loc.file); -@@ -378,8 +378,29 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { - } - } - -- unsafe { -- return llvm::LLVMRustDIBuilderCreateFunction( -+ // When we're adding a method to a type DIE, we only want a DW_AT_declaration there, because -+ // LLVM LTO can't unify type definitions when a child DIE is a full subprogram definition. -+ // When we use this `decl` below, the subprogram definition gets created at the CU level -+ // with a DW_AT_specification pointing back to the type's declaration. -+ let decl = is_method.then(|| unsafe { -+ llvm::LLVMRustDIBuilderCreateMethod( -+ DIB(self), -+ containing_scope, -+ name.as_ptr().cast(), -+ name.len(), -+ linkage_name.as_ptr().cast(), -+ linkage_name.len(), -+ file_metadata, -+ loc.line, -+ function_type_metadata, -+ flags, -+ spflags & !DISPFlags::SPFlagDefinition, -+ template_parameters, -+ ) -+ }); -+ -+ return unsafe { -+ llvm::LLVMRustDIBuilderCreateFunction( - DIB(self), - containing_scope, - name.as_ptr().cast(), -@@ -394,9 +415,9 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { - spflags, - maybe_definition_llfn, - template_parameters, -- None, -- ); -- } -+ decl, -+ ) -+ }; - - fn get_function_signature<'ll, 'tcx>( - cx: &CodegenCx<'ll, 'tcx>, -@@ -493,14 +514,16 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { - names - } - -+ /// Returns a scope, plus `true` if that's a type scope for "class" methods, -+ /// otherwise `false` for plain namespace scopes. - fn get_containing_scope<'ll, 'tcx>( - cx: &CodegenCx<'ll, 'tcx>, - instance: Instance<'tcx>, -- ) -> &'ll DIScope { -+ ) -> (&'ll DIScope, bool) { - // First, let's see if this is a method within an inherent impl. Because - // if yes, we want to make the result subroutine DIE a child of the - // subroutine's self-type. -- let self_type = cx.tcx.impl_of_method(instance.def_id()).and_then(|impl_def_id| { -+ if let Some(impl_def_id) = cx.tcx.impl_of_method(instance.def_id()) { - // If the method does *not* belong to a trait, proceed - if cx.tcx.trait_id_of_impl(impl_def_id).is_none() { - let impl_self_ty = cx.tcx.subst_and_normalize_erasing_regions( -@@ -511,39 +534,33 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { - - // Only "class" methods are generally understood by LLVM, - // so avoid methods on other types (e.g., `<*mut T>::null`). -- match impl_self_ty.kind() { -- ty::Adt(def, ..) if !def.is_box() => { -- // Again, only create type information if full debuginfo is enabled -- if cx.sess().opts.debuginfo == DebugInfo::Full -- && !impl_self_ty.needs_subst() -- { -- Some(type_di_node(cx, impl_self_ty)) -- } else { -- Some(namespace::item_namespace(cx, def.did())) -- } -+ if let ty::Adt(def, ..) = impl_self_ty.kind() && !def.is_box() { -+ // Again, only create type information if full debuginfo is enabled -+ if cx.sess().opts.debuginfo == DebugInfo::Full && !impl_self_ty.needs_subst() -+ { -+ return (type_di_node(cx, impl_self_ty), true); -+ } else { -+ return (namespace::item_namespace(cx, def.did()), false); - } -- _ => None, - } - } else { - // For trait method impls we still use the "parallel namespace" - // strategy -- None - } -- }); -+ } - -- self_type.unwrap_or_else(|| { -- namespace::item_namespace( -- cx, -- DefId { -- krate: instance.def_id().krate, -- index: cx -- .tcx -- .def_key(instance.def_id()) -- .parent -- .expect("get_containing_scope: missing parent?"), -- }, -- ) -- }) -+ let scope = namespace::item_namespace( -+ cx, -+ DefId { -+ krate: instance.def_id().krate, -+ index: cx -+ .tcx -+ .def_key(instance.def_id()) -+ .parent -+ .expect("get_containing_scope: missing parent?"), -+ }, -+ ); -+ (scope, false) - } - } - -diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -index c95148013eb74..1f98d91c32054 100644 ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -1987,6 +1987,21 @@ extern "C" { - Decl: Option<&'a DIDescriptor>, - ) -> &'a DISubprogram; - -+ pub fn LLVMRustDIBuilderCreateMethod<'a>( -+ Builder: &DIBuilder<'a>, -+ Scope: &'a DIDescriptor, -+ Name: *const c_char, -+ NameLen: size_t, -+ LinkageName: *const c_char, -+ LinkageNameLen: size_t, -+ File: &'a DIFile, -+ LineNo: c_uint, -+ Ty: &'a DIType, -+ Flags: DIFlags, -+ SPFlags: DISPFlags, -+ TParam: &'a DIArray, -+ ) -> &'a DISubprogram; -+ - pub fn LLVMRustDIBuilderCreateBasicType<'a>( - Builder: &DIBuilder<'a>, - Name: *const c_char, -diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -index cadb6b1e23fe9..49acd71b3e106 100644 ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -831,6 +831,28 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction( - return wrap(Sub); - } - -+extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMethod( -+ LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, -+ const char *Name, size_t NameLen, -+ const char *LinkageName, size_t LinkageNameLen, -+ LLVMMetadataRef File, unsigned LineNo, -+ LLVMMetadataRef Ty, LLVMRustDIFlags Flags, -+ LLVMRustDISPFlags SPFlags, LLVMMetadataRef TParam) { -+ DITemplateParameterArray TParams = -+ DITemplateParameterArray(unwrap(TParam)); -+ DISubprogram::DISPFlags llvmSPFlags = fromRust(SPFlags); -+ DINode::DIFlags llvmFlags = fromRust(Flags); -+ DISubprogram *Sub = Builder->createMethod( -+ unwrapDI(Scope), -+ StringRef(Name, NameLen), -+ StringRef(LinkageName, LinkageNameLen), -+ unwrapDI(File), LineNo, -+ unwrapDI(Ty), -+ 0, 0, nullptr, // VTable params aren't used -+ llvmFlags, llvmSPFlags, TParams); -+ return wrap(Sub); -+} -+ - extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateBasicType( - LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen, - uint64_t SizeInBits, unsigned Encoding) { -diff --git a/tests/run-make/issue-109934-lto-debuginfo/Makefile b/tests/run-make/issue-109934-lto-debuginfo/Makefile -new file mode 100644 -index 0000000000000..3b7a99d3dbc62 ---- /dev/null -+++ b/tests/run-make/issue-109934-lto-debuginfo/Makefile -@@ -0,0 +1,12 @@ -+# ignore-cross-compile -+include ../tools.mk -+ -+# With the upgrade to LLVM 16, this was getting: -+# -+# error: Cannot represent a difference across sections -+# -+# The error stemmed from DI function definitions under type scopes, fixed by -+# only declaring in type scope and defining the subprogram elsewhere. -+ -+all: -+ $(RUSTC) lib.rs --test -C lto=fat -C debuginfo=2 -C incremental=$(TMPDIR)/inc-fat -diff --git a/tests/run-make/issue-109934-lto-debuginfo/lib.rs b/tests/run-make/issue-109934-lto-debuginfo/lib.rs -new file mode 100644 -index 0000000000000..c405928bd1824 ---- /dev/null -+++ b/tests/run-make/issue-109934-lto-debuginfo/lib.rs -@@ -0,0 +1,9 @@ -+extern crate alloc; -+ -+#[cfg(test)] -+mod tests { -+ #[test] -+ fn something_alloc() { -+ assert_eq!(Vec::::new(), Vec::::new()); -+ } -+} diff --git a/llvm-tools-install.patch b/llvm-tools-install.patch deleted file mode 100644 index 0e79433..0000000 --- a/llvm-tools-install.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 97740a648f57e24c45f641f2827598b26a2bf661 Mon Sep 17 00:00:00 2001 -From: NagaChaitanya Vellanki -Date: Fri, 17 Mar 2023 02:33:31 -0700 -Subject: [PATCH] Check for llvm-tools before install - ---- - src/bootstrap/install.rs | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs -index ac3843c3344eb..42d895a3413fb 100644 ---- a/src/bootstrap/install.rs -+++ b/src/bootstrap/install.rs -@@ -210,10 +210,13 @@ install!((self, builder, _config), - } - }; - LlvmTools, alias = "llvm-tools", Self::should_build(_config), only_hosts: true, { -- let tarball = builder -- .ensure(dist::LlvmTools { target: self.target }) -- .expect("missing llvm-tools"); -- install_sh(builder, "llvm-tools", self.compiler.stage, Some(self.target), &tarball); -+ if let Some(tarball) = builder.ensure(dist::LlvmTools { target: self.target }) { -+ install_sh(builder, "llvm-tools", self.compiler.stage, Some(self.target), &tarball); -+ } else { -+ builder.info( -+ &format!("skipping llvm-tools stage{} ({}): external LLVM", self.compiler.stage, self.target), -+ ); -+ } - }; - Rustfmt, alias = "rustfmt", Self::should_build(_config), only_hosts: true, { - if let Some(tarball) = builder.ensure(dist::Rustfmt { diff --git a/rust.spec b/rust.spec index d97bf50..9f3f17a 100644 --- a/rust.spec +++ b/rust.spec @@ -21,9 +21,9 @@ # To bootstrap from scratch, set the channel and date from src/stage0.json # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24 # or nightly wants some beta-YYYY-MM-DD -%define bootstrap_rust 1.68.2 +%define bootstrap_rust 1.69.0 %define bootstrap_cargo %{bootstrap_rust} -%define bootstrap_date 2023-03-28 +%define bootstrap_date 2023-04-20 %ifarch x32 %define with_cross 1 @@ -36,25 +36,23 @@ Summary: The Rust Programming Language Summary(pl.UTF-8): Język programowania Rust Name: rust -Version: 1.69.0 -Release: 3 +Version: 1.70.0 +Release: 1 # Licenses: (rust itself) and (bundled libraries) License: (Apache v2.0 or MIT) and (BSD and ISC and MIT) Group: Development/Languages Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz -# Source0-md5: 2fac6c46422e743f5f05287e89e72f22 +# Source0-md5: 165792a4266021589b2d6061f208755f Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz -# Source1-md5: b82ae74e630a849d6675b93ddf0ed6ca +# Source1-md5: f64b22de708c5a4e6ca2a0b549b9c438 Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz -# Source2-md5: a2affbb1e831228c71f972a270717ce3 +# Source2-md5: 0abd3a7776a84e4a631df506ba6b7b8a Source3: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz -# Source3-md5: 489073dd8a8380c28a570bf70c9fbd6e +# Source3-md5: 75bcdcf347a5195d1c20aa176734fb05 Source4: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz -# Source4-md5: bb43d3fca2893f2de0b892e0f4a8fdb3 +# Source4-md5: 58660f3595f67f0da91abaf209298588 Source5: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-armv7-unknown-linux-gnueabihf.tar.xz -# Source5-md5: 5691b194302d66b40c3e4eee0eeb1813 -Patch0: llvm-tools-install.patch -Patch1: 111167.patch +# Source5-md5: bf50136eba1bbaae5002f728efa637aa URL: https://www.rust-lang.org/ # for src/compiler-rt BuildRequires: cmake >= 3.4.3 @@ -333,8 +331,6 @@ Dopełnianie parametrów polecenia cargo w powłoce Zsh. %prep %setup -q -n %{rustc_package} -%patch0 -p1 -%patch1 -p1 %if %{with bootstrap} %ifarch %{x8664} x32 -- 2.44.0