From 1334558c5c21247d5cdc234a31a81702b4720860 Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbarton@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:40:42 +0000 Subject: [PATCH] Support llvm 18 --- .github/workflows/ci.yml | 91 +++++++++++++++++++++-- CMakeLists.txt | 8 +- lib/Interpreter/DynamicLibraryManager.cpp | 8 +- 3 files changed, 95 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d8c46470..e05d35561 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,21 @@ jobs: fail-fast: false matrix: include: + - name: ubu22-x86-gcc12-clang-repl-18-cppyy + os: ubuntu-22.04 + compiler: gcc-12 + clang-runtime: '18' + cling: Off + cppyy: On + coverage: true + - name: ubu22-x86-gcc12-clang-repl-18-xeus-clang-repl + os: ubuntu-22.04 + compiler: gcc-12 + clang-runtime: '18' + cling: Off + cppyy: On + xeus-clang-repl: On + coverage: true - name: ubu22-x86-gcc12-clang-repl-17-cppyy os: ubuntu-22.04 compiler: gcc-12 @@ -70,6 +85,19 @@ jobs: coverage: true #Commented out until Ubuntu on arm Github runner becomes available #os key to be replaced once known + #- name: ubu22-arm-gcc12-clang-repl-18-cppyy + # os: ubuntu-22.04-arm + # compiler: gcc-12 + # clang-runtime: '18' + # cling: Off + # cppyy: On + #- name: ubu22-arm-gcc12-clang-repl-18-xeus-clang-repl + # os: ubuntu-22.04-arm + # compiler: gcc-12 + # clang-runtime: '18' + # cling: Off + # cppyy: On + # xeus-clang-repl: On #- name: ubu22-arm-gcc12-clang-repl-17-cppyy # os: ubuntu-22.04-arm # compiler: gcc-12 @@ -114,6 +142,12 @@ jobs: # xeus-clang-repl: On #FIXME: Windows CppInterOp tests expected to fail #until https://github.com/compiler-research/CppInterOp/issues/188 is solved + - name: win2022-msvc-clang-repl-18 + os: windows-2022 + compiler: msvc + clang-runtime: '18' + cling: Off + cppyy: Off - name: win2022-msvc-clang-repl-17 os: windows-2022 compiler: msvc @@ -152,6 +186,19 @@ jobs: # cling: On # cling-version: '1.0' # cppyy: On + - name: osx14-arm-clang-clang-repl-18-cppyy + os: macos-14 + compiler: clang + clang-runtime: '18' + cling: Off + cppyy: On + - name: osx14-arm-clang-clang-repl-18-xeus-clang-repl + os: macos-14 + compiler: clang + clang-runtime: '18' + cling: Off + cppyy: On + xeus-clang-repl: On - name: osx14-arm-clang-clang-repl-17-cppyy os: macos-14 compiler: clang @@ -193,6 +240,19 @@ jobs: cling-version: '1.0' cppyy: On xeus-clang-repl: On + - name: osx13-x86-clang-clang-repl-18-cppyy + os: macos-13 + compiler: clang + clang-runtime: '18' + cling: Off + cppyy: On + - name: osx13-x86-clang-clang-repl-18-xeus-clang-repl + os: macos-13 + compiler: clang + clang-runtime: '18' + cling: Off + cppyy: On + xeus-clang-repl: On - name: osx13-x86-clang-clang-repl-17-cppyy os: macos-13 compiler: clang @@ -454,8 +514,11 @@ jobs: cmake --build . --target gtest_main --parallel ${{ env.ncpus }} else # Apply patches - git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch - echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" + llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]') + if [[ "${llvm_vers}" != "18" ]]; then + git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch + echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" + fi cd build cmake -DLLVM_ENABLE_PROJECTS="clang;lld" \ -DLLVM_TARGETS_TO_BUILD="WebAssembly;host;NVPTX" \ @@ -526,7 +589,7 @@ jobs: git apply -v clang16-2-CUDA.patch git apply -v clang16-3-WeakRef.patch } - elseif ( "${{ matrix.clang-runtime }}" -imatch "16" ) + elseif ( "${{ matrix.clang-runtime }}" -imatch "17" ) { git apply -v clang17-1-NewOperator.patch } @@ -920,6 +983,11 @@ jobs: fail-fast: false matrix: include: + - name: ubu22-x86-gcc12-clang-repl-18-emscripten_wasm + os: ubuntu-22.04 + compiler: gcc-12 + clang-runtime: '18' + cling: Off - name: ubu22-x86-gcc12-clang-repl-17-emscripten_wasm os: ubuntu-22.04 compiler: gcc-12 @@ -936,6 +1004,11 @@ jobs: clang-runtime: '13' cling: On cling-version: '1.0' + - name: osx14-arm-clang-clang-repl-18-emscripten_wasm + os: macos-14 + compiler: clang + clang-runtime: '18' + cling: Off - name: osx14-arm-clang-clang-repl-17-emscripten_wasm os: macos-14 compiler: clang @@ -952,6 +1025,11 @@ jobs: clang-runtime: '13' cling: On cling-version: '1.0' + - name: osx13-x86-clang-clang-repl-18-emscripten_wasm + os: macos-13 + compiler: clang + clang-runtime: '18' + cling: Off - name: osx13-x86-clang-clang-repl-17-emscripten_wasm os: macos-13 compiler: clang @@ -1081,8 +1159,11 @@ jobs: cmake --build . --target gtest_main --parallel ${{ env.ncpus }} else # Apply patches - git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch - echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" + llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]') + if [[ "${llvm_vers}" != "18" ]]; then + git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch + echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" + fi cd build cmake -DLLVM_ENABLE_PROJECTS="clang;lld" \ -DLLVM_TARGETS_TO_BUILD="WebAssembly;host;NVPTX" \ diff --git a/CMakeLists.txt b/CMakeLists.txt index b8ab68251..55a2f3a99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,11 +56,11 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) ## Define supported version of clang and llvm set(CLANG_MIN_SUPPORTED 13.0) - set(CLANG_MAX_SUPPORTED "17.0.x") - set(CLANG_VERSION_UPPER_BOUND 17.1.0) + set(CLANG_MAX_SUPPORTED "18.1.x") + set(CLANG_VERSION_UPPER_BOUND 19.0.0) set(LLVM_MIN_SUPPORTED 13.0) - set(LLVM_MAX_SUPPORTED "17.0.x") - set(LLVM_VERSION_UPPER_BOUND 17.1.0) + set(LLVM_MAX_SUPPORTED "18.1.x") + set(LLVM_VERSION_UPPER_BOUND 19.0.0) ## Set Cmake packages search order diff --git a/lib/Interpreter/DynamicLibraryManager.cpp b/lib/Interpreter/DynamicLibraryManager.cpp index 6ec0e329b..d2cf5a172 100644 --- a/lib/Interpreter/DynamicLibraryManager.cpp +++ b/lib/Interpreter/DynamicLibraryManager.cpp @@ -69,12 +69,14 @@ namespace Cpp { for (const std::string& P : SysPaths) addSearchPath(P, /*IsUser*/ false); } - +#if LLVM_VERSION_MAJOR < 18 +#define starts_with_insensitive startswith_insensitive +#endif ///\returns substitution of pattern in the front of original with replacement /// Example: substFront("@rpath/abc", "@rpath/", "/tmp") -> "/tmp/abc" static std::string substFront(StringRef original, StringRef pattern, StringRef replacement) { - if (!original.startswith_insensitive(pattern)) + if (!original.starts_with_insensitive(pattern)) return original.str(); SmallString<512> result(replacement); result.append(original.drop_front(pattern.size())); @@ -300,7 +302,7 @@ namespace Cpp { // Subst all known linker variables ($origin, @rpath, etc.) #ifdef __APPLE__ // On MacOS @rpath is preplaced by all paths in RPATH one by one. - if (libStem.startswith_insensitive("@rpath")) { + if (libStem.starts_with_insensitive("@rpath")) { for (auto& P : RPath) { std::string result = substFront(libStem, "@rpath", P); if (isSharedLibrary(result))