Skip to content

Commit 443c316

Browse files
committed
Auto merge of rust-lang#114048 - nikic:llvm-17, r=cuviper
Update to LLVM 17 Expected LLVM 17.0.0 release date: Sep 5th Rust 1.73 release date: Oct 5th Compatibility changes in this PR: - Drop LLVM_RUSTLLVM check for target-cpu table, which no longer requires a patch with LLVM 17. - Update powerpc data layouts, which now include function alignment information. As usual, downgrade for older LLVM versions. - Adjust the stack-protector.rs test so that the stack smashing does not get optimized away. - Adjust path of crtbegin.c and crtend.c in compiler-rt. - Updated dist-riscv64-linux to use binutils 2.36 in order to recognize the zicsr feature, which is no longer part of the base ISA. - Fixed symlink for asm include directory on dist-various-2. We should use `/usr/include/x86_64-linux-gnu/asm` for the host, rather than `/usr/include/asm-generic`. Upstream patches: - [x] https://reviews.llvm.org/D156525 (backported) Perf run: https://perf.rust-lang.org/compare.html?start=f239bb6bea94d16d902c36d72b5cabdddefb3cab&end=8030d71a95a3ea79f5fc95232c32f9b78effb92d&stat=instructions:u Fixes rust-lang#109671. Successful: dist-x86_64-linux, dist-aarch64-linux, dist-s390x-linux, dist-powerpc-linux, armhf-gnu, wasm32
2 parents 03a119b + 7867833 commit 443c316

25 files changed

+38
-27
lines changed

Diff for: .gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
[submodule "src/llvm-project"]
3434
path = src/llvm-project
3535
url = https://github.com/rust-lang/llvm-project.git
36-
branch = rustc/16.0-2023-06-05
36+
branch = rustc/17.0-2023-07-29
3737
shallow = true
3838
[submodule "src/doc/embedded-book"]
3939
path = src/doc/embedded-book

Diff for: compiler/rustc_codegen_llvm/src/context.rs

+11
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ pub unsafe fn create_module<'ll>(
145145
target_data_layout = target_data_layout.replace("-n32:64-", "-n64-");
146146
}
147147
}
148+
if llvm_version < (17, 0, 0) {
149+
if sess.target.arch.starts_with("powerpc") {
150+
// LLVM 17 specifies function pointer alignment for ppc:
151+
// https://reviews.llvm.org/D147016
152+
target_data_layout = target_data_layout
153+
.replace("-Fn32", "")
154+
.replace("-Fi32", "")
155+
.replace("-Fn64", "")
156+
.replace("-Fi64", "");
157+
}
158+
}
148159

149160
// Ensure the data-layout values hardcoded remain the defaults.
150161
if sess.target.is_builtin {

Diff for: compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,6 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
322322

323323
#if LLVM_VERSION_GE(17, 0)
324324
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getAllProcessorDescriptions();
325-
#elif defined(LLVM_RUSTLLVM)
326-
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
327325
#else
328326
Buf << "Full target CPU help is not supported by this LLVM version.\n\n";
329327
SubtargetSubTypeKV TargetCPUKV = { TargetCPU, {{}}, {{}} };
@@ -1120,7 +1118,7 @@ struct LLVMRustThinLTOData {
11201118

11211119
// Not 100% sure what these are, but they impact what's internalized and
11221120
// what's inlined across modules, I believe.
1123-
#if LLVM_VERSION_GE(17, 0)
1121+
#if LLVM_VERSION_GE(18, 0)
11241122
DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists;
11251123
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists;
11261124
DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries;

Diff for: compiler/rustc_target/src/spec/powerpc64_ibm_aix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
Target {
1212
llvm_target: "powerpc64-ibm-aix".into(),
1313
pointer_width: 64,
14-
data_layout: "E-m:a-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
14+
data_layout: "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
1515
arch: "powerpc64".into(),
1616
options: base,
1717
}

Diff for: compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
Target {
1212
llvm_target: "powerpc64-unknown-freebsd".into(),
1313
pointer_width: 64,
14-
data_layout: "E-m:e-i64:64-n32:64".into(),
14+
data_layout: "E-m:e-Fn32-i64:64-n32:64".into(),
1515
arch: "powerpc64".into(),
1616
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
1717
}

Diff for: compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
Target {
1212
llvm_target: "powerpc64-unknown-linux-gnu".into(),
1313
pointer_width: 64,
14-
data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
14+
data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
1515
arch: "powerpc64".into(),
1616
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
1717
}

Diff for: compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
Target {
1212
llvm_target: "powerpc64-unknown-linux-musl".into(),
1313
pointer_width: 64,
14-
data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
14+
data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
1515
arch: "powerpc64".into(),
1616
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
1717
}

Diff for: compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
Target {
1212
llvm_target: "powerpc64-unknown-openbsd".into(),
1313
pointer_width: 64,
14-
data_layout: "E-m:e-i64:64-n32:64".into(),
14+
data_layout: "E-m:e-Fn32-i64:64-n32:64".into(),
1515
arch: "powerpc64".into(),
1616
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
1717
}

Diff for: compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
Target {
1212
llvm_target: "powerpc64-unknown-linux-gnu".into(),
1313
pointer_width: 64,
14-
data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
14+
data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
1515
arch: "powerpc64".into(),
1616
options: TargetOptions { endian: Endian::Big, ..base },
1717
}

Diff for: compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc64le-unknown-freebsd".into(),
1212
pointer_width: 64,
13-
data_layout: "e-m:e-i64:64-n32:64".into(),
13+
data_layout: "e-m:e-Fn32-i64:64-n32:64".into(),
1414
arch: "powerpc64".into(),
1515
options: TargetOptions { mcount: "_mcount".into(), ..base },
1616
}

Diff for: compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc64le-unknown-linux-gnu".into(),
1212
pointer_width: 64,
13-
data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
13+
data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
1414
arch: "powerpc64".into(),
1515
options: TargetOptions { mcount: "_mcount".into(), ..base },
1616
}

