From 40286bfd1312174a4ff4e4fdb98f91bcfa51f249 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Thu, 16 Oct 2025 23:00:16 +0300 Subject: [PATCH 01/13] Update Slang-LLVM to LLVM 21.1 --- cmake/LLVM.cmake | 51 ++++++++-------------- docs/building.md | 4 +- external/build-llvm.ps1 | 2 +- external/build-llvm.sh | 2 +- source/slang-llvm/slang-llvm-filecheck.cpp | 4 +- source/slang-llvm/slang-llvm.cpp | 51 +++++++++------------- 6 files changed, 45 insertions(+), 69 deletions(-) diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake index b9ce73a6e12..3a0a2b551ad 100644 --- a/cmake/LLVM.cmake +++ b/cmake/LLVM.cmake @@ -1,42 +1,20 @@ -# A convenience on top of the llvm package's cmake files, this creates a target -# to pass to target_link_libraries which correctly pulls in the llvm include -# dir and other compile dependencies -function(llvm_target_from_components target_name) - set(components ${ARGN}) - llvm_map_components_to_libnames(llvm_libs - ${components} - ) - add_library(${target_name} INTERFACE) - target_link_libraries(${target_name} INTERFACE ${llvm_libs}) - target_include_directories( - ${target_name} - SYSTEM - INTERFACE ${LLVM_INCLUDE_DIRS} - ) - target_compile_definitions(${target_name} INTERFACE ${LLVM_DEFINITIONS}) - if(NOT LLVM_ENABLE_RTTI) - # Make sure that we don't disable rtti if this library wasn't compiled with - # support - add_supported_cxx_flags(${target_name} INTERFACE -fno-rtti /GR-) - endif() -endfunction() - # The same for clang function(clang_target_from_libs target_name) set(clang_libs ${ARGN}) add_library(${target_name} INTERFACE) - target_link_libraries(${target_name} INTERFACE ${clang_libs}) + # Check if we have the individual modules or not. + if(TARGET clangBasic) + target_link_libraries(${target_name} INTERFACE ${clang_libs}) + else() + # If not, we can still link to the catch-all clang-cpp. + target_link_libraries(${target_name} INTERFACE clang-cpp) + endif() target_include_directories( ${target_name} SYSTEM INTERFACE ${CLANG_INCLUDE_DIRS} ) target_compile_definitions(${target_name} INTERFACE ${CLANG_DEFINITIONS}) - if(NOT LLVM_ENABLE_RTTI) - # Make sure that we don't disable rtti if this library wasn't compiled with - # support - add_supported_cxx_flags(${target_name} INTERFACE -fno-rtti /GR-) - endif() endfunction() function(fetch_or_build_slang_llvm) @@ -60,10 +38,9 @@ function(fetch_or_build_slang_llvm) endif() endif() elseif(SLANG_SLANG_LLVM_FLAVOR STREQUAL "USE_SYSTEM_LLVM") - find_package(LLVM 14.0 REQUIRED CONFIG) + find_package(LLVM 21.1 REQUIRED CONFIG) find_package(Clang REQUIRED CONFIG) - llvm_target_from_components(llvm-dep filecheck native orcjit) clang_target_from_libs( clang-dep clangBasic @@ -76,7 +53,7 @@ function(fetch_or_build_slang_llvm) slang_add_target( source/slang-llvm MODULE - LINK_WITH_PRIVATE core compiler-core llvm-dep clang-dep + LINK_WITH_PRIVATE core compiler-core clang-dep # We include slang.h, but don't need to link with it INCLUDE_FROM_PRIVATE slang # We include tools/slang-test/filecheck.h, but don't need to link @@ -90,6 +67,8 @@ function(fetch_or_build_slang_llvm) INSTALL_COMPONENT slang-llvm EXPORT_SET_NAME SlangTargets ) + llvm_config(slang-llvm USE_SHARED filecheck native orcjit) + # If we don't include this, then the symbols in the LLVM linked here may # conflict with those of other LLVMs linked at runtime, for instance in mesa. set_target_properties( @@ -107,8 +86,14 @@ function(fetch_or_build_slang_llvm) target_compile_options(slang-llvm PRIVATE -wd4244) endif() + if(NOT LLVM_ENABLE_RTTI) + # Make sure that we don't disable rtti if this library wasn't compiled with + # support + add_supported_cxx_flags(slang-llvm INTERFACE -fno-rtti /GR-) + endif() + # TODO: Put a check here that libslang-llvm.so doesn't have a 'NEEDED' - # directive for libLLVM-14.so, it's almost certainly going to break at + # directive for libLLVM-21.so, it's almost certainly going to break at # runtime in surprising ways when linked alongside Mesa (or anything else # pulling in libLLVM.so) endif() diff --git a/docs/building.md b/docs/building.md index bcf366d5189..dbedaa737c7 100644 --- a/docs/building.md +++ b/docs/building.md @@ -213,13 +213,13 @@ There are several options for getting llvm-support: containing such a file - If this isn't set then the build system tries to download it from the release on github matching the current tag. If such a tag doesn't exist - or doesn't have the correct os*arch combination then the latest release + or doesn't have the correct os\*arch combination then the latest release will be tried. - If `SLANG_SLANG_LLVM_BINARY_URL` is `FETCH_BINARY_IF_POSSIBLE` then in the case that a prebuilt binary can't be found then the build will proceed as though `DISABLE` was chosen - Use a system supplied LLVM: `-DSLANG_SLANG_LLVM_FLAVOR=USE_SYSTEM_LLVM`, you - must have llvm-14.0 and a matching libclang installed. It's important that + must have llvm-21.1 and a matching libclang installed. It's important that either: - You don't end up linking to a dynamic libllvm.so, this will almost certainly cause multiple versions of LLVM to be loaded at runtime, diff --git a/external/build-llvm.ps1 b/external/build-llvm.ps1 index f403e6ae21f..47e8bb85b31 100644 --- a/external/build-llvm.ps1 +++ b/external/build-llvm.ps1 @@ -55,7 +55,7 @@ $null = Register-EngineEvent PowerShell.Exiting -Action $cleanup # Default values $repo = "https://github.com/llvm/llvm-project" -$branch = "llvmorg-14.0.6" +$branch = "llvmorg-21.1.2" $sourceDir = $tempDir.FullName $installPrefix = "" $config = "Release" diff --git a/external/build-llvm.sh b/external/build-llvm.sh index b556bae7953..9ef363e3d0f 100755 --- a/external/build-llvm.sh +++ b/external/build-llvm.sh @@ -54,7 +54,7 @@ trap cleanup EXIT SIGHUP SIGINT SIGTERM # Options and parsing # repo=https://github.com/llvm/llvm-project -branch=llvmorg-14.0.6 +branch=llvmorg-21.1.2 source_dir=$temp_dir install_prefix= config=Release diff --git a/source/slang-llvm/slang-llvm-filecheck.cpp b/source/slang-llvm/slang-llvm-filecheck.cpp index 492b0e0d419..fb4811039b9 100644 --- a/source/slang-llvm/slang-llvm-filecheck.cpp +++ b/source/slang-llvm/slang-llvm-filecheck.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace slang_llvm @@ -126,8 +127,7 @@ TestResult LLVMFileCheck::performTest( TestMessageType::RunError}; sourceManager.setDiagHandler(fileCheckDiagHandler, static_cast(&reporterData)); - auto checkPrefix = fc.buildCheckPrefixRegex(); - if (fc.readCheckFile(sourceManager, rulesStringRef, checkPrefix)) + if (fc.readCheckFile(sourceManager, rulesStringRef)) { // FileCheck failed to find or understand any FileCheck rules in // the input file, automatic fail, and reported to the diag handler . diff --git a/source/slang-llvm/slang-llvm.cpp b/source/slang-llvm/slang-llvm.cpp index 81d7a9cf600..bbdd13d2dfd 100644 --- a/source/slang-llvm/slang-llvm.cpp +++ b/source/slang-llvm/slang-llvm.cpp @@ -2,7 +2,7 @@ #include "clang/Basic/TargetOptions.h" #include "clang/Basic/Version.h" #include "clang/CodeGen/CodeGenAction.h" -#include "clang/CodeGen/ObjectFilePCHContainerOperations.h" +#include "clang/CodeGen/ObjectFilePCHContainerWriter.h" #include "clang/Config/config.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" @@ -15,6 +15,7 @@ #include "clang/Frontend/Utils.h" #include "clang/FrontendTool/Utils.h" #include "clang/Lex/PreprocessorOptions.h" +#include "clang/Serialization/ObjectFilePCHContainerReader.h" #include "llvm/ADT/Statistic.h" #include "llvm/Config/llvm-config.h" #include "llvm/LinkAllPasses.h" @@ -226,13 +227,8 @@ void* LLVMJITSharedLibrary::castAs(const Guid& guid) void* LLVMJITSharedLibrary::findSymbolAddressByName(char const* name) { - auto fnExpected = m_jit->lookup(name); - if (fnExpected) - { - auto fn = std::move(*fnExpected); - return (void*)fn.getAddress(); - } - return nullptr; + auto fn = m_jit->lookup(name); + return fn ? (void*)fn.get().getValue() : nullptr; } @@ -653,7 +649,7 @@ SlangResult LLVMDownstreamCompiler::compile( pchOps->registerWriter(std::make_unique()); pchOps->registerReader(std::make_unique()); - IntrusiveRefCntPtr diagOpts = new DiagnosticOptions(); + DiagnosticOptions diagOpts; ComPtr diagnostics(new ArtifactDiagnostics); @@ -721,8 +717,6 @@ SlangResult LLVMDownstreamCompiler::compile( } } - const InputKind inputKind(language, InputKind::Format::Source); - { auto& opts = invocation.getFrontendOpts(); @@ -732,7 +726,7 @@ SlangResult LLVMDownstreamCompiler::compile( // input is a memory buffer. For Slang usage, this probably isn't an issue, because it's // *output* typically holds #line directives. { - + const InputKind inputKind(language, InputKind::Format::Source); FrontendInputFile inputFile(*sourceBuffer, inputKind); opts.Inputs.push_back(inputFile); } @@ -784,16 +778,16 @@ SlangResult LLVMDownstreamCompiler::compile( includes.push_back(includePath.begin()); } - clang::CompilerInvocation::setLangDefaults( - *opts, - inputKind, + clang::LangOptions::setLangDefaults( + opts, + language, targetTriple, includes, langStd); if (options.floatingPointMode == DownstreamCompileOptions::FloatingPointMode::Fast) { - opts->FastMath = true; + opts.FastMath = true; } } @@ -853,7 +847,7 @@ SlangResult LLVMDownstreamCompiler::compile( #endif // Create the actual diagnostics engine. - clang->createDiagnostics(); + clang->createDiagnostics(clang->getVirtualFileSystem()); clang->setDiagnostics(diags.get()); if (!clang->hasDiagnostics()) @@ -1037,36 +1031,33 @@ SlangResult LLVMDownstreamCompiler::compile( // Add all the symbolmap SymbolMap symbolMap; - // symbolMap.insert(std::make_pair(mangler("sin"), - // JITEvaluatedSymbol::fromPointer(static_cast(&sin)))); - { static const NameAndFunc funcs[] = {SLANG_LLVM_FUNCS( SLANG_LLVM_FUNC) SLANG_PLATFORM_FUNCS(SLANG_LLVM_FUNC)}; for (auto& func : funcs) { - symbolMap.insert(std::make_pair( + symbolMap.insert({ mangler(func.name), - JITEvaluatedSymbol::fromPointer(func.func))); + { ExecutorAddr::fromPtr(func.func), JITSymbolFlags::Callable }}); } } #if SLANG_PTR_IS_32 && SLANG_VC { // https://docs.microsoft.com/en-us/windows/win32/devnotes/-win32-alldiv - symbolMap.insert(std::make_pair( + symbolMap.insert({ mangler("_alldiv"), - JITEvaluatedSymbol::fromPointer(WinSpecific::_alldiv))); - symbolMap.insert(std::make_pair( + { ExecutorAddr::fromPtr(WinSpecific::_alldiv), JITSymbolFlags::Callable}}); + symbolMap.insert({ mangler("_allrem"), - JITEvaluatedSymbol::fromPointer(WinSpecific::_allrem))); - symbolMap.insert(std::make_pair( + { ExecutorAddr::fromPtr(WinSpecific::_allrem), JITSymbolFlags::Callable}}); + symbolMap.insert({ mangler("_aullrem"), - JITEvaluatedSymbol::fromPointer(WinSpecific::_aullrem))); - symbolMap.insert(std::make_pair( + { ExecutorAddr::fromPtr(WinSpecific::_aullrem), JITSymbolFlags::Callable}}); + symbolMap.insert({ mangler("_aulldiv"), - JITEvaluatedSymbol::fromPointer(WinSpecific::_aulldiv))); + { ExecutorAddr::fromPtr(WinSpecific::_aulldiv), JITSymbolFlags::Callable}}); } #endif From f0c59a681ffb7c093129cdd29513d72cb9f55f21 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Thu, 16 Oct 2025 23:22:39 +0300 Subject: [PATCH 02/13] Fix formatting --- source/slang-llvm/slang-llvm-filecheck.cpp | 2 +- source/slang-llvm/slang-llvm.cpp | 41 +++++++++++----------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/source/slang-llvm/slang-llvm-filecheck.cpp b/source/slang-llvm/slang-llvm-filecheck.cpp index fb4811039b9..c1a19ce9d41 100644 --- a/source/slang-llvm/slang-llvm-filecheck.cpp +++ b/source/slang-llvm/slang-llvm-filecheck.cpp @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include #include namespace slang_llvm diff --git a/source/slang-llvm/slang-llvm.cpp b/source/slang-llvm/slang-llvm.cpp index bbdd13d2dfd..af939c18f46 100644 --- a/source/slang-llvm/slang-llvm.cpp +++ b/source/slang-llvm/slang-llvm.cpp @@ -778,12 +778,7 @@ SlangResult LLVMDownstreamCompiler::compile( includes.push_back(includePath.begin()); } - clang::LangOptions::setLangDefaults( - opts, - language, - targetTriple, - includes, - langStd); + clang::LangOptions::setLangDefaults(opts, language, targetTriple, includes, langStd); if (options.floatingPointMode == DownstreamCompileOptions::FloatingPointMode::Fast) { @@ -1037,27 +1032,31 @@ SlangResult LLVMDownstreamCompiler::compile( for (auto& func : funcs) { - symbolMap.insert({ - mangler(func.name), - { ExecutorAddr::fromPtr(func.func), JITSymbolFlags::Callable }}); + symbolMap.insert( + {mangler(func.name), + {ExecutorAddr::fromPtr(func.func), JITSymbolFlags::Callable}}); } } #if SLANG_PTR_IS_32 && SLANG_VC { // https://docs.microsoft.com/en-us/windows/win32/devnotes/-win32-alldiv - symbolMap.insert({ - mangler("_alldiv"), - { ExecutorAddr::fromPtr(WinSpecific::_alldiv), JITSymbolFlags::Callable}}); - symbolMap.insert({ - mangler("_allrem"), - { ExecutorAddr::fromPtr(WinSpecific::_allrem), JITSymbolFlags::Callable}}); - symbolMap.insert({ - mangler("_aullrem"), - { ExecutorAddr::fromPtr(WinSpecific::_aullrem), JITSymbolFlags::Callable}}); - symbolMap.insert({ - mangler("_aulldiv"), - { ExecutorAddr::fromPtr(WinSpecific::_aulldiv), JITSymbolFlags::Callable}}); + symbolMap.insert( + {mangler("_alldiv"), + {ExecutorAddr::fromPtr(WinSpecific::_alldiv), + JITSymbolFlags::Callable}}); + symbolMap.insert( + {mangler("_allrem"), + {ExecutorAddr::fromPtr(WinSpecific::_allrem), + JITSymbolFlags::Callable}}); + symbolMap.insert( + {mangler("_aullrem"), + {ExecutorAddr::fromPtr(WinSpecific::_aullrem), + JITSymbolFlags::Callable}}); + symbolMap.insert( + {mangler("_aulldiv"), + {ExecutorAddr::fromPtr(WinSpecific::_aulldiv), + JITSymbolFlags::Callable}}); } #endif From 3f3101cad3a6e704dac8b251d936194f6994a3a4 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Thu, 16 Oct 2025 23:46:23 +0300 Subject: [PATCH 03/13] Try to avoid the broken revision parsing --- external/build-llvm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/external/build-llvm.sh b/external/build-llvm.sh index 9ef363e3d0f..a7797bfe5de 100755 --- a/external/build-llvm.sh +++ b/external/build-llvm.sh @@ -122,6 +122,7 @@ cmake_arguments_for_slang=( -DLLVM_INCLUDE_EXAMPLES=0 -DLLVM_INCLUDE_TESTS=0 -DLLVM_ENABLE_TERMINFO=0 + -DLLVM_FORCE_VC_REVISION=0 -DCLANG_BUILD_TOOLS=0 -DCLANG_ENABLE_STATIC_ANALYZER=0 -DCLANG_ENABLE_ARCMT=0 From 3deb2f7af3eb21d91c2dcf862999a39a48428379 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Thu, 16 Oct 2025 23:54:09 +0300 Subject: [PATCH 04/13] Force a repository URL for LLVM too --- external/build-llvm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/external/build-llvm.sh b/external/build-llvm.sh index a7797bfe5de..bbf7715e09c 100755 --- a/external/build-llvm.sh +++ b/external/build-llvm.sh @@ -123,6 +123,7 @@ cmake_arguments_for_slang=( -DLLVM_INCLUDE_TESTS=0 -DLLVM_ENABLE_TERMINFO=0 -DLLVM_FORCE_VC_REVISION=0 + -DLLVM_FORCE_VC_REPOSITORY="https://github.com/llvm/llvm-project" -DCLANG_BUILD_TOOLS=0 -DCLANG_ENABLE_STATIC_ANALYZER=0 -DCLANG_ENABLE_ARCMT=0 From 5bb89319a665b09903b1bec80e837dc73bf80020 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Fri, 17 Oct 2025 00:20:51 +0300 Subject: [PATCH 05/13] Fix MSVC preprocessor flag for including LLVM headers --- cmake/LLVM.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake index 3a0a2b551ad..f5531064913 100644 --- a/cmake/LLVM.cmake +++ b/cmake/LLVM.cmake @@ -83,7 +83,7 @@ function(fetch_or_build_slang_llvm) # The LLVM headers need a warning disabling, which somehow slips through \external if(MSVC) - target_compile_options(slang-llvm PRIVATE -wd4244) + target_compile_options(slang-llvm PRIVATE -wd4244 /Zc:preprocessor) endif() if(NOT LLVM_ENABLE_RTTI) From ac50f3c3a084da1c1691f83e8530f89a020c444d Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Fri, 17 Oct 2025 00:33:59 +0300 Subject: [PATCH 06/13] Disable DIA SDK for LLVM on Windows --- external/build-llvm.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/external/build-llvm.ps1 b/external/build-llvm.ps1 index 47e8bb85b31..8ede7cafedf 100644 --- a/external/build-llvm.ps1 +++ b/external/build-llvm.ps1 @@ -123,6 +123,7 @@ $cmakeArgumentsForSlang = @( "-DLLVM_INCLUDE_EXAMPLES=0" "-DLLVM_INCLUDE_TESTS=0" "-DLLVM_ENABLE_TERMINFO=0" + "-DLLVM_ENABLE_DIA_SDK=0" "-DCLANG_BUILD_TOOLS=0" "-DCLANG_ENABLE_STATIC_ANALYZER=0" "-DCLANG_ENABLE_ARCMT=0" From c1a7a8496a8e82cd2439b25bffff0581d7bb8bfd Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Fri, 17 Oct 2025 00:44:52 +0300 Subject: [PATCH 07/13] Disable DIA SDK in build-llvm.sh too --- external/build-llvm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/external/build-llvm.sh b/external/build-llvm.sh index bbf7715e09c..91bc56560a7 100755 --- a/external/build-llvm.sh +++ b/external/build-llvm.sh @@ -124,6 +124,7 @@ cmake_arguments_for_slang=( -DLLVM_ENABLE_TERMINFO=0 -DLLVM_FORCE_VC_REVISION=0 -DLLVM_FORCE_VC_REPOSITORY="https://github.com/llvm/llvm-project" + -DLLVM_ENABLE_DIA_SDK=0 -DCLANG_BUILD_TOOLS=0 -DCLANG_ENABLE_STATIC_ANALYZER=0 -DCLANG_ENABLE_ARCMT=0 From 388c98988a6e1699216c0a10752d767cccd79e9b Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Fri, 17 Oct 2025 01:10:12 +0300 Subject: [PATCH 08/13] Make USE_SHARED conditional --- cmake/LLVM.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake index f5531064913..455b7aa03de 100644 --- a/cmake/LLVM.cmake +++ b/cmake/LLVM.cmake @@ -41,6 +41,10 @@ function(fetch_or_build_slang_llvm) find_package(LLVM 21.1 REQUIRED CONFIG) find_package(Clang REQUIRED CONFIG) + if (LLVM_LINK_LLVM_DYLIB) + set(LLVM_LINK_TYPE USE_SHARED) + endif() + clang_target_from_libs( clang-dep clangBasic @@ -67,7 +71,8 @@ function(fetch_or_build_slang_llvm) INSTALL_COMPONENT slang-llvm EXPORT_SET_NAME SlangTargets ) - llvm_config(slang-llvm USE_SHARED filecheck native orcjit) + + llvm_config(slang-llvm ${LLVM_LINK_TYPE} filecheck native orcjit) # If we don't include this, then the symbols in the LLVM linked here may # conflict with those of other LLVMs linked at runtime, for instance in mesa. From 5e10b2f0c11004c20ad19f61a503b8212e8d3706 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Fri, 17 Oct 2025 01:12:37 +0300 Subject: [PATCH 09/13] Fix formatting --- cmake/LLVM.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake index 455b7aa03de..25ac61f6f28 100644 --- a/cmake/LLVM.cmake +++ b/cmake/LLVM.cmake @@ -41,7 +41,7 @@ function(fetch_or_build_slang_llvm) find_package(LLVM 21.1 REQUIRED CONFIG) find_package(Clang REQUIRED CONFIG) - if (LLVM_LINK_LLVM_DYLIB) + if(LLVM_LINK_LLVM_DYLIB) set(LLVM_LINK_TYPE USE_SHARED) endif() From 41238efe508f653392c9f1cc0bf23f7db7ab8bfc Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Fri, 17 Oct 2025 02:10:50 +0300 Subject: [PATCH 10/13] Fixes to allow tests to pass again --- source/slang-llvm/slang-llvm.cpp | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/source/slang-llvm/slang-llvm.cpp b/source/slang-llvm/slang-llvm.cpp index af939c18f46..647ce0beaca 100644 --- a/source/slang-llvm/slang-llvm.cpp +++ b/source/slang-llvm/slang-llvm.cpp @@ -770,7 +770,7 @@ SlangResult LLVMDownstreamCompiler::compile( } { - auto opts = invocation.getLangOpts(); + auto& opts = invocation.getLangOpts(); std::vector includes; for (const auto& includePath : options.includePaths) @@ -842,7 +842,7 @@ SlangResult LLVMDownstreamCompiler::compile( #endif // Create the actual diagnostics engine. - clang->createDiagnostics(clang->getVirtualFileSystem()); + clang->createDiagnostics(*llvm::vfs::getRealFileSystem()); clang->setDiagnostics(diags.get()); if (!clang->hasDiagnostics()) @@ -1032,31 +1032,17 @@ SlangResult LLVMDownstreamCompiler::compile( for (auto& func : funcs) { - symbolMap.insert( - {mangler(func.name), - {ExecutorAddr::fromPtr(func.func), JITSymbolFlags::Callable}}); + symbolMap[mangler(func.name)] = {ExecutorAddr::fromPtr(func.func), JITSymbolFlags::Callable}; } } #if SLANG_PTR_IS_32 && SLANG_VC { // https://docs.microsoft.com/en-us/windows/win32/devnotes/-win32-alldiv - symbolMap.insert( - {mangler("_alldiv"), - {ExecutorAddr::fromPtr(WinSpecific::_alldiv), - JITSymbolFlags::Callable}}); - symbolMap.insert( - {mangler("_allrem"), - {ExecutorAddr::fromPtr(WinSpecific::_allrem), - JITSymbolFlags::Callable}}); - symbolMap.insert( - {mangler("_aullrem"), - {ExecutorAddr::fromPtr(WinSpecific::_aullrem), - JITSymbolFlags::Callable}}); - symbolMap.insert( - {mangler("_aulldiv"), - {ExecutorAddr::fromPtr(WinSpecific::_aulldiv), - JITSymbolFlags::Callable}}); + symbolMap[mangler("_alldiv")] = {ExecutorAddr::fromPtr(WinSpecific::_alldiv), JITSymbolFlags::Callable}; + symbolMap[mangler("_allrem")] = {ExecutorAddr::fromPtr(WinSpecific::_allrem), JITSymbolFlags::Callable}; + symbolMap[mangler("_aulldiv")] = {ExecutorAddr::fromPtr(WinSpecific::_aulldiv), JITSymbolFlags::Callable}; + symbolMap[mangler("_aullrem")] = {ExecutorAddr::fromPtr(WinSpecific::_aullrem), JITSymbolFlags::Callable}; } #endif @@ -1066,7 +1052,7 @@ SlangResult LLVMDownstreamCompiler::compile( } // Required or the symbols won't be found - jit->getMainJITDylib().addToLinkOrder(stdcLib); + jit->getMainJITDylib().addToLinkOrder(stdcLib, JITDylibLookupFlags::MatchAllSymbols); } } From 58da73dcd956f6b36e17918add5b7df9d12538f4 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Fri, 17 Oct 2025 02:13:06 +0300 Subject: [PATCH 11/13] Fix formatting --- source/slang-llvm/slang-llvm.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/source/slang-llvm/slang-llvm.cpp b/source/slang-llvm/slang-llvm.cpp index 647ce0beaca..56e12ec7ac9 100644 --- a/source/slang-llvm/slang-llvm.cpp +++ b/source/slang-llvm/slang-llvm.cpp @@ -1032,17 +1032,27 @@ SlangResult LLVMDownstreamCompiler::compile( for (auto& func : funcs) { - symbolMap[mangler(func.name)] = {ExecutorAddr::fromPtr(func.func), JITSymbolFlags::Callable}; + symbolMap[mangler(func.name)] = { + ExecutorAddr::fromPtr(func.func), + JITSymbolFlags::Callable}; } } #if SLANG_PTR_IS_32 && SLANG_VC { // https://docs.microsoft.com/en-us/windows/win32/devnotes/-win32-alldiv - symbolMap[mangler("_alldiv")] = {ExecutorAddr::fromPtr(WinSpecific::_alldiv), JITSymbolFlags::Callable}; - symbolMap[mangler("_allrem")] = {ExecutorAddr::fromPtr(WinSpecific::_allrem), JITSymbolFlags::Callable}; - symbolMap[mangler("_aulldiv")] = {ExecutorAddr::fromPtr(WinSpecific::_aulldiv), JITSymbolFlags::Callable}; - symbolMap[mangler("_aullrem")] = {ExecutorAddr::fromPtr(WinSpecific::_aullrem), JITSymbolFlags::Callable}; + symbolMap[mangler("_alldiv")] = { + ExecutorAddr::fromPtr(WinSpecific::_alldiv), + JITSymbolFlags::Callable}; + symbolMap[mangler("_allrem")] = { + ExecutorAddr::fromPtr(WinSpecific::_allrem), + JITSymbolFlags::Callable}; + symbolMap[mangler("_aulldiv")] = { + ExecutorAddr::fromPtr(WinSpecific::_aulldiv), + JITSymbolFlags::Callable}; + symbolMap[mangler("_aullrem")] = { + ExecutorAddr::fromPtr(WinSpecific::_aullrem), + JITSymbolFlags::Callable}; } #endif @@ -1052,7 +1062,9 @@ SlangResult LLVMDownstreamCompiler::compile( } // Required or the symbols won't be found - jit->getMainJITDylib().addToLinkOrder(stdcLib, JITDylibLookupFlags::MatchAllSymbols); + jit->getMainJITDylib().addToLinkOrder( + stdcLib, + JITDylibLookupFlags::MatchAllSymbols); } } From 8c4b8fe52797912aad639acbb36591239d359417 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Fri, 17 Oct 2025 10:05:44 +0300 Subject: [PATCH 12/13] Fix LLVM_ENABLE_RTTI --- cmake/LLVM.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake index 25ac61f6f28..9a9754684a8 100644 --- a/cmake/LLVM.cmake +++ b/cmake/LLVM.cmake @@ -94,7 +94,7 @@ function(fetch_or_build_slang_llvm) if(NOT LLVM_ENABLE_RTTI) # Make sure that we don't disable rtti if this library wasn't compiled with # support - add_supported_cxx_flags(slang-llvm INTERFACE -fno-rtti /GR-) + add_supported_cxx_flags(slang-llvm PRIVATE -fno-rtti /GR-) endif() # TODO: Put a check here that libslang-llvm.so doesn't have a 'NEEDED' From 0024e22acb59519ba10dbfc0f5196fea004cb309 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Fri, 17 Oct 2025 12:34:40 +0300 Subject: [PATCH 13/13] Increase CI timeout to allow LLVM build to finish This does not need to be permanent, as the build is cached on the CI. --- .github/workflows/ci-slang-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-slang-build.yml b/.github/workflows/ci-slang-build.yml index efb4fe4a4b2..22477833b38 100644 --- a/.github/workflows/ci-slang-build.yml +++ b/.github/workflows/ci-slang-build.yml @@ -34,7 +34,7 @@ on: jobs: build: runs-on: ${{ fromJSON(inputs.runs-on) }} - timeout-minutes: 60 + timeout-minutes: 120 defaults: run: