From d2498cc4318dc1e19bab21bc21e13c745d0bf812 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 14 Apr 2024 00:31:51 +0200 Subject: [PATCH] CI: Bump LDC-LLVM to v18.1.3 (except for Android and macOS arm64) (#4604) I've removed our own TLS emulation for Android, and switched to the latest NDK (r26d). Switching to native TLS supported since Android 10/11 requires a few compiler and druntime changes; I'll follow up. The macOS arm64 LLVM binaries were built natively on macOS 14 arm64, with Xcode v15.3. Experiments with a native LDC build on such a macOS 14 arm64 CI runner show random 'Pure virtual function called' errors for the compiler itself (compiled with itself). Not sure whether these are regressions (with a failure rate of maybe very roughly 1:1000), or happening with the current cross-compiled macOS arm64 binaries too - opting for the safe variant of keeping LLVM 17 for the macOS arm64 job. --- .cirrus.yml | 6 ++- .github/actions/1-setup/action.yml | 4 +- .github/workflows/main.yml | 7 ++-- .github/workflows/supported_llvm_versions.yml | 42 +++++++++---------- CHANGELOG.md | 2 +- runtime/druntime/src/rt/msvc.d | 8 +++- tests/codegen/dcompute_cl_addrspaces_new.d | 3 ++ tests/codegen/dcompute_cl_images.d | 3 ++ 8 files changed, 45 insertions(+), 30 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index d8a7481b6ae..5ad799ca533 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -210,7 +210,7 @@ install_ubuntu_prerequisites_template: &INSTALL_UBUNTU_PREREQUISITES_TEMPLATE environment: CIRRUS_CLONE_DEPTH: 50 HOST_LDC_VERSION: 1.31.0 - LLVM_VERSION: 17.0.6 + LLVM_VERSION: 18.1.3 GITHUB_TOKEN: ENCRYPTED[0955bd48c8d4e5391446fc0149d0719ad0b63df27ec9e6c180a5730a5b10dc7f28f09d1383423db158d21380ee2b022a] task: @@ -248,7 +248,7 @@ task: environment: CI_ARCH: aarch64 CI_OS: linux - EXTRA_APT_PACKAGES: libxml2-dev p7zip-full + EXTRA_APT_PACKAGES: libxml2-dev libzstd-dev p7zip-full EXTRA_CMAKE_FLAGS: >- -DBUILD_LTO_LIBS=ON -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" @@ -282,6 +282,8 @@ task: # Make lld the default linker (likely with enabled assertions unfortunately) ln -sf "$PWD/llvm/bin/ld.lld" /usr/bin/ld ld --version + # Make sure to link libzstd statically + rm /usr/lib/aarch64-linux-gnu/libzstd.so # Download & extract clang download_prebuilt_clang_script: | cd $CIRRUS_WORKING_DIR/.. diff --git a/.github/actions/1-setup/action.yml b/.github/actions/1-setup/action.yml index b8e9bf55da2..aa099699efe 100644 --- a/.github/actions/1-setup/action.yml +++ b/.github/actions/1-setup/action.yml @@ -21,8 +21,10 @@ runs: # Don't use latest gdb v10+ from Ubuntu toolchain PPA with regressions, use official v9 sudo apt-get -yq install \ git-core cmake g++-multilib \ - libcurl4 libcurl4:i386 \ + libcurl4 libcurl4:i386 libzstd-dev \ curl gdb=9.1-0ubuntu1 p7zip-full tzdata unzip zip python3-pip + # Make sure to link libzstd statically + sudo rm /usr/lib/x86_64-linux-gnu/libzstd.so - name: 'Linux: Download & extract clang' # into ../clang if: runner.os == 'Linux' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 593e0641839..026f49f9dd0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ concurrency: env: CLANG_VERSION: 15.0.6 - LLVM_VERSION: 17.0.6 + LLVM_VERSION: 18.1.3 jobs: build-native: @@ -37,7 +37,7 @@ jobs: with_pgo: true - job_name: macOS x86_64 - os: macos-11 + os: macos-12 arch: x86_64 bootstrap_cmake_flags: >- -DBUILD_LTO_LIBS=ON @@ -85,7 +85,7 @@ jobs: - name: Install prerequisites uses: ./.github/actions/1-setup with: - clang_version: ${{ runner.os == 'Windows' && '16.0.6' || env.CLANG_VERSION }} + clang_version: ${{ runner.os == 'Windows' && '18.1.3' || env.CLANG_VERSION }} llvm_version: ${{ env.LLVM_VERSION }} arch: ${{ matrix.arch }} - name: Build bootstrap LDC @@ -192,6 +192,7 @@ jobs: timeout-minutes: 60 env: MACOSX_DEPLOYMENT_TARGET: 11.0 + LLVM_VERSION: 17.0.6 # TODO steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/supported_llvm_versions.yml b/.github/workflows/supported_llvm_versions.yml index c1323bb1731..b9441469f21 100644 --- a/.github/workflows/supported_llvm_versions.yml +++ b/.github/workflows/supported_llvm_versions.yml @@ -18,7 +18,8 @@ jobs: - job_name: Ubuntu 20.04, LDC-LLVM 18, latest LDC beta os: ubuntu-20.04 host_dc: ldc-beta - llvm_version: bfcdb95c # FIXME: no usable official package available yet + # FIXME: no usable official package available yet + llvm_version: https://github.com/ldc-developers/llvm-project/releases/download/ldc-v18.1.3/llvm-18.1.3-linux-x86_64.tar.xz - job_name: macOS 14, LLVM 17, latest LDC beta os: macos-14 host_dc: ldc-beta @@ -81,13 +82,13 @@ jobs: python3 -m pip install --user lit fi python3 -c "import lit.main; lit.main.main();" --version . | head -n 1 - - name: 'Linux: Install gdb and llvm-symbolizer' + - name: 'Linux: Install gdb, llvm-symbolizer and libzstd' if: runner.os == 'Linux' run: | set -eux sudo apt-get update # Don't use latest gdb v10+ from Ubuntu toolchain PPA with regressions, use official v9 - sudo apt-get install gdb=9.1-0ubuntu1 llvm + sudo apt-get install gdb=9.1-0ubuntu1 llvm libzstd-dev - name: Try to restore cached LLVM uses: actions/cache@v3 @@ -102,29 +103,26 @@ jobs: echo "Already cached" exit 0 fi + version='${{ matrix.llvm_version }}' - if [[ '${{ runner.os }}' == macOS ]]; then - if [[ "$version" =~ ^1[6-9]\. ]]; then - suffix='arm64-apple-darwin22.0' + if [[ "$version" =~ ^https:// ]]; then + url="$version" + else + if [[ '${{ runner.os }}' == macOS ]]; then + if [[ "$version" =~ ^1[6-9]\. ]]; then + suffix='arm64-apple-darwin22.0' + else + suffix='x86_64-apple-darwin' + fi + elif [[ "$version" =~ ^1[7-9]\. ]]; then + suffix='x86_64-linux-gnu-ubuntu-22.04' # LLVM 17+ + elif [[ "$version" =~ ^1[3-6]\. ]]; then + suffix='x86_64-linux-gnu-ubuntu-18.04' # LLVM 13.0.1+ else - suffix='x86_64-apple-darwin' + suffix='x86_64-linux-gnu-ubuntu-16.04' fi - elif [[ "$version" =~ ^1[7-9]\. ]]; then - suffix='x86_64-linux-gnu-ubuntu-22.04' # LLVM 17+ - elif [[ "$version" =~ ^1[3-6]\. ]]; then - suffix='x86_64-linux-gnu-ubuntu-18.04' # LLVM 13.0.1+ - else - suffix='x86_64-linux-gnu-ubuntu-16.04' - fi - if [[ "$version" = *.* ]]; then + url="https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/clang+llvm-$version-$suffix.tar.xz" - else # short commit SHA of ldc-developers fork - if [[ '${{ runner.os }}' == Linux ]]; then - suffix='linux-x86_64' - elif [[ '${{ runner.os }}' == macOS ]]; then - suffix='osx-arm64' - fi - url="https://github.com/ldc-developers/llvm-project/releases/download/CI/llvm-$version-$suffix.tar.xz" fi curl -fL --retry 3 --max-time 300 -o llvm.tar.xz "$url" diff --git a/CHANGELOG.md b/CHANGELOG.md index d3823a4e63c..ad894060c2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ #### Big news - Frontend, druntime and Phobos are at version [2.108.0](https://dlang.org/changelog/2.108.0.html). (#4591, #4615) -- Preliminary support for LLVM 18. (#4599, #4605, #4607) +- Support for [LLVM 18](https://releases.llvm.org/18.1.0/docs/ReleaseNotes.html). The prebuilt packages use v18.1.3 (except for Android and macOS arm64). (#4599, #4605, #4607, #4604) #### Platform support - Supports LLVM 11 - 18. diff --git a/runtime/druntime/src/rt/msvc.d b/runtime/druntime/src/rt/msvc.d index 263e3bd1fb6..5ac19a78fbd 100644 --- a/runtime/druntime/src/rt/msvc.d +++ b/runtime/druntime/src/rt/msvc.d @@ -76,9 +76,15 @@ version (LDC) // The MinGW-w64 libs don't provide _(_)chkstk; fall back to the // implementation in LLVM's builtins compiler-rt lib. version (X86_64) + { mixin declareAlternateName!("__chkstk", "___chkstk_ms"); + } else - mixin declareAlternateName!("_chkstk", "__chkstk"); // `__chkstk_ms` isn't the MS-compatible one! + { + // `_chkstk` and `_alloca` are the same function (and `__chkstk_ms` + // isn't the MS-compatible one!); LLVM 18 dropped the `__chkstk` alias + mixin declareAlternateName!("_chkstk", "_alloca"); + } } else // !LDC { diff --git a/tests/codegen/dcompute_cl_addrspaces_new.d b/tests/codegen/dcompute_cl_addrspaces_new.d index 83e572aa6ee..ad28b905ff8 100644 --- a/tests/codegen/dcompute_cl_addrspaces_new.d +++ b/tests/codegen/dcompute_cl_addrspaces_new.d @@ -1,5 +1,8 @@ // See GH issue #2709 +// FIXME: hits an assertion for LLVM 18: https://github.com/llvm/llvm-project/issues/87315 +// UNSUPPORTED: atleast_llvm1800 && atmost_llvm1809 + // REQUIRES: target_SPIRV && atleast_llvm1600 // RUN: %ldc -c -opaque-pointers -mdcompute-targets=ocl-220 -m64 -mdcompute-file-prefix=addrspace_new -output-ll -output-o %s && FileCheck %s --check-prefix=LL < addrspace_new_ocl220_64.ll \ // RUN: && %llc addrspace_new_ocl220_64.ll -mtriple=spirv64-unknown-unknown -O0 -o - | FileCheck %s --check-prefix=SPT diff --git a/tests/codegen/dcompute_cl_images.d b/tests/codegen/dcompute_cl_images.d index 406b9839d3e..892039d5fbf 100644 --- a/tests/codegen/dcompute_cl_images.d +++ b/tests/codegen/dcompute_cl_images.d @@ -3,6 +3,9 @@ // FIXME: hits an assertion with SPIRV-LLVM-Translator for LLVM 15, see https://github.com/ldc-developers/ldc/pull/4010#issuecomment-1191820165 // XFAIL: atleast_llvm1500 && atmost_llvm1509 +// FIXME: another assertion for LLVM 18: https://github.com/llvm/llvm-project/issues/87315 +// UNSUPPORTED: atleast_llvm1800 && atmost_llvm1809 + // RUN: %ldc -c -mdcompute-targets=ocl-220 -m64 -I%S/inputs -mdcompute-file-prefix=%t -output-ll -output-o %s && FileCheck %s < %t_ocl220_64.ll @compute(CompileFor.deviceOnly) module dcompute_cl_images; import ldc.dcompute;