Diff for: compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc64le-unknown-linux-musl".into(),
1212
pointer_width: 64,
13-
data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
13+
data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
1414
arch: "powerpc64".into(),
1515
options: TargetOptions { mcount: "_mcount".into(), ..base },
1616
}

Diff for: compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn target() -> Target {
1414
Target {
1515
llvm_target: "powerpc-unknown-freebsd13.0".into(),
1616
pointer_width: 32,
17-
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
17+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
1818
arch: "powerpc".into(),
1919
options: TargetOptions {
2020
endian: Endian::Big,

Diff for: compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc-unknown-linux-gnu".into(),
1212
pointer_width: 32,
13-
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
13+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
1414
arch: "powerpc".into(),
1515
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
1616
}

Diff for: compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc-unknown-linux-gnuspe".into(),
1212
pointer_width: 32,
13-
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
13+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
1414
arch: "powerpc".into(),
1515
options: TargetOptions {
1616
abi: "spe".into(),

Diff for: compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc-unknown-linux-musl".into(),
1212
pointer_width: 32,
13-
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
13+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
1414
arch: "powerpc".into(),
1515
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
1616
}

Diff for: compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc-unknown-netbsd".into(),
1212
pointer_width: 32,
13-
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
13+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
1414
arch: "powerpc".into(),
1515
options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base },
1616
}

Diff for: compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc-unknown-openbsd".into(),
1212
pointer_width: 32,
13-
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
13+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
1414
arch: "powerpc".into(),
1515
options: base,
1616
}

Diff for: compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc-unknown-linux-gnu".into(),
1212
pointer_width: 32,
13-
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
13+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
1414
arch: "powerpc".into(),
1515
options: TargetOptions { endian: Endian::Big, features: "+secure-plt".into(), ..base },
1616
}

Diff for: compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn target() -> Target {
1010
Target {
1111
llvm_target: "powerpc-unknown-linux-gnuspe".into(),
1212
pointer_width: 32,
13-
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
13+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
1414
arch: "powerpc".into(),
1515
options: TargetOptions {
1616
abi: "spe".into(),

Diff for: src/bootstrap/llvm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,8 @@ impl Step for CrtBeginEnd {
11591159
return out_dir;
11601160
}
11611161

1162-
let crtbegin_src = builder.src.join("src/llvm-project/compiler-rt/lib/crt/crtbegin.c");
1163-
let crtend_src = builder.src.join("src/llvm-project/compiler-rt/lib/crt/crtend.c");
1162+
let crtbegin_src = builder.src.join("src/llvm-project/compiler-rt/lib/builtins/crtbegin.c");
1163+
let crtend_src = builder.src.join("src/llvm-project/compiler-rt/lib/builtins/crtend.c");
11641164
if up_to_date(&crtbegin_src, &out_dir.join("crtbegin.o"))
11651165
&& up_to_date(&crtend_src, &out_dir.join("crtendS.o"))
11661166
{

Diff for: src/ci/docker/host-x86_64/dist-riscv64-linux/riscv64-unknown-linux-gnu.defconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CT_ARCH_64=y
1010
CT_ARCH_ARCH="rv64gc"
1111
CT_KERNEL_LINUX=y
1212
CT_LINUX_V_4_20=y
13-
CT_BINUTILS_V_2_32=y
13+
CT_BINUTILS_V_2_36=y
1414
CT_GLIBC_V_2_29=y
1515
CT_GCC_V_8=y
1616
CT_CC_LANG_CXX=y

Diff for: src/ci/docker/host-x86_64/dist-various-2/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ ENV TARGETS=$TARGETS,x86_64-unknown-uefi
135135
# As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211
136136
# we need asm in the search path for gcc-9 (for gnux32) but not in the search path of the
137137
# cross compilers.
138-
# Luckily one of the folders is /usr/local/include so symlink /usr/include/asm-generic there
139-
RUN ln -s /usr/include/asm-generic /usr/local/include/asm
138+
# Luckily one of the folders is /usr/local/include so symlink /usr/include/x86_64-linux-gnu/asm there
139+
RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/include/asm
140140

141141
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
142142
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \

Diff for: src/llvm-project

Diff for: tests/ui/abi/stack-protector.rs

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ fn vulnerable_function() {
4040
// Overwrite the on-stack return address with the address of `malicious_code()`,
4141
// thereby jumping to that function when returning from `vulnerable_function()`.
4242
unsafe { fill(stackaddr, bad_code_ptr, 20); }
43+
// Capture the address, so the write is not optimized away.
44+
std::hint::black_box(stackaddr);
4345
}
4446

4547
// Use an uninlined function with its own stack frame to make sure that we don't

0 commit comments

Comments
 (0)