From 30c5fa6808b9a71a47d9e89ad090a824d8ea48c3 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 28 Oct 2025 19:47:02 -0700 Subject: accelerate abseil build --- CMakeLists.txt | 19 ++++++++++++++++++- README.md | 1 - build.ps1 | 3 --- main.cc | 20 +++++++++++++------- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a2db3b..5bee59b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,24 @@ FetchContent_Declare( abseil URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.1.zip ) -FetchContent_MakeAvailable(abseil) + +# Only populate abseil if it hasn't been built yet +FetchContent_GetProperties(abseil) +if(NOT abseil_POPULATED) + # Check if the built libraries already exist + set(ABSEIL_STATUS_LIB "${CMAKE_BINARY_DIR}/_deps/abseil-build/absl/status/absl_status.lib") + set(ABSEIL_STATUSOR_LIB "${CMAKE_BINARY_DIR}/_deps/abseil-build/absl/status/absl_statusor.lib") + + if(NOT EXISTS "${ABSEIL_STATUS_LIB}" OR NOT EXISTS "${ABSEIL_STATUSOR_LIB}") + message(STATUS "Abseil libraries not found, building abseil...") + FetchContent_MakeAvailable(abseil) + else() + message(STATUS "Abseil libraries found, skipping rebuild") + # Manually populate the source directory without building + FetchContent_Populate(abseil) + add_subdirectory(${abseil_SOURCE_DIR} ${abseil_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() +endif() add_executable(modular_slang main.cc) set_target_properties(modular_slang PROPERTIES diff --git a/README.md b/README.md index 465a53d..a2e67c5 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ cd build powershell.exe cmake.exe .. powershell.exe cmake.exe --build . -j 32 --config Release # the previous command will take a long fucking time -# switch back to top level of repo cd ../.. # do this in wsl2 or powershell. Showing wsl2/bash syntax. powershell.exe ./build.ps1 && ./dist/modular_slang.exe ./demo.slang diff --git a/build.ps1 b/build.ps1 index c56ae24..00c6a8b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,3 @@ -if (Test-Path -Path ./build) { - rm -Recurse ./build -} mkdir ./build cmake -S . -B build -G "Visual Studio 17 2022" -A x64 diff --git a/main.cc b/main.cc index f6c7a3b..de429a9 100644 --- a/main.cc +++ b/main.cc @@ -491,7 +491,12 @@ absl::StatusOr> loadSlangModule(ISession* session, const std::st return module; } -absl::StatusOr> collectEntryPoints( +struct EntryPointsResult { + std::vector functions; + std::unordered_set publicFunctions; +}; + +absl::StatusOr collectEntryPoints( IModule* module, const std::string& moduleName, const fs::path& sourcePath) { @@ -521,7 +526,7 @@ absl::StatusOr> collectEntryPoints( return absl::NotFoundError(msg.str()); } - return functions; + return EntryPointsResult{functions, publicFunctions}; } absl::StatusOr> createCompileRequest( @@ -625,6 +630,7 @@ std::string removeNvapiInclude(std::string hlslSource) { return hlslSource; } + std::string applyIncludeGuard(const std::string& hlslSource, const IncludeGuardInfo& includeGuard) { if (!includeGuard.present) { return hlslSource; @@ -702,15 +708,15 @@ absl::Status run(int argc, char** argv) { } ComPtr libraryModule = std::move(libraryModuleOr).value(); - absl::StatusOr> functionsOr = + absl::StatusOr entryPointsOr = collectEntryPoints(libraryModule.get(), request.moduleName, request.modulePath); - if (!functionsOr.ok()) { - return functionsOr.status(); + if (!entryPointsOr.ok()) { + return entryPointsOr.status(); } - std::vector functions = std::move(functionsOr).value(); + EntryPointsResult entryPoints = std::move(entryPointsOr).value(); absl::StatusOr> compileRequestOr = - createCompileRequest(session.get(), request, targetDesc, functions); + createCompileRequest(session.get(), request, targetDesc, entryPoints.functions); if (!compileRequestOr.ok()) { return compileRequestOr.status(); } -- cgit v1.2.3