diff --git a/0005-debuginfo-split-method-declaration-and-definition.patch b/0005-debuginfo-split-method-declaration-and-definition.patch deleted file mode 100644 index 03a4937c576805fe71eac0a3ee84c5516895d6f7..0000000000000000000000000000000000000000 --- a/0005-debuginfo-split-method-declaration-and-definition.patch +++ /dev/null @@ -1,254 +0,0 @@ -From 1476ebe761884e0cfc92f3f16809011663eb33f0 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. - -(cherry picked from commit 10b69dde3fd15334ea2382d2dc9e9a261de1afaf) ---- - .../rustc_codegen_llvm/src/debuginfo/mod.rs | 86 +++++++++++-------- - 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, 110 insertions(+), 34 deletions(-) - create mode 100644 tests/run-make-fulldeps/issue-109934-lto-debuginfo/Makefile - create mode 100644 tests/run-make-fulldeps/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 5392534cfcb7..11426b150b6c 100644 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs -@@ -322,7 +322,7 @@ fn dbg_scope_fn( - 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 @@ fn dbg_scope_fn( - } - } - -- 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 @@ fn dbg_scope_fn( - spflags, - maybe_definition_llfn, - template_parameters, -- None, -- ); -- } -+ decl, -+ ) -+ }; - - fn get_function_signature<'ll, 'tcx>( - cx: &CodegenCx<'ll, 'tcx>, -@@ -495,14 +516,16 @@ fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec( - 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( -@@ -513,39 +536,34 @@ fn get_containing_scope<'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 253c2ca7c768..9dd6db1929fc 100644 ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -1968,6 +1968,21 @@ pub fn LLVMRustDIBuilderCreateFunction<'a>( - 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 e3493caaaf74..c4a97af1f0f4 100644 ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -841,6 +841,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-fulldeps/issue-109934-lto-debuginfo/Makefile b/tests/run-make-fulldeps/issue-109934-lto-debuginfo/Makefile -new file mode 100644 -index 000000000000..3b7a99d3dbc6 ---- /dev/null -+++ b/tests/run-make-fulldeps/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-fulldeps/issue-109934-lto-debuginfo/lib.rs b/tests/run-make-fulldeps/issue-109934-lto-debuginfo/lib.rs -new file mode 100644 -index 000000000000..c405928bd182 ---- /dev/null -+++ b/tests/run-make-fulldeps/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()); -+ } -+} --- -2.40.1 - diff --git a/rust.spec b/rust.spec index c02956c4552b6bc37661065358cf02a95b9d3da1..7c457c60d3c37bab67675d51ff64518021b14994 100644 --- a/rust.spec +++ b/rust.spec @@ -1,8 +1,8 @@ -%define anolis_release 4 +%define anolis_release 1 %global rust_arches x86_64 aarch64 loongarch64 %global channel stable -%global bootstrap_version 1.68.2 -%global bootstrap_date 2023-03-28 +%global bootstrap_version 1.69.0 +%global bootstrap_date 2023-04-20 %global __ranlib %{_bindir}/ranlib %global _privatelibs lib(.*-[[:xdigit:]]{16}*|rustc.*)[.]so.* %global __provides_exclude ^(%{_privatelibs})$ @@ -21,20 +21,23 @@ %global wasm_targets wasm32-unknown-unknown wasm32-wasi %endif -%global wasi_libc_source wasi-libc-1dfe5c302d1c5ab621f7abf04620fae92700fd22 -%global wasi_libc_dir %{_builddir}/%{wasi_libc_source} +%global wasi_libc_url https://github.com/WebAssembly/wasi-libc +%global wasi_libc_ref wasi-sdk-20 +%global wasi_libc_name wasi-libc-%{wasi_libc_ref} +%global wasi_libc_source %{wasi_libc_url}/archive/%{wasi_libc_ref}/%{wasi_libc_name}.tar.gz +%global wasi_libc_dir %{_builddir}/%{wasi_libc_name} %bcond_with bootstrap %bcond_with static %bcond_with cmake_path -%bcond_without bundled_libgit2 +%bcond_with bundled_libgit2 %bcond_without curl_http2 %bcond_without lldb %bcond_without debug %bcond_without libssh2 -%global ligbit2_version 1.5.0 -%global next_ligbit2_version 1.6.0~ +%global ligbit2_version 1.6.0 +%global next_ligbit2_version 1.7.0~ %global libssh2_version 1.6.0 %if %{without bootstrap} @@ -42,14 +45,14 @@ %endif Name: rust -Version: 1.69.0 +Version: 1.70.0 Release: %{anolis_release}%{?dist} Summary: The Rust 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-%{version}-src.tar.xz -Source1: https://github.com/WebAssembly/wasi-libc/archive/wasi-sdk-19/%{wasi_libc_source}.tar.gz +Source1: %{wasi_libc_source} Source100: macros.rust-toolset Source101: cargo-config Source102: cargo-config.sh @@ -57,10 +60,9 @@ Source103: cargo-config.csh Source104: bootstrap Patch0001: 0001-Use-lld-provided-by-system-for-wasm.patch -Patch0002: 0002-rustc-1.61.0-rust-gdb-substitute-path.patch +Patch0002: rustc-1.70.0-rust-gdb-substitute-path.patch Patch0003: 0003-rustc-1.65.0-disable-libssh2.patch Patch0004: 0004-rustc-1.69.0-disable-http2.patch -Patch0005: 0005-debuginfo-split-method-declaration-and-definition.patch Patch0006: 0001-vendor-linux-raw-sys-0.1.3.patch Patch0007: 0002-vendor-linux-raw-sys-0.1.4.patch Patch0008: 0003-vendor-cc-1.0.79.patch @@ -278,13 +280,12 @@ test -f '%{local_rust_root}/bin/rustc' %endif %if %{with wasm} -%setup -q -n %{wasi_libc_source} -T -b 1 +%setup -q -n %{wasi_libc_name} -T -b 1 %endif %setup -q -n rustc-%{version}-src %patch -P0001 -p1 %patch -P0002 -p1 -%patch -P0005 -p1 %if %{without libssh2} %patch -P0003 -p1 @@ -295,13 +296,6 @@ test -f '%{local_rust_root}/bin/rustc' rm -rf vendor/libnghttp2-sys/ %endif -%patch -P0006 -p1 -%patch -P0007 -p1 -%patch -P0008 -p1 -%patch -P0009 -p1 -%patch -P0010 -p1 -%patch -P0011 -p1 - sed -i.try-python -e '/^try python3 /i try "%{__python3}" "$@"' ./configure sed -i.rust-src -e "s#@BUILDDIR@#$PWD#" ./src/etc/rust-gdb @@ -586,6 +580,9 @@ done %doc src/tools/rust-analyzer/README.md %changelog +* Thu Oct 26 2023 Funda Wang - 1.70.0-1 +- New version 1.70.0 + * Thu Oct 26 2023 Funda Wang - 1.69.0-4 - Try building with bundled libgit2 for upgrading diff --git a/0002-rustc-1.61.0-rust-gdb-substitute-path.patch b/rustc-1.70.0-rust-gdb-substitute-path.patch similarity index 44% rename from 0002-rustc-1.61.0-rust-gdb-substitute-path.patch rename to rustc-1.70.0-rust-gdb-substitute-path.patch index b94e23ec779439692d48ae499549b46c7b11ab56..e9e5e2e14e78c07ef13c9fa44ea5730e998a334f 100644 --- a/0002-rustc-1.61.0-rust-gdb-substitute-path.patch +++ b/rustc-1.70.0-rust-gdb-substitute-path.patch @@ -1,18 +1,21 @@ ---- rustc-1.61.0-src/src/etc/rust-gdb.orig 2022-05-17 18:29:36.000000000 -0700 -+++ rustc-1.61.0-src/src/etc/rust-gdb 2022-05-18 11:18:13.732709661 -0700 -@@ -14,6 +14,9 @@ fi +diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb +index 9abed30ea6f7..e4bf55df3688 100755 +--- a/src/etc/rust-gdb ++++ b/src/etc/rust-gdb +@@ -13,8 +13,6 @@ fi + # Find out where the pretty printer Python module is RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)" GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc" +-# Get the commit hash for path remapping +-RUSTC_COMMIT_HASH="$("$RUSTC" -vV | sed -n 's/commit-hash: \([a-zA-Z0-9_]*\)/\1/p')" -+RUST_STD_BUILD="@BUILDDIR@/library/" -+RUST_STD_SRC="$RUSTC_SYSROOT/lib/rustlib/src/rust/library/" -+ # Run GDB with the additional arguments that load the pretty printers # Set the environment variable `RUST_GDB` to overwrite the call to a - # different/specific command (defaults to `gdb`). -@@ -21,4 +24,5 @@ RUST_GDB="${RUST_GDB:-gdb}" +@@ -23,6 +21,6 @@ RUST_GDB="${RUST_GDB:-gdb}" PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" exec ${RUST_GDB} \ --directory="$GDB_PYTHON_MODULE_DIRECTORY" \ -iex "add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY" \ -+ -iex "set substitute-path $RUST_STD_BUILD $RUST_STD_SRC" \ +- -iex "set substitute-path /rustc/$RUSTC_COMMIT_HASH $RUSTC_SYSROOT/lib/rustlib/src/rust" \ ++ -iex "set substitute-path @BUILDDIR@ $RUSTC_SYSROOT/lib/rustlib/src/rust" \ "$@" + diff --git a/rustc-1.69.0-src.tar.xz b/rustc-1.70.0-src.tar.xz similarity index 82% rename from rustc-1.69.0-src.tar.xz rename to rustc-1.70.0-src.tar.xz index db6d9e32cf0a293e199f4b8502ea254878b06394..38ee30b2b0d8ce3b9501940b76101ad06b4b31bf 100644 Binary files a/rustc-1.69.0-src.tar.xz and b/rustc-1.70.0-src.tar.xz differ diff --git a/wasi-libc-1dfe5c302d1c5ab621f7abf04620fae92700fd22.tar.gz b/wasi-libc-1dfe5c302d1c5ab621f7abf04620fae92700fd22.tar.gz deleted file mode 100644 index 6b8cab08c7be93a5940fce76052c42d31ffda101..0000000000000000000000000000000000000000 Binary files a/wasi-libc-1dfe5c302d1c5ab621f7abf04620fae92700fd22.tar.gz and /dev/null differ diff --git a/wasi-libc-wasi-sdk-20.tar.gz b/wasi-libc-wasi-sdk-20.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..2b610eaa2259673607592c6426989c346b018d60 Binary files /dev/null and b/wasi-libc-wasi-sdk-20.tar.gz differ