Skip to content

Commit

Permalink
Rollup merge of rust-lang#122649 - cuviper:min-llvm-17, r=nikic
Browse files Browse the repository at this point in the history
Update the minimum external LLVM to 17

With this change, we'll have stable support for LLVM 17 and 18.
For reference, the previous increase to LLVM 16 was rust-lang#117947.
  • Loading branch information
matthiaskrgr committed Mar 18, 2024
2 parents 97ae027 + d9132de commit 414debe
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 170 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: mingw-check-tidy
os: ubuntu-20.04-4core-16gb
env: {}
- name: x86_64-gnu-llvm-16
- name: x86_64-gnu-llvm-17
env:
ENABLE_GCC_CODEGEN: "1"
os: ubuntu-20.04-16core-64gb
Expand Down Expand Up @@ -323,10 +323,6 @@ jobs:
env:
RUST_BACKTRACE: 1
os: ubuntu-20.04-8core-32gb
- name: x86_64-gnu-llvm-16
env:
RUST_BACKTRACE: 1
os: ubuntu-20.04-8core-32gb
- name: x86_64-gnu-nopt
os: ubuntu-20.04-4core-16gb
env: {}
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_codegen_llvm/src/context.rs
Expand Up @@ -126,17 +126,6 @@ pub unsafe fn create_module<'ll>(

