Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to LLVM 17 #114048

Merged
merged 8 commits into from Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Expand Up @@ -33,7 +33,7 @@
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/16.0-2023-06-05
branch = rustc/17.0-2023-07-29
shallow = true
[submodule "src/doc/embedded-book"]
path = src/doc/embedded-book
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_codegen_llvm/src/context.rs
Expand Up @@ -145,6 +145,17 @@ pub unsafe fn create_module<'ll>(
target_data_layout = target_data_layout.replace("-n32:64-", "-n64-");
}
}
if llvm_version < (17, 0, 0) {
if sess.target.arch.starts_with("powerpc") {
// LLVM 17 specifies function pointer alignment for ppc:
// https://reviews.llvm.org/D147016
target_data_layout = target_data_layout
.replace("-Fn32", "")
.replace("-Fi32", "")
.replace("-Fn64", "")
.replace("-Fi64", "");
}
}

// Ensure the data-layout values hardcoded remain the defaults.
if sess.target.is_builtin {
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Expand Up @@ -322,8 +322,6 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,

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

// Not 100% sure what these are, but they impact what's internalized and
// what's inlined across modules, I believe.
#if LLVM_VERSION_GE(17, 0)
#if LLVM_VERSION_GE(18, 0)
DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists;
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists;
DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc64_ibm_aix.rs
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-ibm-aix".into(),
pointer_width: 64,
data_layout: "E-m:a-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: base,
}
Expand Down
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-freebsd".into(),
pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64".into(),
data_layout: "E-m:e-Fn32-i64:64-n32:64".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-linux-gnu".into(),
pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-linux-musl".into(),
pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-openbsd".into(),
pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64".into(),
data_layout: "E-m:e-Fn32-i64:64-n32:64".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-linux-gnu".into(),
pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, ..base },
}
Expand Down
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64le-unknown-freebsd".into(),
pointer_width: 64,
data_layout: "e-m:e-i64:64-n32:64".into(),
data_layout: "e-m:e-Fn32-i64:64-n32:64".into(),
arch: "powerpc64".into(),
options: TargetOptions { mcount: "_mcount".into(), ..base },
}
Expand Down
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64le-unknown-linux-gnu".into(),
pointer_width: 64,
data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { mcount: "_mcount".into(), ..base },
}
Expand Down
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64le-unknown-linux-musl".into(),
pointer_width: 64,
data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { mcount: "_mcount".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs
Expand Up @@ -14,7 +14,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-freebsd13.0".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions {
endian: Endian::Big,
Expand Down
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-gnu".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-gnuspe".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions {
abi: "spe".into(),
Expand Down
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-musl".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-netbsd".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-openbsd".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: base,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-gnu".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions { endian: Endian::Big, features: "+secure-plt".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-gnuspe".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions {
abi: "spe".into(),
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/llvm.rs
Expand Up @@ -1159,8 +1159,8 @@ impl Step for CrtBeginEnd {
return out_dir;
}

let crtbegin_src = builder.src.join("src/llvm-project/compiler-rt/lib/crt/crtbegin.c");
let crtend_src = builder.src.join("src/llvm-project/compiler-rt/lib/crt/crtend.c");
let crtbegin_src = builder.src.join("src/llvm-project/compiler-rt/lib/builtins/crtbegin.c");
let crtend_src = builder.src.join("src/llvm-project/compiler-rt/lib/builtins/crtend.c");
if up_to_date(&crtbegin_src, &out_dir.join("crtbegin.o"))
&& up_to_date(&crtend_src, &out_dir.join("crtendS.o"))
{
Expand Down
Expand Up @@ -10,7 +10,7 @@ CT_ARCH_64=y
CT_ARCH_ARCH="rv64gc"
CT_KERNEL_LINUX=y
CT_LINUX_V_4_20=y
CT_BINUTILS_V_2_32=y
CT_BINUTILS_V_2_36=y
CT_GLIBC_V_2_29=y
CT_GCC_V_8=y
CT_CC_LANG_CXX=y
4 changes: 2 additions & 2 deletions src/ci/docker/host-x86_64/dist-various-2/Dockerfile
Expand Up @@ -135,8 +135,8 @@ ENV TARGETS=$TARGETS,x86_64-unknown-uefi
# As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211
# we need asm in the search path for gcc-9 (for gnux32) but not in the search path of the
# cross compilers.
# Luckily one of the folders is /usr/local/include so symlink /usr/include/asm-generic there
RUN ln -s /usr/include/asm-generic /usr/local/include/asm
# Luckily one of the folders is /usr/local/include so symlink /usr/include/x86_64-linux-gnu/asm there
RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/include/asm

ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 36027 files
2 changes: 2 additions & 0 deletions tests/ui/abi/stack-protector.rs
Expand Up @@ -40,6 +40,8 @@ fn vulnerable_function() {
// Overwrite the on-stack return address with the address of `malicious_code()`,
// thereby jumping to that function when returning from `vulnerable_function()`.
unsafe { fill(stackaddr, bad_code_ptr, 20); }
// Capture the address, so the write is not optimized away.
std::hint::black_box(stackaddr);
}

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