Update to 1.70.0.

This commit is contained in:
Josh Stone 2023-07-18 16:04:11 -07:00
parent d2ebf73bdc
commit c1138bb6d1
12 changed files with 359 additions and 398 deletions

2
.gitignore vendored
View File

@ -6,3 +6,5 @@ SOURCES/wasi-libc-wasi-sdk-17.tar.gz
/wasi-libc-1dfe5c302d1c5ab621f7abf04620fae92700fd22.tar.gz
/rustc-1.68.2-src.tar.xz
/rustc-1.69.0-src.tar.xz
/rustc-1.70.0-src.tar.xz
/wasi-libc-wasi-sdk-20.tar.gz

View File

@ -0,0 +1,98 @@
From 23b3553ca0332dee4bdd79251b881d552e6bbafa Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Fri, 5 May 2023 17:27:59 -0700
Subject: [PATCH] Expand the LLVM coverage of `--print target-cpus`
We've been relying on a custom patch to add `MCSubtargetInfo::getCPUTable`
for `rustc --print target-cpus`, and just printing that it's not supported
on external LLVM builds. LLVM `main` now has `getAllProcessorDescriptions`
that can replace ours, so now we try to use that. In addition, the fallback
path can at least print the native and default cpu options.
There were also some mismatches in the function signatures here between
`LLVM_RUSTLLVM` and otherwise; this is now mitigated by sharing these
functions and only using cpp to adjust the function bodies.
(cherry picked from commit 67ae38a336599a7e0d2898a5ea3416b947458f5d)
---
.../rustc_llvm/llvm-wrapper/PassWrapper.cpp | 30 ++++++++++---------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
index b1503e6e4b87..a4827a57f5cf 100644
--- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
@@ -297,7 +297,6 @@ static Reloc::Model fromRust(LLVMRustRelocModel RustReloc) {
report_fatal_error("Bad RelocModel.");
}
-#ifdef LLVM_RUSTLLVM
/// getLongestEntryLength - Return the length of the longest entry in the table.
template<typename KV>
static size_t getLongestEntryLength(ArrayRef<KV> Table) {
@@ -312,11 +311,21 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* Tar
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
const Triple::ArchType HostArch = Triple(sys::getProcessTriple()).getArch();
const Triple::ArchType TargetArch = Target->getTargetTriple().getArch();
+
+#if LLVM_VERSION_GE(17, 0)
+ const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getAllProcessorDescriptions();
+#elif defined(LLVM_RUSTLLVM)
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
+#else
+ printf("Full target CPU help is not supported by this LLVM version.\n\n");
+ SubtargetSubTypeKV TargetCPUKV = { TargetCPU, {{}}, {{}} };
+ const ArrayRef<SubtargetSubTypeKV> CPUTable = TargetCPUKV;
+#endif
unsigned MaxCPULen = getLongestEntryLength(CPUTable);
printf("Available CPUs for this target:\n");
if (HostArch == TargetArch) {
+ MaxCPULen = std::max(MaxCPULen, (unsigned) std::strlen("native"));
const StringRef HostCPU = sys::getHostCPUName();
printf(" %-*s - Select the CPU of the current host (currently %.*s).\n",
MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
@@ -336,34 +345,27 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* Tar
}
extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) {
+#ifdef LLVM_RUSTLLVM
const TargetMachine *Target = unwrap(TM);
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
return FeatTable.size();
+#else
+ return 0;
+#endif
}
extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index,
const char** Feature, const char** Desc) {
+#ifdef LLVM_RUSTLLVM
const TargetMachine *Target = unwrap(TM);
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
const SubtargetFeatureKV Feat = FeatTable[Index];
*Feature = Feat.Key;
*Desc = Feat.Desc;
-}
-
-#else
-
-extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef) {
- printf("Target CPU help is not supported by this LLVM version.\n\n");
-}
-
-extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef) {
- return 0;
-}
-
-extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef, const char**, const char**) {}
#endif
+}
extern "C" const char* LLVMRustGetHostCPUName(size_t *len) {
StringRef Name = sys::getHostCPUName();
--
2.40.1

View File

@ -0,0 +1,53 @@
From 6e2adb05860b72610291d3b0e8bd525c44cb0cc9 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Fri, 9 Jun 2023 15:23:08 -0700
Subject: [PATCH] Let environment variables override some default CPUs
---
compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs | 2 +-
compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs | 2 +-
compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs
index fd896e086b54..08d0c43d20b4 100644
--- a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs
@@ -2,7 +2,7 @@
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
- base.cpu = "ppc64le".into();
+ base.cpu = option_env!("RUSTC_TARGET_CPU_PPC64LE").unwrap_or("ppc64le").into();
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
base.stack_probes = StackProbeType::Inline;
diff --git a/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs
index f2c722b9a89d..17a14d10b27e 100644
--- a/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs
@@ -5,7 +5,7 @@ pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.endian = Endian::Big;
// z10 is the oldest CPU supported by LLVM
- base.cpu = "z10".into();
+ base.cpu = option_env!("RUSTC_TARGET_CPU_S390X").unwrap_or("z10").into();
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
// also strip v128 from the data_layout below to match the older LLVM's expectation.
diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
index 9af1049b8702..68f876dd18c3 100644
--- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
@@ -2,7 +2,7 @@
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
- base.cpu = "x86-64".into();
+ base.cpu = option_env!("RUSTC_TARGET_CPU_X86_64").unwrap_or("x86-64").into();
base.max_atomic_width = Some(64);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.stack_probes = StackProbeType::X86;
--
2.40.1

View File

@ -0,0 +1,102 @@
From 6edbc665ea37ba3bf852b4eb42898b7d6e7b919c Mon Sep 17 00:00:00 2001
From: Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com>
Date: Fri, 5 May 2023 18:40:35 +0530
Subject: [PATCH] Rollup merge of #110876 - mj10021:issue-110647-fix, r=b-naber
Added default target cpu to `--print target-cpus` output and updated docs
Added default target cpu info as requested in issue #110647 and noted the new output in the documentation
(cherry picked from commit 65702bfd6bfb8616e182ddd19d0520ce7e35314a)
---
compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 2 +-
compiler/rustc_codegen_llvm/src/llvm_util.rs | 9 ++++++++-
.../rustc_llvm/llvm-wrapper/PassWrapper.cpp | 17 +++++++++++++----
src/doc/rustc/src/codegen-options/index.md | 3 ++-
4 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
index 05bbdbb7415c..383a9d2e5ddb 100644
--- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
@@ -2263,7 +2263,7 @@ pub fn LLVMRustDIBuilderCreateDebugLocation<'a>(
pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
- pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine);
+ pub fn LLVMRustPrintTargetCPUs(T: &TargetMachine, cpu: *const c_char);
pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
pub fn LLVMRustGetTargetFeature(
T: &TargetMachine,
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index 46692fd5e8bc..2fbdab9f8ce0 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -329,7 +329,14 @@ pub(crate) fn print(req: PrintRequest, sess: &Session) {
require_inited();
let tm = create_informational_target_machine(sess);
match req {
- PrintRequest::TargetCPUs => unsafe { llvm::LLVMRustPrintTargetCPUs(tm) },
+ PrintRequest::TargetCPUs => {
+ // SAFETY generate a C compatible string from a byte slice to pass
+ // the target CPU name into LLVM, the lifetime of the reference is
+ // at least as long as the C function
+ let cpu_cstring = CString::new(handle_native(sess.target.cpu.as_ref()))
+ .unwrap_or_else(|e| bug!("failed to convert to cstring: {}", e));
+ unsafe { llvm::LLVMRustPrintTargetCPUs(tm, cpu_cstring.as_ptr()) };
+ }
PrintRequest::TargetFeatures => print_target_features(sess, tm),
_ => bug!("rustc_codegen_llvm can't handle print request: {:?}", req),
}
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
index 08e38b0c9d59..b1503e6e4b87 100644
--- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
@@ -307,7 +307,7 @@ static size_t getLongestEntryLength(ArrayRef<KV> Table) {
return MaxLen;
}
-extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
+extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* TargetCPU) {
const TargetMachine *Target = unwrap(TM);
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
const Triple::ArchType HostArch = Triple(sys::getProcessTriple()).getArch();
@@ -321,9 +321,18 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
printf(" %-*s - Select the CPU of the current host (currently %.*s).\n",
MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
}
- for (auto &CPU : CPUTable)
- printf(" %-*s\n", MaxCPULen, CPU.Key);
- printf("\n");
+ for (auto &CPU : CPUTable) {
+ // Compare cpu against current target to label the default
+ if (strcmp(CPU.Key, TargetCPU) == 0) {
+ printf(" %-*s - This is the default target CPU"
+ " for the current build target (currently %s).",
+ MaxCPULen, CPU.Key, Target->getTargetTriple().str().c_str());
+ }
+ else {
+ printf(" %-*s", MaxCPULen, CPU.Key);
+ }
+ printf("\n");
+ }
}
extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) {
diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md
index 62347f169a5e..3a14f582d600 100644
--- a/src/doc/rustc/src/codegen-options/index.md
+++ b/src/doc/rustc/src/codegen-options/index.md
@@ -574,7 +574,8 @@ change in the future.
This instructs `rustc` to generate code specifically for a particular processor.
You can run `rustc --print target-cpus` to see the valid options to pass
-here. Each target has a default base CPU. Special values include:
+and the default target CPU for the current buid target.
+Each target has a default base CPU. Special values include:
* `native` can be passed to use the processor of the host machine.
* `generic` refers to an LLVM target with minimal features but modern tuning.
--
2.40.1

View File

@ -1,254 +0,0 @@
From 1476ebe761884e0cfc92f3f16809011663eb33f0 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
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<S
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(
@@ -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<MDTuple>(TParam));
+ DISubprogram::DISPFlags llvmSPFlags = fromRust(SPFlags);
+ DINode::DIFlags llvmFlags = fromRust(Flags);
+ DISubprogram *Sub = Builder->createMethod(
+ unwrapDI<DIScope>(Scope),
+ StringRef(Name, NameLen),
+ StringRef(LinkageName, LinkageNameLen),
+ unwrapDI<DIFile>(File), LineNo,
+ unwrapDI<DISubroutineType>(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::<u32>::new(), Vec::<u32>::new());
+ }
+}
--
2.40.1

