From 85eaadfc01b0e558f99c5b162caf53988a9b96a5 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 17 Jan 2024 14:50:32 +0100 Subject: [PATCH 1/8] Update to LLVM 18 --- .gitmodules | 2 +- src/llvm-project | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 9bb68b37081f5..802d61eea293b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,7 +33,7 @@ [submodule "src/llvm-project"] path = src/llvm-project url = https://github.com/rust-lang/llvm-project.git - branch = rustc/17.0-2023-12-14 + branch = rustc/18.0-2024-02-13 shallow = true [submodule "src/doc/embedded-book"] path = src/doc/embedded-book diff --git a/src/llvm-project b/src/llvm-project index 700fbf978e6c5..9ea7f739f257b 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 700fbf978e6c5bb297d12963206f7487722de480 +Subproject commit 9ea7f739f257b049a65deeb1f2455bb2ea021cfa From a911c8ce23a29a0721fb02ff90368143e764de9c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 17 Jan 2024 15:05:18 +0100 Subject: [PATCH 2/8] Use MCSubtargetInfo::getAllProcessorFeatures() This method is now available in upstream LLVM \o/ --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 3b6bf03686b0d..9744701be6b45 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -368,10 +368,10 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, } extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) { -#ifdef LLVM_RUSTLLVM +#if LLVM_VERSION_GE(18, 0) const TargetMachine *Target = unwrap(TM); const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo(); - const ArrayRef FeatTable = MCInfo->getFeatureTable(); + const ArrayRef FeatTable = MCInfo->getAllProcessorFeatures(); return FeatTable.size(); #else return 0; @@ -380,10 +380,10 @@ extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) { extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index, const char** Feature, const char** Desc) { -#ifdef LLVM_RUSTLLVM +#if LLVM_VERSION_GE(18, 0) const TargetMachine *Target = unwrap(TM); const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo(); - const ArrayRef FeatTable = MCInfo->getFeatureTable(); + const ArrayRef FeatTable = MCInfo->getAllProcessorFeatures(); const SubtargetFeatureKV Feat = FeatTable[Index]; *Feature = Feat.Key; *Desc = Feat.Desc; From edfbe6351d99d7d51696aa824c3faf916cba50a4 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 22 Jan 2024 12:59:41 +0100 Subject: [PATCH 3/8] Update compiler-builtins This is necessary to pull in a number of compiler-rt build fixes. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d552bb655b40a..d4b7253feb5bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -747,9 +747,9 @@ checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335" [[package]] name = "compiler_builtins" -version = "0.1.105" +version = "0.1.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3686cc48897ce1950aa70fd595bd2dc9f767a3c4cca4cd17b2cb52a2d37e6eb4" +checksum = "d68bc55329711cd719c2687bb147bc06211b0521f97ef398280108ccb23227e9" dependencies = [ "cc", "rustc-std-workspace-core", From 48748804e0fb02da94518a952df3aca5e6eadcb5 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 5 Feb 2024 12:08:51 +0100 Subject: [PATCH 4/8] Use CMAKE_MSVC_RUNTIME_LIBRARY instead of LLVM_USE_CRT_* This cmake option has been removed in: https://github.com/llvm/llvm-project/commit/618e5d2c2d8e0c288c37b883ece553ca4f994c2e --- src/bootstrap/src/core/build_steps/llvm.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index afbbbb5bd269d..836ac3de94d36 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -412,9 +412,7 @@ impl Step for Llvm { } if target.is_msvc() { - cfg.define("LLVM_USE_CRT_DEBUG", "MT"); - cfg.define("LLVM_USE_CRT_RELEASE", "MT"); - cfg.define("LLVM_USE_CRT_RELWITHDEBINFO", "MT"); + cfg.define("CMAKE_MSVC_RUNTIME_LIBRARY", "MultiThreaded"); cfg.static_crt(true); } From 1ea7db8a54aefddce9d4ee67c57e7fae6986a723 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 8 Feb 2024 09:43:01 +0100 Subject: [PATCH 5/8] Add missing riscv32imafc_unknown_none_elf env vars to dist-various-1 These are necessary now that compiler-builtins requires a working C compiler for riscv. --- src/ci/docker/host-x86_64/dist-various-1/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile index ea185cd582cd1..09fbbac466c72 100644 --- a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile @@ -134,6 +134,8 @@ ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft CFLAGS_riscv32imc_unknown_none_elf=-march=rv32imc -mabi=ilp32 \ CC_riscv32imac_unknown_none_elf=riscv32-unknown-elf-gcc \ CFLAGS_riscv32imac_unknown_none_elf=-march=rv32imac -mabi=ilp32 \ + CC_riscv32imafc_unknown_none_elf=riscv32-unknown-elf-gcc \ + CFLAGS_riscv32imafc_unknown_none_elf=-march=rv32imafc -mabi=ilp32 \ CC_riscv64imac_unknown_none_elf=riscv64-unknown-elf-gcc \ CFLAGS_riscv64imac_unknown_none_elf=-march=rv64imac -mabi=lp64 \ CC_riscv64gc_unknown_none_elf=riscv64-unknown-elf-gcc \ From 41a9cd4810723990151e2b2be3c8c990cd672ace Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 8 Feb 2024 16:12:50 +0100 Subject: [PATCH 6/8] Set wasm32_unknown_unknown compiler in test-various --- src/ci/docker/host-x86_64/test-various/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index 4fe66014c17cd..3fcf12dd9f28e 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -59,6 +59,7 @@ ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_T tests/codegen \ tests/assembly \ library/core +ENV CC_wasm32_unknown_unknown=clang-11 ENV NVPTX_TARGETS=nvptx64-nvidia-cuda ENV NVPTX_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $NVPTX_TARGETS \ From a47834ef809274b1ed0a55d064979f238dd58293 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 8 Feb 2024 18:30:17 +0100 Subject: [PATCH 7/8] Use system clang for wasm32_unknown_unknown on x86-gnu-integration Fuchsia clang does not include the wasm32 target, so instead install and use system clang for this purpose. --- src/ci/docker/host-x86_64/x86_64-gnu-integration/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-integration/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-integration/Dockerfile index bec1c89733775..c8c754914aa63 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-integration/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu-integration/Dockerfile @@ -3,6 +3,7 @@ FROM ubuntu:22.04 ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ + clang-15 \ g++ \ make \ ninja-build \ @@ -46,6 +47,9 @@ ENV TARGETS=x86_64-fuchsia ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnu ENV TARGETS=$TARGETS,wasm32-unknown-unknown +# Fuchsia clang does not have wasm target enabled, use system clang. +ENV CC_wasm32_unknown_unknown=clang-15 + COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh From a6ee72df91093b4615421679471ec61191d503b3 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Mon, 12 Feb 2024 16:26:06 -0500 Subject: [PATCH 8/8] tests: LLVM 18 infers an extra noalias here This test started failing on LLVM 18 after change 61118ffd04aa6d1f9ee92daae4deb28bd975d4ab. As far as I can tell, it's just good fortune that LLVM is able to sniff out the new noalias here, and it's correct. --- tests/codegen/iter-repeat-n-trivial-drop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codegen/iter-repeat-n-trivial-drop.rs b/tests/codegen/iter-repeat-n-trivial-drop.rs index 0b08e578151db..b052d339917da 100644 --- a/tests/codegen/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen/iter-repeat-n-trivial-drop.rs @@ -47,7 +47,7 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN) -> Option Vec { - // CHECK: %[[ADDR:.+]] = tail call noundef dereferenceable_or_null(1234) ptr @__rust_alloc(i64 noundef 1234, i64 noundef 1) + // CHECK: %[[ADDR:.+]] = tail call {{(noalias )?}}noundef dereferenceable_or_null(1234) ptr @__rust_alloc(i64 noundef 1234, i64 noundef 1) // CHECK: tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1234) %[[ADDR]], i8 42, i64 1234, let n = 1234_usize;