From af6b0fce736cc241172acb88a2767862c1fed3d3 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Tue, 15 Jul 2025 17:05:24 +0100 Subject: [PATCH 01/15] Make CppInterOp llvm 21 compatible --- .github/workflows/emscripten.yml | 59 ++++++++++++++++++- .github/workflows/main.yml | 46 +++++++++++++++ CMakeLists.txt | 12 ++-- lib/CppInterOp/Compatibility.h | 11 ++++ lib/CppInterOp/CppInterOp.cpp | 6 +- ...ws-emscripten-clang21-1-CrossCompile.patch | 20 +++++++ ...1-2-shift-temporary-files-to-tmp-dir.patch | 15 +++++ 7 files changed, 159 insertions(+), 10 deletions(-) create mode 100644 patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch create mode 100644 patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 98cc10ef3..3b0e60a42 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -77,6 +77,34 @@ jobs: llvm_enable_projects: "clang;lld" llvm_targets_to_build: "WebAssembly" emsdk_ver: "3.1.73" + - name: ubu24-arm-clang-repl-21-emscripten + os: ubuntu-24.04-arm + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.73" + - name: osx15-arm-clang-repl-21-emscripten + os: macos-15 + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.73" + - name: ubu24-x86-clang-repl-21-emscripten + os: ubuntu-24.04 + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.73" + - name: win2025-x86-clang-repl-21-emscripten + os: windows-2025 + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.73" steps: - uses: actions/checkout@v4 @@ -199,7 +227,7 @@ jobs: else # Apply patches llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]') - if [[ "${llvm_vers}" == "19" || "${llvm_vers}" == "20" ]]; then + if [[ "${llvm_vers}" == "19" || "${llvm_vers}" == "20" || "${llvm_vers}" == "21" ]]; then git apply -v ../patches/llvm/emscripten-clang${{ matrix.clang-runtime }}-*.patch echo "Apply emscripten-clang${{ matrix.clang-runtime }}-*.patch patches:" fi @@ -321,6 +349,11 @@ jobs: git apply -v emscripten-clang20-2-shift-temporary-files-to-tmp-dir.patch git apply -v emscripten-clang20-3-enable_exception_handling.patch } + elseif ( "${{ matrix.clang-runtime }}" -imatch "21" ) + { + git apply -v Windows-emscripten-clang21-1-CrossCompile.patch + git apply -v emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch + } cd build echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" emcmake cmake -DCMAKE_BUILD_TYPE=Release ` @@ -431,6 +464,30 @@ jobs: cling: Off micromamba_shell_init: powershell emsdk_ver: "3.1.73" + - name: ubu24-x86-clang-repl-21-emscripten_wasm + os: ubuntu-24.04 + clang-runtime: '21' + cling: Off + micromamba_shell_init: bash + emsdk_ver: "3.1.73" + - name: osx15-arm-clang-repl-21-emscripten_wasm + os: macos-15 + clang-runtime: '21' + cling: Off + micromamba_shell_init: bash + emsdk_ver: "3.1.73" + - name: ubu24-arm-clang-repl-21-emscripten_wasm + os: ubuntu-24.04-arm + clang-runtime: '21' + cling: Off + micromamba_shell_init: bash + emsdk_ver: "3.1.73" + - name: win2025-x86-clang-repl-21-emscripten + os: windows-2025 + clang-runtime: '21' + cling: Off + micromamba_shell_init: powershell + emsdk_ver: "3.1.73" steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc40f0bea..605780436 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,14 @@ jobs: matrix: include: # Ubuntu Arm Jobs + - name: ubu24-arm-gcc12-clang-repl-21 + os: ubuntu-24.04-arm + compiler: gcc-12 + clang-runtime: '21' + cling: Off + cppyy: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" - name: ubu22-arm-gcc12-clang-repl-20-coverage os: ubuntu-22.04-arm compiler: gcc-12 @@ -66,6 +74,14 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # Ubuntu X86 Jobs + - name: ubu24-x86-gcc12-clang-repl-21 + os: ubuntu-24.04 + compiler: gcc-12 + clang-runtime: '21' + cling: Off + cppyy: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" - name: ubu24-x86-gcc12-clang-repl-20 os: ubuntu-24.04 compiler: gcc-12 @@ -100,6 +116,14 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # MacOS Arm Jobs + - name: osx15-arm-clang-clang-repl-21 + os: macos-15 + compiler: clang + clang-runtime: '21' + cling: Off + cppyy: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" - name: osx15-arm-clang-clang-repl-20 os: macos-15 compiler: clang @@ -134,6 +158,14 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # MacOS X86 Jobs + - name: osx13-x86-clang-clang-repl-21 + os: macos-13 + compiler: clang + clang-runtime: '21' + cling: Off + cppyy: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" - name: osx13-x86-clang-clang-repl-20 os: macos-13 compiler: clang @@ -168,6 +200,13 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # Windows Arm Jobs + - name: win11-msvc-clang-repl-21 + os: windows-11-arm + compiler: msvc + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" - name: win11-msvc-clang-repl-20 os: windows-11-arm compiler: msvc @@ -184,6 +223,13 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # Windows X86 Jobs + - name: win2025-msvc-clang-repl-21 + os: windows-2025 + compiler: msvc + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" - name: win2025-msvc-clang-repl-20 os: windows-2025 compiler: msvc diff --git a/CMakeLists.txt b/CMakeLists.txt index 981c57ced..cc8d38617 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,14 +68,14 @@ include(GNUInstallDirs) ## Define supported version of clang and llvm set(CLANG_MIN_SUPPORTED 18.0) - set(CLANG_MAX_SUPPORTED "20.1.x") - set(CLANG_VERSION_UPPER_BOUND 21.0.0) + set(CLANG_MAX_SUPPORTED "21.1.x") + set(CLANG_VERSION_UPPER_BOUND 22.0.0) set(LLD_MIN_SUPPORTED 18.0) - set(LLD_MAX_SUPPORTED "20.1.x") - set(LLD_VERSION_UPPER_BOUND 21.0.0) + set(LLD_MAX_SUPPORTED "21.1.x") + set(LLD_VERSION_UPPER_BOUND 22.0.0) set(LLVM_MIN_SUPPORTED 18.0) - set(LLVM_MAX_SUPPORTED "20.1.x") - set(LLVM_VERSION_UPPER_BOUND 21.0.0) + set(LLVM_MAX_SUPPORTED "21.1.x") + set(LLVM_VERSION_UPPER_BOUND 22.0.0) ## Set Cmake packages search order diff --git a/lib/CppInterOp/Compatibility.h b/lib/CppInterOp/Compatibility.h index ddee92574..f82d67453 100644 --- a/lib/CppInterOp/Compatibility.h +++ b/lib/CppInterOp/Compatibility.h @@ -31,6 +31,17 @@ static inline char* GetEnv(const char* Var_Name) { #endif } +#if CLANG_VERSION_MAJOR < 21 +#define clang_LookupResult_Found clang::LookupResult::Found +#define clang_LookupResult_Not_Found clang::LookupResult::NotFound +#define clang_LookupResult_Found_Overloaded clang::LookupResult::FoundOverloaded +#else +#define clang_LookupResult_Found clang::LookupResultKind::Found +#define clang_LookupResult_Not_Found clang::LookupResultKind::NotFound +#define clang_LookupResult_Found_Overloaded \ + clang::LookupResultKind::FoundOverloaded +#endif + #if CLANG_VERSION_MAJOR < 19 #define Template_Deduction_Result Sema::TemplateDeductionResult #define Template_Deduction_Result_Success \ diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index 01a14ce03..b6e16323b 100755 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -1135,16 +1135,16 @@ bool GetClassTemplatedMethods(const std::string& name, TCppScope_t parent, auto* DC = clang::Decl::castToDeclContext(D); Cpp_utils::Lookup::Named(&S, R, DC); - if (R.getResultKind() == clang::LookupResult::NotFound && funcs.empty()) + if (R.getResultKind() == clang_LookupResult_Not_Found && funcs.empty()) return false; // Distinct match, single Decl - else if (R.getResultKind() == clang::LookupResult::Found) { + else if (R.getResultKind() == clang_LookupResult_Found) { if (IsTemplatedFunction(R.getFoundDecl())) funcs.push_back(R.getFoundDecl()); } // Loop over overload set - else if (R.getResultKind() == clang::LookupResult::FoundOverloaded) { + else if (R.getResultKind() == clang_LookupResult_Found_Overloaded) { for (auto* Found : R) if (IsTemplatedFunction(Found)) funcs.push_back(Found); diff --git a/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch b/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch new file mode 100644 index 000000000..a1ffeccc8 --- /dev/null +++ b/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch @@ -0,0 +1,20 @@ +diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake +index 39b4abaa0..474ceddbb 100644 +--- a/llvm/cmake/modules/CrossCompile.cmake ++++ b/llvm/cmake/modules/CrossCompile.cmake +@@ -74,10 +74,12 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype) + endif() + + add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt +- COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ++ COMMAND ${CMAKE_COMMAND} -G Ninja + -DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}" +- -DCMAKE_C_COMPILER_LAUNCHER="${CMAKE_C_COMPILER_LAUNCHER}" +- -DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}" ++ -DCMAKE_C_COMPILER="clang-cl" ++ -DCMAKE_CXX_COMPILER="clang-cl" ++ -DCMAKE_ASM_MASM_COMPILER=llvm-ml ++ -DCMAKE_ASM_MASM_FLAGS="-m64" + ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_CURRENT_SOURCE_DIR} + ${CROSS_TOOLCHAIN_FLAGS_${project_name}_${target_name}} + -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE diff --git a/patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch b/patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch new file mode 100644 index 000000000..32ac45c13 --- /dev/null +++ b/patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch @@ -0,0 +1,15 @@ +diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp +index aa10b160ccf8..184867e2b55f 100644 +--- a/clang/lib/Interpreter/Wasm.cpp ++++ b/clang/lib/Interpreter/Wasm.cpp +@@ -76,8 +76,8 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) { + llvm::TargetMachine *TargetMachine = Target->createTargetMachine( + PTU.TheModule->getTargetTriple(), "", "", TO, llvm::Reloc::Model::PIC_); + PTU.TheModule->setDataLayout(TargetMachine->createDataLayout()); +- std::string ObjectFileName = PTU.TheModule->getName().str() + ".o"; +- std::string BinaryFileName = PTU.TheModule->getName().str() + ".wasm"; ++ std::string ObjectFileName = "/tmp/" + PTU.TheModule->getName().str() + ".o"; ++ std::string BinaryFileName = "/tmp/" + PTU.TheModule->getName().str() + ".wasm"; + + std::error_code Error; + llvm::raw_fd_ostream ObjectFileOutput(llvm::StringRef(ObjectFileName), Error); From 3d74a26394a8e27f7a9129a64d3bac284c076cac Mon Sep 17 00:00:00 2001 From: mcbarton Date: Tue, 15 Jul 2025 21:03:13 +0100 Subject: [PATCH 02/15] Update Windows-emscripten-clang21-1-CrossCompile.patch --- .../llvm/Windows-emscripten-clang21-1-CrossCompile.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch b/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch index a1ffeccc8..00e0aef6f 100644 --- a/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch +++ b/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch @@ -8,9 +8,9 @@ index 39b4abaa0..474ceddbb 100644 add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt - COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" + COMMAND ${CMAKE_COMMAND} -G Ninja - -DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}" -- -DCMAKE_C_COMPILER_LAUNCHER="${CMAKE_C_COMPILER_LAUNCHER}" -- -DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}" + "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" +- "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}" +- "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}" + -DCMAKE_C_COMPILER="clang-cl" + -DCMAKE_CXX_COMPILER="clang-cl" + -DCMAKE_ASM_MASM_COMPILER=llvm-ml From aef6370df2014afc6d60a07699f94883f664ac00 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Wed, 16 Jul 2025 09:20:19 +0100 Subject: [PATCH 03/15] Update exports.ld --- lib/CppInterOp/exports.ld | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/CppInterOp/exports.ld b/lib/CppInterOp/exports.ld index 49b7b0d83..c1c4e59e8 100644 --- a/lib/CppInterOp/exports.ld +++ b/lib/CppInterOp/exports.ld @@ -50,4 +50,5 @@ -Wl,--export=_ZNK5clang4Type14isFloatingTypeEv -Wl,--export=_ZNK5clang12FunctionDecl12getNumParamsEv -Wl,--export=__clang_Interpreter_SetValueNoAlloc --Wl,--export=__clang_Interpreter_SetValueWithAlloc \ No newline at end of file +-Wl,--export=__clang_Interpreter_SetValueWithAlloc +-Wl,--export=_ZN5clang11Interpreter6createENSt3__210unique_ptrINS_16CompilerInstanceENS1_14default_deleteIS3_EEEENS2_IN4llvm3orc12LLJITBuilderENS4_IS9_EEEE From 2a280d1536a4c0c89fc159c8e0f68624aee61a10 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Wed, 16 Jul 2025 10:59:46 +0100 Subject: [PATCH 04/15] Update exports.ld --- lib/CppInterOp/exports.ld | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/CppInterOp/exports.ld b/lib/CppInterOp/exports.ld index c1c4e59e8..65c3b439b 100644 --- a/lib/CppInterOp/exports.ld +++ b/lib/CppInterOp/exports.ld @@ -51,4 +51,5 @@ -Wl,--export=_ZNK5clang12FunctionDecl12getNumParamsEv -Wl,--export=__clang_Interpreter_SetValueNoAlloc -Wl,--export=__clang_Interpreter_SetValueWithAlloc --Wl,--export=_ZN5clang11Interpreter6createENSt3__210unique_ptrINS_16CompilerInstanceENS1_14default_deleteIS3_EEEENS2_IN4llvm3orc12LLJITBuilderENS4_IS9_EEEE +-Wl,--export=_ZN5clang11Interpreter6createENSt3__210unique_ptrINS_16CompilerInstanceENS1_14default_deleteIS3_EEEENS2_IN4llvm3orc12LLJITBuilderENS4_IS9_EEEE +-Wl,--export=_ZNK5clang13CXXRecordDecl19isInjectedClassNameEv From bbd2a48422d759ba2bb72b6d315506790c947dae Mon Sep 17 00:00:00 2001 From: mcbarton Date: Tue, 9 Sep 2025 16:02:20 +0100 Subject: [PATCH 05/15] Define Print_Canonical_Types for llvm 21 compatibility --- lib/CppInterOp/Compatibility.h | 6 ++++++ lib/CppInterOp/CppInterOp.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/CppInterOp/Compatibility.h b/lib/CppInterOp/Compatibility.h index fe8eed44c..b1dc2daa9 100644 --- a/lib/CppInterOp/Compatibility.h +++ b/lib/CppInterOp/Compatibility.h @@ -31,6 +31,12 @@ static inline char* GetEnv(const char* Var_Name) { #endif } +#if CLANG_VERSION_MAJOR < 21 +#define Print_Canonical_Types PrintCanonicalTypes +#else +#define Print_Canonical_Types PrintAsCanonical +#endif + #if CLANG_VERSION_MAJOR < 21 #define clang_LookupResult_Found clang::LookupResult::Found #define clang_LookupResult_Not_Found clang::LookupResult::NotFound diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index 819ec72c1..6613e2546 100755 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -1954,7 +1954,7 @@ static void GetDeclName(const clang::Decl* D, ASTContext& Context, PrintingPolicy Policy(Context.getPrintingPolicy()); Policy.SuppressTagKeyword = true; Policy.SuppressUnwrittenScope = true; - Policy.PrintCanonicalTypes = true; + Policy.Print_Canonical_Types = true; if (const TypeDecl* TD = dyn_cast(D)) { // This is a class, struct, or union member. QualType QT; From 68a3695b9701bb4be192dc22143409d88bb59741 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Tue, 15 Jul 2025 17:05:24 +0100 Subject: [PATCH 06/15] Make CppInterOp llvm 21 compatible --- .github/workflows/emscripten.yml | 59 ++++++++++++++++++- .github/workflows/main.yml | 46 +++++++++++++++ CMakeLists.txt | 12 ++-- lib/CppInterOp/Compatibility.h | 11 ++++ lib/CppInterOp/CppInterOp.cpp | 6 +- ...ws-emscripten-clang21-1-CrossCompile.patch | 20 +++++++ ...1-2-shift-temporary-files-to-tmp-dir.patch | 15 +++++ 7 files changed, 159 insertions(+), 10 deletions(-) create mode 100644 patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch create mode 100644 patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index daa4d8152..3c27a20b1 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -77,6 +77,34 @@ jobs: llvm_enable_projects: "clang;lld" llvm_targets_to_build: "WebAssembly" emsdk_ver: "3.1.73" + - name: ubu24-arm-clang-repl-21-emscripten + os: ubuntu-24.04-arm + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.73" + - name: osx15-arm-clang-repl-21-emscripten + os: macos-15 + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.73" + - name: ubu24-x86-clang-repl-21-emscripten + os: ubuntu-24.04 + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.73" + - name: win2025-x86-clang-repl-21-emscripten + os: windows-2025 + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.73" steps: - uses: actions/checkout@v5 @@ -201,7 +229,7 @@ jobs: else # Apply patches llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]') - if [[ "${llvm_vers}" == "19" || "${llvm_vers}" == "20" ]]; then + if [[ "${llvm_vers}" == "19" || "${llvm_vers}" == "20" || "${llvm_vers}" == "21" ]]; then git apply -v ../patches/llvm/emscripten-clang${{ matrix.clang-runtime }}-*.patch echo "Apply emscripten-clang${{ matrix.clang-runtime }}-*.patch patches:" fi @@ -327,6 +355,11 @@ jobs: git apply -v emscripten-clang20-2-shift-temporary-files-to-tmp-dir.patch git apply -v emscripten-clang20-3-enable_exception_handling.patch } + elseif ( "${{ matrix.clang-runtime }}" -imatch "21" ) + { + git apply -v Windows-emscripten-clang21-1-CrossCompile.patch + git apply -v emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch + } cd build echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" emcmake cmake -DCMAKE_BUILD_TYPE=Release ` @@ -439,6 +472,30 @@ jobs: cling: Off micromamba_shell_init: powershell emsdk_ver: "3.1.73" + - name: ubu24-x86-clang-repl-21-emscripten_wasm + os: ubuntu-24.04 + clang-runtime: '21' + cling: Off + micromamba_shell_init: bash + emsdk_ver: "3.1.73" + - name: osx15-arm-clang-repl-21-emscripten_wasm + os: macos-15 + clang-runtime: '21' + cling: Off + micromamba_shell_init: bash + emsdk_ver: "3.1.73" + - name: ubu24-arm-clang-repl-21-emscripten_wasm + os: ubuntu-24.04-arm + clang-runtime: '21' + cling: Off + micromamba_shell_init: bash + emsdk_ver: "3.1.73" + - name: win2025-x86-clang-repl-21-emscripten + os: windows-2025 + clang-runtime: '21' + cling: Off + micromamba_shell_init: powershell + emsdk_ver: "3.1.73" steps: - uses: actions/checkout@v5 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20232cca1..ace7a1ead 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,14 @@ jobs: matrix: include: # Ubuntu Arm Jobs + - name: ubu24-arm-gcc12-clang-repl-21 + os: ubuntu-24.04-arm + compiler: gcc-12 + clang-runtime: '21' + cling: Off + cppyy: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" - name: ubu22-arm-gcc12-clang-repl-20-coverage os: ubuntu-22.04-arm compiler: gcc-12 @@ -66,6 +74,14 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # Ubuntu X86 Jobs + - name: ubu24-x86-gcc12-clang-repl-21 + os: ubuntu-24.04 + compiler: gcc-12 + clang-runtime: '21' + cling: Off + cppyy: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" - name: ubu24-x86-gcc12-clang-repl-20 os: ubuntu-24.04 compiler: gcc-12 @@ -100,6 +116,14 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # MacOS Arm Jobs + - name: osx15-arm-clang-clang-repl-21 + os: macos-15 + compiler: clang + clang-runtime: '21' + cling: Off + cppyy: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" - name: osx15-arm-clang-clang-repl-20 os: macos-15 compiler: clang @@ -134,6 +158,14 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # MacOS X86 Jobs + - name: osx13-x86-clang-clang-repl-21 + os: macos-13 + compiler: clang + clang-runtime: '21' + cling: Off + cppyy: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host" - name: osx13-x86-clang-clang-repl-20 os: macos-13 compiler: clang @@ -168,6 +200,13 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # Windows Arm Jobs + - name: win11-msvc-clang-repl-21 + os: windows-11-arm + compiler: msvc + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" - name: win11-msvc-clang-repl-20 os: windows-11-arm compiler: msvc @@ -184,6 +223,13 @@ jobs: llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" # Windows X86 Jobs + - name: win2025-msvc-clang-repl-21 + os: windows-2025 + compiler: msvc + clang-runtime: '21' + cling: Off + llvm_enable_projects: "clang" + llvm_targets_to_build: "host;NVPTX" - name: win2025-msvc-clang-repl-20 os: windows-2025 compiler: msvc diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d1aa034d..1850ddcc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,14 +68,14 @@ include(GNUInstallDirs) ## Define supported version of clang and llvm set(CLANG_MIN_SUPPORTED 18.0) - set(CLANG_MAX_SUPPORTED "20.1.x") - set(CLANG_VERSION_UPPER_BOUND 21.0.0) + set(CLANG_MAX_SUPPORTED "21.1.x") + set(CLANG_VERSION_UPPER_BOUND 22.0.0) set(LLD_MIN_SUPPORTED 18.0) - set(LLD_MAX_SUPPORTED "20.1.x") - set(LLD_VERSION_UPPER_BOUND 21.0.0) + set(LLD_MAX_SUPPORTED "21.1.x") + set(LLD_VERSION_UPPER_BOUND 22.0.0) set(LLVM_MIN_SUPPORTED 18.0) - set(LLVM_MAX_SUPPORTED "20.1.x") - set(LLVM_VERSION_UPPER_BOUND 21.0.0) + set(LLVM_MAX_SUPPORTED "21.1.x") + set(LLVM_VERSION_UPPER_BOUND 22.0.0) ## Set Cmake packages search order diff --git a/lib/CppInterOp/Compatibility.h b/lib/CppInterOp/Compatibility.h index 24c822dec..fe8eed44c 100644 --- a/lib/CppInterOp/Compatibility.h +++ b/lib/CppInterOp/Compatibility.h @@ -31,6 +31,17 @@ static inline char* GetEnv(const char* Var_Name) { #endif } +#if CLANG_VERSION_MAJOR < 21 +#define clang_LookupResult_Found clang::LookupResult::Found +#define clang_LookupResult_Not_Found clang::LookupResult::NotFound +#define clang_LookupResult_Found_Overloaded clang::LookupResult::FoundOverloaded +#else +#define clang_LookupResult_Found clang::LookupResultKind::Found +#define clang_LookupResult_Not_Found clang::LookupResultKind::NotFound +#define clang_LookupResult_Found_Overloaded \ + clang::LookupResultKind::FoundOverloaded +#endif + #if CLANG_VERSION_MAJOR < 19 #define Template_Deduction_Result Sema::TemplateDeductionResult #define Template_Deduction_Result_Success \ diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index f1527b4a8..896a20e32 100755 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -1307,16 +1307,16 @@ bool GetClassTemplatedMethods(const std::string& name, TCppScope_t parent, auto* DC = clang::Decl::castToDeclContext(D); Cpp_utils::Lookup::Named(&S, R, DC); - if (R.getResultKind() == clang::LookupResult::NotFound && funcs.empty()) + if (R.getResultKind() == clang_LookupResult_Not_Found && funcs.empty()) return false; // Distinct match, single Decl - else if (R.getResultKind() == clang::LookupResult::Found) { + else if (R.getResultKind() == clang_LookupResult_Found) { if (IsTemplatedFunction(R.getFoundDecl())) funcs.push_back(R.getFoundDecl()); } // Loop over overload set - else if (R.getResultKind() == clang::LookupResult::FoundOverloaded) { + else if (R.getResultKind() == clang_LookupResult_Found_Overloaded) { for (auto* Found : R) if (IsTemplatedFunction(Found)) funcs.push_back(Found); diff --git a/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch b/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch new file mode 100644 index 000000000..a1ffeccc8 --- /dev/null +++ b/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch @@ -0,0 +1,20 @@ +diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake +index 39b4abaa0..474ceddbb 100644 +--- a/llvm/cmake/modules/CrossCompile.cmake ++++ b/llvm/cmake/modules/CrossCompile.cmake +@@ -74,10 +74,12 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype) + endif() + + add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt +- COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ++ COMMAND ${CMAKE_COMMAND} -G Ninja + -DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}" +- -DCMAKE_C_COMPILER_LAUNCHER="${CMAKE_C_COMPILER_LAUNCHER}" +- -DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}" ++ -DCMAKE_C_COMPILER="clang-cl" ++ -DCMAKE_CXX_COMPILER="clang-cl" ++ -DCMAKE_ASM_MASM_COMPILER=llvm-ml ++ -DCMAKE_ASM_MASM_FLAGS="-m64" + ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_CURRENT_SOURCE_DIR} + ${CROSS_TOOLCHAIN_FLAGS_${project_name}_${target_name}} + -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE diff --git a/patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch b/patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch new file mode 100644 index 000000000..32ac45c13 --- /dev/null +++ b/patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch @@ -0,0 +1,15 @@ +diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp +index aa10b160ccf8..184867e2b55f 100644 +--- a/clang/lib/Interpreter/Wasm.cpp ++++ b/clang/lib/Interpreter/Wasm.cpp +@@ -76,8 +76,8 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) { + llvm::TargetMachine *TargetMachine = Target->createTargetMachine( + PTU.TheModule->getTargetTriple(), "", "", TO, llvm::Reloc::Model::PIC_); + PTU.TheModule->setDataLayout(TargetMachine->createDataLayout()); +- std::string ObjectFileName = PTU.TheModule->getName().str() + ".o"; +- std::string BinaryFileName = PTU.TheModule->getName().str() + ".wasm"; ++ std::string ObjectFileName = "/tmp/" + PTU.TheModule->getName().str() + ".o"; ++ std::string BinaryFileName = "/tmp/" + PTU.TheModule->getName().str() + ".wasm"; + + std::error_code Error; + llvm::raw_fd_ostream ObjectFileOutput(llvm::StringRef(ObjectFileName), Error); From a6919e748214d03f324c847af2936e0fe89f3a6f Mon Sep 17 00:00:00 2001 From: mcbarton Date: Tue, 15 Jul 2025 21:03:13 +0100 Subject: [PATCH 07/15] Update Windows-emscripten-clang21-1-CrossCompile.patch --- .../llvm/Windows-emscripten-clang21-1-CrossCompile.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch b/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch index a1ffeccc8..00e0aef6f 100644 --- a/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch +++ b/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch @@ -8,9 +8,9 @@ index 39b4abaa0..474ceddbb 100644 add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt - COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" + COMMAND ${CMAKE_COMMAND} -G Ninja - -DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}" -- -DCMAKE_C_COMPILER_LAUNCHER="${CMAKE_C_COMPILER_LAUNCHER}" -- -DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}" + "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" +- "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}" +- "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}" + -DCMAKE_C_COMPILER="clang-cl" + -DCMAKE_CXX_COMPILER="clang-cl" + -DCMAKE_ASM_MASM_COMPILER=llvm-ml From a4801b4edf14f974a293fc7d77181e5077e7419c Mon Sep 17 00:00:00 2001 From: mcbarton Date: Wed, 16 Jul 2025 09:20:19 +0100 Subject: [PATCH 08/15] Update exports.ld --- lib/CppInterOp/exports.ld | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/CppInterOp/exports.ld b/lib/CppInterOp/exports.ld index e22490f2a..dbe06bb32 100644 --- a/lib/CppInterOp/exports.ld +++ b/lib/CppInterOp/exports.ld @@ -51,4 +51,6 @@ -Wl,--export=_ZNK5clang12FunctionDecl12getNumParamsEv -Wl,--export=__clang_Interpreter_SetValueNoAlloc -Wl,--export=__clang_Interpreter_SetValueWithAlloc +-Wl,--export=_ZN5clang11Interpreter6createENSt3__210unique_ptrINS_16CompilerInstanceENS1_14default_deleteIS3_EEEENS2_IN4llvm3orc12LLJITBuilderENS4_IS9_EEEE + -Wl,--export=_ZN4llvm15SmallVectorBaseIjE8set_sizeEm \ No newline at end of file From 113b7a6732e21225d648f13868dd9759cf73f530 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Wed, 16 Jul 2025 10:59:46 +0100 Subject: [PATCH 09/15] Update exports.ld --- lib/CppInterOp/exports.ld | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/CppInterOp/exports.ld b/lib/CppInterOp/exports.ld index dbe06bb32..918c6fd34 100644 --- a/lib/CppInterOp/exports.ld +++ b/lib/CppInterOp/exports.ld @@ -51,6 +51,7 @@ -Wl,--export=_ZNK5clang12FunctionDecl12getNumParamsEv -Wl,--export=__clang_Interpreter_SetValueNoAlloc -Wl,--export=__clang_Interpreter_SetValueWithAlloc --Wl,--export=_ZN5clang11Interpreter6createENSt3__210unique_ptrINS_16CompilerInstanceENS1_14default_deleteIS3_EEEENS2_IN4llvm3orc12LLJITBuilderENS4_IS9_EEEE +-Wl,--export=_ZN5clang11Interpreter6createENSt3__210unique_ptrINS_16CompilerInstanceENS1_14default_deleteIS3_EEEENS2_IN4llvm3orc12LLJITBuilderENS4_IS9_EEEE +-Wl,--export=_ZNK5clang13CXXRecordDecl19isInjectedClassNameEv -Wl,--export=_ZN4llvm15SmallVectorBaseIjE8set_sizeEm \ No newline at end of file From ed5b80c2bf99fc964136965d4304955ef503d7cd Mon Sep 17 00:00:00 2001 From: mcbarton Date: Tue, 9 Sep 2025 16:02:20 +0100 Subject: [PATCH 10/15] Define Print_Canonical_Types for llvm 21 compatibility --- lib/CppInterOp/Compatibility.h | 6 ++++++ lib/CppInterOp/CppInterOp.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/CppInterOp/Compatibility.h b/lib/CppInterOp/Compatibility.h index fe8eed44c..b1dc2daa9 100644 --- a/lib/CppInterOp/Compatibility.h +++ b/lib/CppInterOp/Compatibility.h @@ -31,6 +31,12 @@ static inline char* GetEnv(const char* Var_Name) { #endif } +#if CLANG_VERSION_MAJOR < 21 +#define Print_Canonical_Types PrintCanonicalTypes +#else +#define Print_Canonical_Types PrintAsCanonical +#endif + #if CLANG_VERSION_MAJOR < 21 #define clang_LookupResult_Found clang::LookupResult::Found #define clang_LookupResult_Not_Found clang::LookupResult::NotFound diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index 896a20e32..0290dbe01 100755 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -2108,7 +2108,7 @@ static void GetDeclName(const clang::Decl* D, ASTContext& Context, PrintingPolicy Policy(Context.getPrintingPolicy()); Policy.SuppressTagKeyword = true; Policy.SuppressUnwrittenScope = true; - Policy.PrintCanonicalTypes = true; + Policy.Print_Canonical_Types = true; if (const TypeDecl* TD = dyn_cast(D)) { // This is a class, struct, or union member. QualType QT; From 19e195177773c1dc599a417b6d152372d89b5a0f Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Mon, 15 Sep 2025 10:21:26 +0200 Subject: [PATCH 11/15] fix instantiation of templated class instantiate templated classes to TSK_ExplicitInstantiationDefinition --- lib/CppInterOp/Compatibility.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/CppInterOp/Compatibility.h b/lib/CppInterOp/Compatibility.h index b1dc2daa9..c6ab5cc70 100644 --- a/lib/CppInterOp/Compatibility.h +++ b/lib/CppInterOp/Compatibility.h @@ -429,11 +429,11 @@ inline void InstantiateClassTemplateSpecialization( #if CLANG_VERSION_MAJOR < 20 interp.getSema().InstantiateClassTemplateSpecialization( clang::SourceLocation::getFromRawEncoding(1), CTSD, - clang::TemplateSpecializationKind::TSK_Undeclared, /*Complain=*/true); + clang::TemplateSpecializationKind::TSK_ExplicitInstantiationDefinition, /*Complain=*/true); #else interp.getSema().InstantiateClassTemplateSpecialization( clang::SourceLocation::getFromRawEncoding(1), CTSD, - clang::TemplateSpecializationKind::TSK_Undeclared, /*Complain=*/true, + clang::TemplateSpecializationKind::TSK_ExplicitInstantiationDefinition, /*Complain=*/true, /*PrimaryHasMatchedPackOnParmToNonPackOnArg=*/false); #endif } From eaf352c49e2feded890c916f69ad5749a4a1ab76 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Mon, 15 Sep 2025 10:26:26 +0200 Subject: [PATCH 12/15] fix instantiation of templated class instantiate templated classes to TSK_ExplicitInstantiationDefinition --- lib/CppInterOp/Compatibility.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/CppInterOp/Compatibility.h b/lib/CppInterOp/Compatibility.h index b1dc2daa9..42463c0b9 100644 --- a/lib/CppInterOp/Compatibility.h +++ b/lib/CppInterOp/Compatibility.h @@ -429,11 +429,13 @@ inline void InstantiateClassTemplateSpecialization( #if CLANG_VERSION_MAJOR < 20 interp.getSema().InstantiateClassTemplateSpecialization( clang::SourceLocation::getFromRawEncoding(1), CTSD, - clang::TemplateSpecializationKind::TSK_Undeclared, /*Complain=*/true); + clang::TemplateSpecializationKind::TSK_ExplicitInstantiationDefinition, + /*Complain=*/true); #else interp.getSema().InstantiateClassTemplateSpecialization( clang::SourceLocation::getFromRawEncoding(1), CTSD, - clang::TemplateSpecializationKind::TSK_Undeclared, /*Complain=*/true, + clang::TemplateSpecializationKind::TSK_ExplicitInstantiationDefinition, + /*Complain=*/true, /*PrimaryHasMatchedPackOnParmToNonPackOnArg=*/false); #endif } From bbbf6d0210107995bfc1057d72b0a2354b36dba7 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Mon, 15 Sep 2025 21:56:11 +0100 Subject: [PATCH 13/15] Apply some PR comments --- .github/workflows/emscripten.yml | 4 ++-- Emscripten-build-instructions.md | 14 ++++++------- README.md | 8 ++++---- ...ws-emscripten-clang21-1-CrossCompile.patch | 20 ------------------- ...-1-shift-temporary-files-to-tmp-dir.patch} | 0 5 files changed, 13 insertions(+), 33 deletions(-) delete mode 100644 patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch rename patches/llvm/{emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch => emscripten-clang21-1-shift-temporary-files-to-tmp-dir.patch} (100%) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index e4b2d8825..1f8648015 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -355,8 +355,8 @@ jobs: } elseif ( "${{ matrix.clang-runtime }}" -imatch "21" ) { - git apply -v Windows-emscripten-clang21-1-CrossCompile.patch - git apply -v emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch + git apply -v emscripten-clang21-1-shift-temporary-files-to-tmp-dir.patch + git apply -v emscripten-clang21-2-enable_exception_handling.patch } cd build echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" diff --git a/Emscripten-build-instructions.md b/Emscripten-build-instructions.md index 0854fed2d..f7c40673b 100644 --- a/Emscripten-build-instructions.md +++ b/Emscripten-build-instructions.md @@ -42,11 +42,11 @@ $env:PWD_DIR= $PWD.Path $env:SYSROOT_PATH="$env:EMSDK/upstream/emscripten/cache/sysroot" ``` -Now clone the 20.x release of the LLVM project repository and CppInterOp (the building of the emscripten version of llvm can be +Now clone the 21.x release of the LLVM project repository and CppInterOp (the building of the emscripten version of llvm can be avoided by executing micromamba install llvm -c and setting the LLVM_BUILD_DIR/$env:LLVM_BUILD_DIR appropriately) ```bash -git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.git +git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git git clone --depth=1 https://github.com/compiler-research/CppInterOp.git ``` @@ -55,16 +55,16 @@ executing ```bash cd ./llvm-project/ -git apply -v ../CppInterOp/patches/llvm/emscripten-clang20-*.patch +git apply -v ../CppInterOp/patches/llvm/emscripten-clang21-*.patch ``` On Windows execute the following ```powershell cd .\llvm-project\ -cp -r ..\patches\llvm\emscripten-clang20* -git apply -v emscripten-clang20-2-shift-temporary-files-to-tmp-dir.patch -git apply -v emscripten-clang20-3-enable_exception_handling.patch +cp -r ..\patches\llvm\emscripten-clang21* +git apply -v emscripten-clang21-1-shift-temporary-files-to-tmp-dir.patch +git apply -v emscripten-clang21-2-enable_exception_handling.patch ``` We are now in a position to build an emscripten build of llvm by executing the following on Linux @@ -343,7 +343,7 @@ of llvm you are building against) ```bash cd ../.. git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git -export LLVM_VERSION=20 +export LLVM_VERSION=21 cd ./xeus-cpp mkdir build cd build diff --git a/README.md b/README.md index e14a94d94..bd93923eb 100644 --- a/README.md +++ b/README.md @@ -104,10 +104,10 @@ git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git #### Setup Clang-REPL -Clone the 20.x release of the LLVM project repository. +Clone the 1.x release of the LLVM project repository. ```bash -git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.git +git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git cd llvm-project ``` @@ -406,10 +406,10 @@ git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git #### Setup Clang-REPL -Clone the 20.x release of the LLVM project repository. +Clone the 21.x release of the LLVM project repository. ```bash -git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.git +git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git cd llvm-project ``` diff --git a/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch b/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch deleted file mode 100644 index 00e0aef6f..000000000 --- a/patches/llvm/Windows-emscripten-clang21-1-CrossCompile.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake -index 39b4abaa0..474ceddbb 100644 ---- a/llvm/cmake/modules/CrossCompile.cmake -+++ b/llvm/cmake/modules/CrossCompile.cmake -@@ -74,10 +74,12 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype) - endif() - - add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt -- COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -+ COMMAND ${CMAKE_COMMAND} -G Ninja - "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" -- "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}" -- "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}" -+ -DCMAKE_C_COMPILER="clang-cl" -+ -DCMAKE_CXX_COMPILER="clang-cl" -+ -DCMAKE_ASM_MASM_COMPILER=llvm-ml -+ -DCMAKE_ASM_MASM_FLAGS="-m64" - ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_CURRENT_SOURCE_DIR} - ${CROSS_TOOLCHAIN_FLAGS_${project_name}_${target_name}} - -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE diff --git a/patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch b/patches/llvm/emscripten-clang21-1-shift-temporary-files-to-tmp-dir.patch similarity index 100% rename from patches/llvm/emscripten-clang21-2-shift-temporary-files-to-tmp-dir.patch rename to patches/llvm/emscripten-clang21-1-shift-temporary-files-to-tmp-dir.patch From c97eb37d47b8a326032f9a00123083afedca44f0 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Mon, 15 Sep 2025 22:01:56 +0100 Subject: [PATCH 14/15] Updat 1.x to 21.x readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd93923eb..6976c9b1e 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git #### Setup Clang-REPL -Clone the 1.x release of the LLVM project repository. +Clone the 21.x release of the LLVM project repository. ```bash git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git From 541711ea03fbafcb51564a252834cf7471d69299 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Mon, 15 Sep 2025 22:05:24 +0100 Subject: [PATCH 15/15] Update rest of docs for llvm 21 --- docs/DevelopersDocumentation.rst | 4 ++-- docs/Emscripten-build-instructions.rst | 14 +++++++------- docs/InstallationAndUsage.rst | 4 ++-- docs/ReleaseNotes.md | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/DevelopersDocumentation.rst b/docs/DevelopersDocumentation.rst index e586cc5d8..a440e05c6 100644 --- a/docs/DevelopersDocumentation.rst +++ b/docs/DevelopersDocumentation.rst @@ -34,11 +34,11 @@ library Setup Clang-REPL ****************** -Clone the 20.x release of the LLVM project repository. +Clone the 21.x release of the LLVM project repository. .. code:: bash - git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.git + git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git cd llvm-project ****************** diff --git a/docs/Emscripten-build-instructions.rst b/docs/Emscripten-build-instructions.rst index 89e9be0d2..87de691ac 100644 --- a/docs/Emscripten-build-instructions.rst +++ b/docs/Emscripten-build-instructions.rst @@ -57,7 +57,7 @@ and on Windows execute in Powershell $env:PWD_DIR= $PWD.Path $env:SYSROOT_PATH="$env:EMSDK/upstream/emscripten/cache/sysroot" -Now clone the 20.x release of the LLVM project repository and CppInterOp +Now clone the 21.x release of the LLVM project repository and CppInterOp (the building of the emscripten version of llvm can be avoided by executing micromamba install llvm -c and setting the LLVM_BUILD_DIR/$env:LLVM_BUILD_DIR @@ -65,7 +65,7 @@ appropriately) .. code:: bash - git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.git + git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git git clone --depth=1 https://github.com/compiler-research/CppInterOp.git Now move into the cloned llvm-project folder and apply the required patches. On Linux and osx this @@ -74,16 +74,16 @@ executing .. code:: bash cd ./llvm-project/ - git apply -v ../CppInterOp/patches/llvm/emscripten-clang20-*.patch + git apply -v ../CppInterOp/patches/llvm/emscripten-clang21-*.patch On Windows execute the following .. code:: powershell cd .\llvm-project\ - cp -r ..\patches\llvm\emscripten-clang20* - git apply -v emscripten-clang20-2-shift-temporary-files-to-tmp-dir.patch - git apply -v emscripten-clang20-3-enable_exception_handling.patch + cp -r ..\patches\llvm\emscripten-clang21* + git apply -v emscripten-clang21-1-shift-temporary-files-to-tmp-dir.patch + git apply -v emscripten-clang21-2-enable_exception_handling.patch We are now in a position to build an emscripten build of llvm by executing the following on Linux and osx @@ -365,7 +365,7 @@ build folder, you can build the wasm version of xeus-cpp by executing cd ../.. git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git - export LLVM_VERSION=20 + export LLVM_VERSION=21 cd ./xeus-cpp mkdir build cd build diff --git a/docs/InstallationAndUsage.rst b/docs/InstallationAndUsage.rst index 3ec6470b4..526e32882 100644 --- a/docs/InstallationAndUsage.rst +++ b/docs/InstallationAndUsage.rst @@ -34,11 +34,11 @@ library Setup Clang-REPL ****************** -Clone the 20.x release of the LLVM project repository. +Clone the 21.x release of the LLVM project repository. .. code:: bash - git clone --depth=1 --branch release/20.x https://github.com/llvm/llvm-project.git + git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git cd llvm-project ****************** diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 811519dea..a39ef6220 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -25,7 +25,7 @@ infrastructure are described first. ## External Dependencies - CppInterOp now works with: - - llvm20 + - llvm21 ## Introspection