102
rust.spec
View File

@ -8,9 +8,9 @@
# To bootstrap from scratch, set the channel and date from src/stage0.json
# e.g. 1.59.0 wants rustc: 1.58.0-2022-01-13
# or nightly wants some beta-YYYY-MM-DD
%global bootstrap_version 1.68.2
%global bootstrap_channel 1.68.2
%global bootstrap_date 2023-03-28
%global bootstrap_version 1.69.0
%global bootstrap_channel 1.69.0
%global bootstrap_date 2023-04-20
# Only the specified arches will use bootstrap binaries.
# NOTE: Those binaries used to be uploaded with every new release, but that was
@ -39,8 +39,7 @@
# src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh
# (updated per https://github.com/rust-lang/rust/pull/96907)
%global wasi_libc_url https://github.com/WebAssembly/wasi-libc
#global wasi_libc_ref wasi-sdk-20
%global wasi_libc_ref 1dfe5c302d1c5ab621f7abf04620fae92700fd22
%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}
@ -51,14 +50,14 @@
# We can also choose to just use Rust's bundled LLVM, in case the system LLVM
# is insufficient. Rust currently requires LLVM 14.0+.
%global min_llvm_version 14.0.0
%global bundled_llvm_version 15.0.7
%global bundled_llvm_version 16.0.2
%bcond_with bundled_llvm
# Requires stable libgit2 1.5, and not the next minor soname change.
# Requires stable libgit2 1.6, and not the next minor soname change.
# This needs to be consistent with the bindings in vendor/libgit2-sys.
%global min_libgit2_version 1.5.0
%global next_libgit2_version 1.6.0~
%global bundled_libgit2_version 1.5.0
%global min_libgit2_version 1.6.0
%global next_libgit2_version 1.7.0~
%global bundled_libgit2_version 1.6.3
%if 0%{?fedora} >= 38
%bcond_with bundled_libgit2
%else
@ -88,7 +87,7 @@
%endif
Name: rust
Version: 1.69.0
Version: 1.70.0
Release: 1%{?dist}
Summary: The Rust Programming Language
License: (ASL 2.0 or MIT) and (BSD and MIT)
@ -109,10 +108,19 @@ Source1: %{wasi_libc_source}
Patch1: 0001-Use-lld-provided-by-system-for-wasm.patch
# Set a substitute-path in rust-gdb for standard library sources.
Patch2: rustc-1.61.0-rust-gdb-substitute-path.patch
Patch2: rustc-1.70.0-rust-gdb-substitute-path.patch
# https://github.com/rust-lang/rust/pull/111167
Patch3: 0001-debuginfo-split-method-declaration-and-definition.patch
# Override default target CPUs to match distro settings
# TODO: upstream this ability into the actual build configuration
Patch3: 0001-Let-environment-variables-override-some-default-CPUs.patch
# Added default target cpu to `--print target-cpus` output
# https://github.com/rust-lang/rust/pull/110876
Patch4: 0001-Rollup-merge-of-110876-mj10021-issue-110647-fix-r-b-.patch
# Improve `--print target-cpus` for non-bundled LLVM
# https://github.com/rust-lang/rust/pull/111274
Patch5: 0001-Expand-the-LLVM-coverage-of-print-target-cpus.patch
### RHEL-specific patches below ###
@ -120,16 +128,11 @@ Patch3: 0001-debuginfo-split-method-declaration-and-definition.patch
Source100: macros.rust-toolset
# Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949)
Patch100: rustc-1.65.0-disable-libssh2.patch
Patch100: rustc-1.70.0-disable-libssh2.patch
# libcurl on RHEL7 doesn't have http2, but since cargo requests it, curl-sys
# will try to build it statically -- instead we turn off the feature.
Patch101: rustc-1.69.0-disable-http2.patch
# kernel rh1410097 causes too-small stacks for PIE.
# (affects RHEL6 kernels when building for RHEL7)
Patch102: rustc-1.65.0-no-default-pie.patch
Patch101: rustc-1.70.0-disable-http2.patch
# Get the Rust triple for any arch.
%{lua: function rust_triple(arch)
@ -589,6 +592,8 @@ test -f '%{local_rust_root}/bin/rustc'
%patch -P1 -p1
%patch -P2 -p1
%patch -P3 -p1
%patch -P4 -p1
%patch -P5 -p1
%if %with disabled_libssh2
%patch -P100 -p1
@ -596,11 +601,7 @@ test -f '%{local_rust_root}/bin/rustc'
%if %without curl_http2
%patch -P101 -p1
rm -rf vendor/libnghttp2-sys/
%endif
%if 0%{?rhel} && 0%{?rhel} < 8
%patch -P102 -p1
rm -rf vendor/libnghttp2-sys*/
%endif
# Use our explicit python3 first
@ -615,21 +616,21 @@ mkdir -p src/llvm-project/libunwind/
%endif
# Remove other unused vendored libraries
rm -rf vendor/curl-sys/curl/
rm -rf vendor/curl-sys*/curl/
rm -rf vendor/*jemalloc-sys*/jemalloc/
rm -rf vendor/libmimalloc-sys/c_src/mimalloc/
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/
rm -rf vendor/libffi-sys*/libffi/
rm -rf vendor/libmimalloc-sys*/c_src/mimalloc/
rm -rf vendor/libssh2-sys*/libssh2/
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/
rm -rf vendor/libgit2-sys*/libgit2/
%endif
%if %with disabled_libssh2
rm -rf vendor/libssh2-sys/
rm -rf vendor/libssh2-sys*/
%endif
# This only affects the transient rust-installer, but let it use our dynamic xz-libs
@ -665,24 +666,20 @@ find -name '*.rs' -type f -perm /111 -exec chmod -v -x '{}' '+'
%endif
# These are similar to __cflags_arch_* in /usr/lib/rpm/redhat/macros
%if 0%{?fedora} || 0%{?rhel} >= 9
%ifarch x86_64
%global rust_target_cpu %[0%{?rhel} >= 10 ? "x86-64-v3" : ""]
%global rust_target_cpu %[0%{?rhel} == 9 ? "x86-64-v2" : "%{rust_target_cpu}"]
%endif
%ifarch s390x
%global rust_target_cpu %[0%{?rhel} >= 9 ? "z14" : "zEC12"]
%endif
%ifarch ppc64le
%global rust_target_cpu %[0%{?rhel} >= 9 ? "pwr9" : "pwr8"]
%endif
%endif
%{lua: function rustc_target_cpus()
local fedora = tonumber(rpm.expand("0%{?fedora}"))
local rhel = tonumber(rpm.expand("0%{?rhel}"))
local env =
" RUSTC_TARGET_CPU_X86_64=x86-64" .. ((rhel >= 10) and "-v3" or (rhel == 9) and "-v2" or "")
.. " RUSTC_TARGET_CPU_PPC64LE=" .. ((rhel >= 9) and "pwr9" or "pwr8")
.. " RUSTC_TARGET_CPU_S390X=" ..
((rhel >= 9) and "z14" or (rhel == 8 or fedora >= 38) and "z13" or
(fedora >= 26) and "zEC12" or (rhel == 7) and "z196" or "z10")
return env
end}
# Set up shared environment variables for build/install/check
%global rust_env %{?rustflags:RUSTFLAGS="%{rustflags}"}
%if "%{?rust_target_cpu}" != ""
%global rust_env %{?rust_env} CARGO_TARGET_%{rust_triple_env}_RUSTFLAGS=-Ctarget-cpu=%{rust_target_cpu}
%endif
%global rust_env %{?rustflags:RUSTFLAGS="%{rustflags}"} %{lua: print(rustc_target_cpus())}
%if %defined cmake_path
%global rust_env %{?rust_env} PATH="%{cmake_path}:$PATH"
%endif
@ -1068,6 +1065,9 @@ end}
%changelog
* Tue Jul 18 2023 Josh Stone <jistone@redhat.com> - 1.70.0-1
- Update to 1.70.0.
* Fri May 26 2023 Josh Stone <jistone@redhat.com> - 1.69.0-1
- Update to 1.69.0.
- Obsolete rust-analysis.

View File

@ -1,18 +0,0 @@
--- 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
RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)"
GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
+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}"
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" \
"$@"

View File

@ -1,43 +0,0 @@
--- rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs.orig 2022-09-24 10:20:14.000000000 -0700
+++ rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs 2022-10-05 11:24:21.759564185 -0700
@@ -755,7 +755,7 @@
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie")
{
info!("linker output: {:?}", out);
- warn!("Linker does not support -no-pie command line option. Retrying without.");
+ info!("Linker does not support -no-pie command line option. Retrying without.");
for arg in cmd.take_args() {
if arg.to_string_lossy() != "-no-pie" {
cmd.arg(arg);
@@ -774,7 +774,7 @@
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-static-pie")
{
info!("linker output: {:?}", out);
- warn!(
+ info!(
"Linker does not support -static-pie command line option. Retrying with -static instead."
);
// Mirror `add_(pre,post)_link_objects` to replace CRT objects.
@@ -1520,15 +1520,15 @@
}
fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
- let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) {
+ // Only use PIE if explicitly specified.
+ #[allow(rustc::bad_opt_access)]
+ let explicit_pic =
+ matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic | RelocModel::Pie));
+ let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) {
(CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe,
- (CrateType::Executable, false, RelocModel::Pic | RelocModel::Pie) => {
- LinkOutputKind::DynamicPicExe
- }
+ (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe,
(CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe,
- (CrateType::Executable, true, RelocModel::Pic | RelocModel::Pie) => {
- LinkOutputKind::StaticPicExe
- }
+ (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe,
(CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe,
(_, true, _) => LinkOutputKind::StaticDylib,
(_, false, _) => LinkOutputKind::DynamicDylib,

View File

@ -1,6 +1,6 @@
--- rustc-beta-src/Cargo.lock.orig 2023-03-23 17:10:30.810989345 -0700
+++ rustc-beta-src/Cargo.lock 2023-03-23 17:10:30.812989303 -0700
@@ -1142,7 +1142,6 @@
--- rustc-beta-src/Cargo.lock.orig 2023-05-24 16:49:05.242510531 -0700
+++ rustc-beta-src/Cargo.lock 2023-05-24 16:51:11.741865603 -0700
@@ -1197,7 +1197,6 @@ checksum = "14d05c10f541ae6f3bc5b3d923c2
dependencies = [
"cc",
"libc",
@ -8,7 +8,7 @@
"libz-sys",
"openssl-sys",
"pkg-config",
@@ -2375,16 +2374,6 @@
@@ -2989,16 +2988,6 @@ source = "registry+https://github.com/ru
checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
[[package]]
@ -25,20 +25,20 @@
name = "libz-sys"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
--- rustc-beta-src/src/tools/cargo/Cargo.toml.orig 2023-03-23 17:10:30.812989303 -0700
+++ rustc-beta-src/src/tools/cargo/Cargo.toml 2023-03-23 17:11:26.242836664 -0700
@@ -23,7 +23,7 @@
cargo-util = { path = "crates/cargo-util", version = "0.2.3" }
clap = "4.1.3"
--- rustc-beta-src/src/tools/cargo/Cargo.toml.orig 2023-05-24 16:49:05.244510489 -0700
+++ rustc-beta-src/src/tools/cargo/Cargo.toml 2023-05-24 16:51:04.683013189 -0700
@@ -23,7 +23,7 @@ cargo-platform = { path = "crates/cargo-
cargo-util = { path = "crates/cargo-util", version = "0.2.4" }
clap = "4.2.0"
crates-io = { path = "crates/crates-io", version = "0.36.0" }
-curl = { version = "0.4.44", features = ["http2"] }
+curl = { version = "0.4.44", features = [] }
curl-sys = "0.4.59"
curl-sys = "0.4.61"
env_logger = "0.10.0"
filetime = "0.2.9"
--- rustc-beta-src/src/tools/cargo/src/cargo/core/package.rs.orig 2023-03-19 00:20:55.000000000 -0700
+++ rustc-beta-src/src/tools/cargo/src/cargo/core/package.rs 2023-03-23 17:10:30.812989303 -0700
@@ -401,16 +401,9 @@
--- rustc-beta-src/src/tools/cargo/src/cargo/core/package.rs.orig 2023-05-19 19:05:42.000000000 -0700
+++ rustc-beta-src/src/tools/cargo/src/cargo/core/package.rs 2023-05-24 16:49:05.244510489 -0700
@@ -407,16 +407,9 @@ impl<'cfg> PackageSet<'cfg> {
sources: SourceMap<'cfg>,
config: &'cfg Config,
) -> CargoResult<PackageSet<'cfg>> {
@ -58,9 +58,9 @@
Ok(PackageSet {
packages: package_ids
--- rustc-beta-src/src/tools/cargo/src/cargo/sources/registry/http_remote.rs.orig 2023-03-19 00:20:55.000000000 -0700
+++ rustc-beta-src/src/tools/cargo/src/cargo/sources/registry/http_remote.rs 2023-03-23 17:10:30.813989282 -0700
@@ -220,16 +220,8 @@
--- rustc-beta-src/src/tools/cargo/src/cargo/sources/registry/http_remote.rs.orig 2023-05-24 16:49:05.245510468 -0700
+++ rustc-beta-src/src/tools/cargo/src/cargo/sources/registry/http_remote.rs 2023-05-24 16:51:57.916900146 -0700
@@ -229,16 +229,8 @@ impl<'cfg> HttpRegistry<'cfg> {
}
self.fetch_started = true;
@ -77,11 +77,11 @@
+ // Multiplexing is disabled because the system libcurl doesn't support it.
+ self.multiplexing = false;
self.config
.shell()
--- rustc-beta-src/src/tools/cargo/src/cargo/util/network.rs.orig 2023-03-19 00:20:55.000000000 -0700
+++ rustc-beta-src/src/tools/cargo/src/cargo/util/network.rs 2023-03-23 17:10:30.813989282 -0700
@@ -116,7 +116,7 @@
if !self.quiet {
self.config
--- rustc-beta-src/src/tools/cargo/src/cargo/util/network/mod.rs.orig 2023-05-19 19:05:42.000000000 -0700
+++ rustc-beta-src/src/tools/cargo/src/cargo/util/network/mod.rs 2023-05-24 16:49:05.245510468 -0700
@@ -25,7 +25,7 @@ impl<T> PollExt<T> for Poll<T> {
macro_rules! try_old_curl {
($e:expr, $msg:expr) => {
let result = $e;

View File

@ -1,6 +1,6 @@
--- rustc-beta-src/Cargo.lock.orig 2022-09-24 10:20:14.000000000 -0700
+++ rustc-beta-src/Cargo.lock 2022-10-04 10:26:35.490270607 -0700
@@ -1971,7 +1971,6 @@
--- rustc-beta-src/Cargo.lock.orig 2023-05-19 19:02:31.000000000 -0700
+++ rustc-beta-src/Cargo.lock 2023-05-24 16:36:33.312232441 -0700
@@ -2967,7 +2967,6 @@
dependencies = [
"cc",
"libc",
@ -8,14 +8,14 @@
"libz-sys",
"openssl-sys",
"pkg-config",
@@ -2004,20 +2003,6 @@
@@ -3000,20 +2999,6 @@
]
[[package]]
-name = "libssh2-sys"
-version = "0.2.23"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca"
-checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee"
-dependencies = [
- "cc",
- "libc",
@ -29,9 +29,9 @@
name = "libz-sys"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
--- rustc-beta-src/vendor/git2/Cargo.toml.orig 2022-10-04 10:26:35.490270607 -0700
+++ rustc-beta-src/vendor/git2/Cargo.toml 2022-10-04 10:28:14.002187686 -0700
@@ -58,9 +58,7 @@
--- rustc-beta-src/vendor/git2/Cargo.toml.orig 2023-05-19 21:16:57.000000000 -0700
+++ rustc-beta-src/vendor/git2/Cargo.toml 2023-05-24 16:33:42.043813439 -0700
@@ -55,9 +55,7 @@
[features]
default = [

View File

@ -0,0 +1,21 @@
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')"
# Run GDB with the additional arguments that load the pretty printers
# Set the environment variable `RUST_GDB` to overwrite the call to a
@@ -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 /rustc/$RUSTC_COMMIT_HASH $RUSTC_SYSROOT/lib/rustlib/src/rust" \
+ -iex "set substitute-path @BUILDDIR@ $RUSTC_SYSROOT/lib/rustlib/src/rust" \
"$@"

View File

@ -1,2 +1,2 @@
SHA512 (rustc-1.69.0-src.tar.xz) = 724398fc208ec18adbd8ba81a445e23d1001b746990f36b869126be8a45f1cdfa75f5b9cbdd0abbab506f91a56d3736ab247677699ebd69525245558cfc01a60
SHA512 (wasi-libc-1dfe5c302d1c5ab621f7abf04620fae92700fd22.tar.gz) = 6f813bc7822746c161932de6b84fb965111400a1a38c25dd0981209d588b9ccafe1a5923349110c536f1b7cda707dfa2d0be42c92b2fa6fd89c957eda27bda27
SHA512 (rustc-1.70.0-src.tar.xz) = 21b35185fdcc35a059ee5ef6dca2b68f5f1d199e97f425a571cfc318a852c36a57bccf68e7673b4cb7cd83128f30d0b3eb93009a978f3ba3909b7eee50d40631
SHA512 (wasi-libc-wasi-sdk-20.tar.gz) = e264240dc7dbcf6398c8ca09bc108298f4a8aa955af22de5a3015fbcde81cb09dd83cd48349090082d5de0e8a3dbcf746c7b14657c67657b3f2f1ab28bb9cf05