let mut target_data_layout = sess.target.data_layout.to_string();
let llvm_version = llvm_util::get_version();
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", "");
}
}
if llvm_version < (18, 0, 0) {
if sess.target.arch == "x86" || sess.target.arch == "x86_64" {
// LLVM 18 adjusts i128 to be 128-bit aligned on x86 variants.
Expand Down
40 changes: 4 additions & 36 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Expand Up @@ -24,9 +24,7 @@
#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/FileSystem.h"
#if LLVM_VERSION_GE(17, 0)
#include "llvm/Support/VirtualFileSystem.h"
#endif
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO/AlwaysInliner.h"
#include "llvm/Transforms/IPO/FunctionImport.h"
Expand Down Expand Up @@ -334,14 +332,8 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,

std::ostringstream Buf;

#if LLVM_VERSION_GE(17, 0)
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getAllProcessorDescriptions();
#else
Buf << "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);

Buf << "Available CPUs for this target:\n";
Expand Down Expand Up @@ -476,10 +468,6 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
Options.RelaxELFRelocations = RelaxELFRelocations;
#endif
Options.UseInitArray = UseInitArray;

#if LLVM_VERSION_LT(17, 0)
Options.ExplicitEmulatedTLS = true;
#endif
Options.EmulatedTLS = UseEmulatedTls;

if (TrapUnreachable) {
Expand Down Expand Up @@ -761,50 +749,32 @@ LLVMRustOptimize(
}

std::optional<PGOOptions> PGOOpt;
#if LLVM_VERSION_GE(17, 0)
auto FS = vfs::getRealFileSystem();
#endif
if (PGOGenPath) {
assert(!PGOUsePath && !PGOSampleUsePath);
PGOOpt = PGOOptions(PGOGenPath, "", "",
#if LLVM_VERSION_GE(17, 0)
"",
FS,
#endif
PGOOpt = PGOOptions(PGOGenPath, "", "", "", FS,
PGOOptions::IRInstr, PGOOptions::NoCSAction,
#if LLVM_VERSION_GE(19, 0)
PGOOptions::ColdFuncOpt::Default,
#endif
DebugInfoForProfiling);
} else if (PGOUsePath) {
assert(!PGOSampleUsePath);
PGOOpt = PGOOptions(PGOUsePath, "", "",
#if LLVM_VERSION_GE(17, 0)
"",
FS,
#endif
PGOOpt = PGOOptions(PGOUsePath, "", "", "", FS,
PGOOptions::IRUse, PGOOptions::NoCSAction,
#if LLVM_VERSION_GE(19, 0)
PGOOptions::ColdFuncOpt::Default,
#endif
DebugInfoForProfiling);
} else if (PGOSampleUsePath) {
PGOOpt = PGOOptions(PGOSampleUsePath, "", "",
#if LLVM_VERSION_GE(17, 0)
"",
FS,
#endif
PGOOpt = PGOOptions(PGOSampleUsePath, "", "", "", FS,
PGOOptions::SampleUse, PGOOptions::NoCSAction,
#if LLVM_VERSION_GE(19, 0)
PGOOptions::ColdFuncOpt::Default,
#endif
DebugInfoForProfiling);
} else if (DebugInfoForProfiling) {
PGOOpt = PGOOptions("", "", "",
#if LLVM_VERSION_GE(17, 0)
"",
FS,
#endif
PGOOpt = PGOOptions("", "", "", "", FS,
PGOOptions::NoAction, PGOOptions::NoCSAction,
#if LLVM_VERSION_GE(19, 0)
PGOOptions::ColdFuncOpt::Default,
Expand Down Expand Up @@ -1353,9 +1323,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
ComputeCrossModuleImport(
Ret->Index,
Ret->ModuleToDefinedGVSummaries,
#if LLVM_VERSION_GE(17, 0)
isPrevailing,
#endif
Ret->ImportLists,
Ret->ExportLists
);
Expand Down
16 changes: 0 additions & 16 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Expand Up @@ -2152,19 +2152,3 @@ extern "C" LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C,
return wrap(ConstantDataArray::getString(*unwrap(C), StringRef(Str, Length), !DontNullTerminate));
}
#endif

// FIXME: Remove when Rust's minimum supported LLVM version reaches 17.
// https://github.com/llvm/llvm-project/commit/35276f16e5a2cae0dfb49c0fbf874d4d2f177acc
#if LLVM_VERSION_LT(17, 0)
extern "C" LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy,
LLVMValueRef *ConstantVals,
uint64_t Length) {
ArrayRef<Constant *> V(unwrap<Constant>(ConstantVals, Length), Length);
return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
}

extern "C" LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementTy,
uint64_t ElementCount) {
return wrap(ArrayType::get(unwrap(ElementTy), ElementCount));
}
#endif
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/llvm.rs
Expand Up @@ -564,11 +564,11 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
let version = output(cmd.arg("--version"));
let mut parts = version.split('.').take(2).filter_map(|s| s.parse::<u32>().ok());
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
if major >= 16 {
if major >= 17 {
return;
}
}
panic!("\n\nbad LLVM version: {version}, need >=16.0\n\n")
panic!("\n\nbad LLVM version: {version}, need >=17.0\n\n")
}

fn configure_cmake(
Expand Down
67 changes: 0 additions & 67 deletions src/ci/docker/host-x86_64/x86_64-gnu-llvm-16/Dockerfile

This file was deleted.

3 changes: 1 addition & 2 deletions src/ci/docker/host-x86_64/x86_64-gnu-llvm-17/Dockerfile
Expand Up @@ -56,11 +56,10 @@ ENV RUST_CONFIGURE_ARGS \
--enable-llvm-link-shared \
--set rust.thin-lto-import-instr-limit=10

COPY host-x86_64/x86_64-gnu-llvm-16/script.sh /tmp/

COPY host-x86_64/dist-x86_64-linux/shared.sh /scripts/
COPY host-x86_64/dist-x86_64-linux/build-gccjit.sh /scripts/

RUN /scripts/build-gccjit.sh /scripts

COPY scripts/x86_64-gnu-llvm.sh /tmp/script.sh
ENV SCRIPT /tmp/script.sh
15 changes: 11 additions & 4 deletions src/ci/docker/host-x86_64/x86_64-gnu-llvm-18/Dockerfile
Expand Up @@ -24,11 +24,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
xz-utils \
nodejs \
mingw-w64 \
libgccjit-13-dev \
# libgccjit dependencies
flex \
libmpfr-dev \
libgmp-dev \
libmpc3 \
libmpc-dev \
&& rm -rf /var/lib/apt/lists/*

# Note: libgccjit needs to match the default gcc version for the linker to find it.

# Install powershell (universal package) so we can test x.ps1 on Linux
# FIXME: need a "universal" version that supports libicu74, but for now it still works to ignore that dep.
RUN curl -sL "https://github.com/PowerShell/PowerShell/releases/download/v7.3.1/powershell_7.3.1-1.deb_amd64.deb" > powershell.deb && \
Expand All @@ -50,6 +53,10 @@ ENV RUST_CONFIGURE_ARGS \
--enable-llvm-link-shared \
--set rust.thin-lto-import-instr-limit=10

COPY host-x86_64/x86_64-gnu-llvm-16/script.sh /tmp/
COPY host-x86_64/dist-x86_64-linux/shared.sh /scripts/
COPY host-x86_64/dist-x86_64-linux/build-gccjit.sh /scripts/

RUN /scripts/build-gccjit.sh /scripts

COPY scripts/x86_64-gnu-llvm.sh /tmp/script.sh
ENV SCRIPT /tmp/script.sh
File renamed without changes.
7 changes: 1 addition & 6 deletions src/ci/github-actions/ci.yml
Expand Up @@ -357,7 +357,7 @@ jobs:
- name: mingw-check-tidy
<<: *job-linux-4c

- name: x86_64-gnu-llvm-16
- name: x86_64-gnu-llvm-17
env:
ENABLE_GCC_CODEGEN: "1"
<<: *job-linux-16c
Expand Down Expand Up @@ -520,11 +520,6 @@ jobs:
RUST_BACKTRACE: 1
<<: *job-linux-8c

- name: x86_64-gnu-llvm-16
env:
RUST_BACKTRACE: 1
<<: *job-linux-8c

- name: x86_64-gnu-nopt
<<: *job-linux-4c

Expand Down
1 change: 0 additions & 1 deletion tests/codegen/issues/issue-114312.rs
@@ -1,5 +1,4 @@
//@ compile-flags: -O
//@ min-llvm-version: 17
//@ only-x86_64-unknown-linux-gnu

// We want to check that this function does not mis-optimize to loop jumping.
Expand Down
1 change: 0 additions & 1 deletion tests/codegen/move-before-nocapture-ref-arg.rs
@@ -1,7 +1,6 @@
// Verify that move before the call of the function with noalias, nocapture, readonly.
// #107436
//@ compile-flags: -O
//@ min-llvm-version: 17

#![crate_type = "lib"]

Expand Down
2 changes: 0 additions & 2 deletions tests/codegen/option-as-slice.rs
@@ -1,7 +1,5 @@
//@ compile-flags: -O -Z randomize-layout=no
//@ only-x86_64
//@ ignore-llvm-version: 16.0.0
// ^-- needs https://reviews.llvm.org/D146149 in 16.0.1
#![crate_type = "lib"]
#![feature(generic_nonzero)]

Expand Down
1 change: 0 additions & 1 deletion tests/codegen/trailing_zeros.rs
@@ -1,5 +1,4 @@
//@ compile-flags: -O
//@ min-llvm-version: 17

#![crate_type = "lib"]

Expand Down
14 changes: 0 additions & 14 deletions tests/codegen/vec-shrink-panik.rs
@@ -1,8 +1,5 @@
//@ revisions: old new
// LLVM 17 realizes double panic is not possible and doesn't generate calls
// to panic_cannot_unwind.
//@ [old]ignore-llvm-version: 17 - 99
//@ [new]min-llvm-version: 17
//@ compile-flags: -O
//@ ignore-debug: plain old debug assertions
//@ needs-unwind
Expand All @@ -22,14 +19,6 @@ pub fn shrink_to_fit(vec: &mut Vec<u32>) {
// CHECK-LABEL: @issue71861
#[no_mangle]
pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> {
// CHECK-NOT: panic

// Call to panic_cannot_unwind in case of double-panic is expected
// on LLVM 16 and older, but other panics are not.
// old: filter
// old-NEXT: ; call core::panicking::panic_cannot_unwind
// old-NEXT: panic_cannot_unwind

// CHECK-NOT: panic
vec.into_boxed_slice()
}
Expand All @@ -40,6 +29,3 @@ pub fn issue75636<'a>(iter: &[&'a str]) -> Box<[&'a str]> {
// CHECK-NOT: panic
iter.iter().copied().collect()
}

// old: ; core::panicking::panic_cannot_unwind
// old: declare void @{{.*}}panic_cannot_unwind
1 change: 0 additions & 1 deletion tests/run-make/lto-linkage-used-attr/Makefile
Expand Up @@ -2,7 +2,6 @@ include ../tools.mk

# Verify that the impl_* symbols are preserved. #108030
# only-x86_64-unknown-linux-gnu
# min-llvm-version: 17

all:
$(RUSTC) -Cdebuginfo=0 -Copt-level=3 lib.rs
Expand Down
1 change: 0 additions & 1 deletion tests/ui/codegen/target-cpus.rs
@@ -1,4 +1,3 @@
//@ needs-llvm-components: webassembly
//@ min-llvm-version: 17
//@ compile-flags: --print=target-cpus --target=wasm32-unknown-unknown
//@ check-pass

0 comments on commit 414debe

Please sign in to comment.