Skip to content

Commit 2943055

Browse files
committed
Update the minimum external LLVM to 17
1 parent 35dfc67 commit 2943055

File tree

16 files changed

+20
-168
lines changed

16 files changed

+20
-168
lines changed

.github/workflows/ci.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: mingw-check-tidy
5959
os: ubuntu-20.04-4core-16gb
6060
env: {}
61-
- name: x86_64-gnu-llvm-16
61+
- name: x86_64-gnu-llvm-17
6262
env:
6363
ENABLE_GCC_CODEGEN: "1"
6464
os: ubuntu-20.04-16core-64gb
@@ -323,10 +323,6 @@ jobs:
323323
env:
324324
RUST_BACKTRACE: 1
325325
os: ubuntu-20.04-8core-32gb
326-
- name: x86_64-gnu-llvm-16
327-
env:
328-
RUST_BACKTRACE: 1
329-
os: ubuntu-20.04-8core-32gb
330326
- name: x86_64-gnu-nopt
331327
os: ubuntu-20.04-4core-16gb
332328
env: {}

compiler/rustc_codegen_llvm/src/context.rs

-11
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,6 @@ pub unsafe fn create_module<'ll>(
126126

127127
let mut target_data_layout = sess.target.data_layout.to_string();
128128
let llvm_version = llvm_util::get_version();
129-
if llvm_version < (17, 0, 0) {
130-
if sess.target.arch.starts_with("powerpc") {
131-
// LLVM 17 specifies function pointer alignment for ppc:
132-
// https://reviews.llvm.org/D147016
133-
target_data_layout = target_data_layout
134-
.replace("-Fn32", "")
135-
.replace("-Fi32", "")
136-
.replace("-Fn64", "")
137-
.replace("-Fi64", "");
138-
}
139-
}
140129
if llvm_version < (18, 0, 0) {
141130
if sess.target.arch == "x86" || sess.target.arch == "x86_64" {
142131
// LLVM 18 adjusts i128 to be 128-bit aligned on x86 variants.

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+4-36
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
#include "llvm/Passes/StandardInstrumentations.h"
2525
#include "llvm/Support/CBindingWrapping.h"
2626
#include "llvm/Support/FileSystem.h"
27-
#if LLVM_VERSION_GE(17, 0)
2827
#include "llvm/Support/VirtualFileSystem.h"
29-
#endif
3028
#include "llvm/Target/TargetMachine.h"
3129
#include "llvm/Transforms/IPO/AlwaysInliner.h"
3230
#include "llvm/Transforms/IPO/FunctionImport.h"
@@ -334,14 +332,8 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
334332

335333
std::ostringstream Buf;
336334

337-
#if LLVM_VERSION_GE(17, 0)
338335
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
339336
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getAllProcessorDescriptions();
340-
#else
341-
Buf << "Full target CPU help is not supported by this LLVM version.\n\n";
342-
SubtargetSubTypeKV TargetCPUKV = { TargetCPU, {{}}, {{}} };
343-
const ArrayRef<SubtargetSubTypeKV> CPUTable = TargetCPUKV;
344-
#endif
345337
unsigned MaxCPULen = getLongestEntryLength(CPUTable);
346338

347339
Buf << "Available CPUs for this target:\n";
@@ -476,10 +468,6 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
476468
Options.RelaxELFRelocations = RelaxELFRelocations;
477469
#endif
478470
Options.UseInitArray = UseInitArray;
479-
480-
#if LLVM_VERSION_LT(17, 0)
481-
Options.ExplicitEmulatedTLS = true;
482-
#endif
483471
Options.EmulatedTLS = UseEmulatedTls;
484472

485473
if (TrapUnreachable) {
@@ -761,50 +749,32 @@ LLVMRustOptimize(
761749
}
762750

763751
std::optional<PGOOptions> PGOOpt;
764-
#if LLVM_VERSION_GE(17, 0)
765752
auto FS = vfs::getRealFileSystem();
766-
#endif
767753
if (PGOGenPath) {
768754
assert(!PGOUsePath && !PGOSampleUsePath);
769-
PGOOpt = PGOOptions(PGOGenPath, "", "",
770-
#if LLVM_VERSION_GE(17, 0)
771-
"",
772-
FS,
773-
#endif
755+
PGOOpt = PGOOptions(PGOGenPath, "", "", "", FS,
774756
PGOOptions::IRInstr, PGOOptions::NoCSAction,
775757
#if LLVM_VERSION_GE(19, 0)
776758
PGOOptions::ColdFuncOpt::Default,
777759
#endif
778760
DebugInfoForProfiling);
779761
} else if (PGOUsePath) {
780762
assert(!PGOSampleUsePath);
781-
PGOOpt = PGOOptions(PGOUsePath, "", "",
782-
#if LLVM_VERSION_GE(17, 0)
783-
"",
784-
FS,
785-
#endif
763+
PGOOpt = PGOOptions(PGOUsePath, "", "", "", FS,
786764
PGOOptions::IRUse, PGOOptions::NoCSAction,
787765
#if LLVM_VERSION_GE(19, 0)
788766
PGOOptions::ColdFuncOpt::Default,
789767
#endif
790768
DebugInfoForProfiling);
791769
} else if (PGOSampleUsePath) {
792-
PGOOpt = PGOOptions(PGOSampleUsePath, "", "",
793-
#if LLVM_VERSION_GE(17, 0)
794-
"",
795-
FS,
796-
#endif
770+
PGOOpt = PGOOptions(PGOSampleUsePath, "", "", "", FS,
797771
PGOOptions::SampleUse, PGOOptions::NoCSAction,
798772
#if LLVM_VERSION_GE(19, 0)
799773
PGOOptions::ColdFuncOpt::Default,
800774
#endif
801775
DebugInfoForProfiling);
802776
} else if (DebugInfoForProfiling) {
803-
PGOOpt = PGOOptions("", "", "",
804-
#if LLVM_VERSION_GE(17, 0)
805-
"",
806-
FS,
807-
#endif
777+
PGOOpt = PGOOptions("", "", "", "", FS,
808778
PGOOptions::NoAction, PGOOptions::NoCSAction,
809779
#if LLVM_VERSION_GE(19, 0)
810780
PGOOptions::ColdFuncOpt::Default,
@@ -1353,9 +1323,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
13531323
ComputeCrossModuleImport(
13541324
Ret->Index,
13551325
Ret->ModuleToDefinedGVSummaries,
1356-
#if LLVM_VERSION_GE(17, 0)
13571326
isPrevailing,
1358-
#endif
13591327
Ret->ImportLists,
13601328
Ret->ExportLists
13611329
);

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -2152,19 +2152,3 @@ extern "C" LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C,
21522152
return wrap(ConstantDataArray::getString(*unwrap(C), StringRef(Str, Length), !DontNullTerminate));
21532153
}
21542154
#endif
2155-
2156-
// FIXME: Remove when Rust's minimum supported LLVM version reaches 17.
2157-
// https://github.com./llvm/llvm-project/commit/35276f16e5a2cae0dfb49c0fbf874d4d2f177acc
2158-
#if LLVM_VERSION_LT(17, 0)
2159-
extern "C" LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy,
2160-
LLVMValueRef *ConstantVals,
2161-
uint64_t Length) {
2162-
ArrayRef<Constant *> V(unwrap<Constant>(ConstantVals, Length), Length);
2163-
return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
2164-
}
2165-
2166-
extern "C" LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementTy,
2167-
uint64_t ElementCount) {
2168-
return wrap(ArrayType::get(unwrap(ElementTy), ElementCount));
2169-
}
2170-
#endif

src/bootstrap/src/core/build_steps/llvm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,11 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
564564
let version = output(cmd.arg("--version"));
565565
let mut parts = version.split('.').take(2).filter_map(|s| s.parse::<u32>().ok());
566566
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
567-
if major >= 16 {
567+
if major >= 17 {
568568
return;
569569
}
570570
}
571-
panic!("\n\nbad LLVM version: {version}, need >=16.0\n\n")
571+
panic!("\n\nbad LLVM version: {version}, need >=17.0\n\n")
572572
}
573573

574574
fn configure_cmake(

src/ci/docker/host-x86_64/x86_64-gnu-llvm-16/Dockerfile

-67
This file was deleted.

src/ci/docker/host-x86_64/x86_64-gnu-llvm-17/Dockerfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ ENV RUST_CONFIGURE_ARGS \
5656
--enable-llvm-link-shared \
5757
--set rust.thin-lto-import-instr-limit=10
5858

59-
COPY host-x86_64/x86_64-gnu-llvm-16/script.sh /tmp/
60-
6159
COPY host-x86_64/dist-x86_64-linux/shared.sh /scripts/
6260
COPY host-x86_64/dist-x86_64-linux/build-gccjit.sh /scripts/
6361

6462
RUN /scripts/build-gccjit.sh /scripts
6563

64+
COPY scripts/x86_64-gnu-llvm.sh /tmp/script.sh
6665
ENV SCRIPT /tmp/script.sh

src/ci/docker/host-x86_64/x86_64-gnu-llvm-18/Dockerfile

+11-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2424
xz-utils \
2525
nodejs \
2626
mingw-w64 \
27-
libgccjit-13-dev \
27+
# libgccjit dependencies
28+
flex \
29+
libmpfr-dev \
30+
libgmp-dev \
31+
libmpc3 \
32+
libmpc-dev \
2833
&& rm -rf /var/lib/apt/lists/*
2934

30-
# Note: libgccjit needs to match the default gcc version for the linker to find it.
31-
3235
# Install powershell (universal package) so we can test x.ps1 on Linux
3336
# FIXME: need a "universal" version that supports libicu74, but for now it still works to ignore that dep.
3437
RUN curl -sL "https://github.com./PowerShell/PowerShell/releases/download/v7.3.1/powershell_7.3.1-1.deb_amd64.deb" > powershell.deb && \
@@ -50,6 +53,10 @@ ENV RUST_CONFIGURE_ARGS \
5053
--enable-llvm-link-shared \
5154
--set rust.thin-lto-import-instr-limit=10
5255

53-
COPY host-x86_64/x86_64-gnu-llvm-16/script.sh /tmp/
56+
COPY host-x86_64/dist-x86_64-linux/shared.sh /scripts/
57+
COPY host-x86_64/dist-x86_64-linux/build-gccjit.sh /scripts/
58+
59+
RUN /scripts/build-gccjit.sh /scripts
5460

61+
COPY scripts/x86_64-gnu-llvm.sh /tmp/script.sh
5562
ENV SCRIPT /tmp/script.sh

src/ci/github-actions/ci.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ jobs:
357357
- name: mingw-check-tidy
358358
<<: *job-linux-4c
359359

360-
- name: x86_64-gnu-llvm-16
360+
- name: x86_64-gnu-llvm-17
361361
env:
362362
ENABLE_GCC_CODEGEN: "1"
363363
<<: *job-linux-16c
@@ -520,11 +520,6 @@ jobs:
520520
RUST_BACKTRACE: 1
521521
<<: *job-linux-8c
522522

523-
- name: x86_64-gnu-llvm-16
524-
env:
525-
RUST_BACKTRACE: 1
526-
<<: *job-linux-8c
527-
528523
- name: x86_64-gnu-nopt
529524
<<: *job-linux-4c
530525

tests/codegen/issues/issue-114312.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ compile-flags: -O
2-
//@ min-llvm-version: 17
32
//@ only-x86_64-unknown-linux-gnu
43

54
// We want to check that this function does not mis-optimize to loop jumping.

tests/codegen/move-before-nocapture-ref-arg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Verify that move before the call of the function with noalias, nocapture, readonly.
22
// #107436
33
//@ compile-flags: -O
4-
//@ min-llvm-version: 17
54

65
#![crate_type = "lib"]
76

tests/codegen/trailing_zeros.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ compile-flags: -O
2-
//@ min-llvm-version: 17
32

43
#![crate_type = "lib"]
54

tests/codegen/vec-shrink-panik.rs

-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
//@ revisions: old new
21
// LLVM 17 realizes double panic is not possible and doesn't generate calls
32
// to panic_cannot_unwind.
4-
//@ [old]ignore-llvm-version: 17 - 99
5-
//@ [new]min-llvm-version: 17
63
//@ compile-flags: -O
74
//@ ignore-debug: plain old debug assertions
85
//@ needs-unwind
@@ -22,14 +19,6 @@ pub fn shrink_to_fit(vec: &mut Vec<u32>) {
2219
// CHECK-LABEL: @issue71861
2320
#[no_mangle]
2421
pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> {
25-
// CHECK-NOT: panic
26-
27-
// Call to panic_cannot_unwind in case of double-panic is expected
28-
// on LLVM 16 and older, but other panics are not.
29-
// old: filter
30-
// old-NEXT: ; call core::panicking::panic_cannot_unwind
31-
// old-NEXT: panic_cannot_unwind
32-
3322
// CHECK-NOT: panic
3423
vec.into_boxed_slice()
3524
}
@@ -40,6 +29,3 @@ pub fn issue75636<'a>(iter: &[&'a str]) -> Box<[&'a str]> {
4029
// CHECK-NOT: panic
4130
iter.iter().copied().collect()
4231
}
43-
44-
// old: ; core::panicking::panic_cannot_unwind
45-
// old: declare void @{{.*}}panic_cannot_unwind

tests/run-make/lto-linkage-used-attr/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ include ../tools.mk
22

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

76
all:
87
$(RUSTC) -Cdebuginfo=0 -Copt-level=3 lib.rs

tests/ui/codegen/target-cpus.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
//@ needs-llvm-components: webassembly
2-
//@ min-llvm-version: 17
32
//@ compile-flags: --print=target-cpus --target=wasm32-unknown-unknown
43
//@ check-pass

0 commit comments

Comments
 (0)