From 436a56314ce7d19d1b77cf42b396593f6c63c283 Mon Sep 17 00:00:00 2001 From: Ray Wang Date: Mon, 21 Jul 2025 10:44:20 +0800 Subject: [PATCH] Use std::filesystem::directory_iterator instead of std::filesystem::recursive_directory_iterator to avoid an ABI breakage we met (#131) --- csrc/jit/compiler.hpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/csrc/jit/compiler.hpp b/csrc/jit/compiler.hpp index 4296b35..2ccb368 100644 --- a/csrc/jit/compiler.hpp +++ b/csrc/jit/compiler.hpp @@ -19,16 +19,29 @@ class Compiler { std::string library_version; std::filesystem::path library_root_path; - std::string get_library_version() const { - // Recursively walk through all subdirectories and update hash - std::stringstream ss; - for (const auto& entry: std::filesystem::recursive_directory_iterator(library_include_path / "deep_gemm")) { - if (entry.is_regular_file() and entry.path().extension() == ".cuh") { - std::ifstream file(entry.path(), std::ios::binary); - std::string content((std::istreambuf_iterator(file)), std::istreambuf_iterator()); - ss << content; + static void collect_files(const std::filesystem::path& dir, + std::vector& out) { + // We met ABI breakage using std::filesystem::recursive_directory_iterator + // Use std::filesystem::directory_iterator instead + for (const auto& entry : std::filesystem::directory_iterator(dir)) { + if (entry.is_directory()) { + collect_files(entry.path(), out); + } else if (entry.is_regular_file() && entry.path().extension()==".cuh") { + out.emplace_back(entry.path()); } } + } + + std::string get_library_version() const { + std::vector files; + collect_files(library_include_path / "deep_gemm", files); + std::sort(files.begin(), files.end()); + + std::stringstream ss; + for (const auto& f : files) { + std::ifstream in(f, std::ios::binary); + ss << in.rdbuf(); + } return get_hex_digest(ss.str()); }