diff --git a/src/libutil/posix-source-accessor.cc b/src/libutil/posix-source-accessor.cc index f8ec7fc6b..41c2db59a 100644 --- a/src/libutil/posix-source-accessor.cc +++ b/src/libutil/posix-source-accessor.cc @@ -85,16 +85,20 @@ bool PosixSourceAccessor::pathExists(const CanonPath & path) std::optional PosixSourceAccessor::cachedLstat(const CanonPath & path) { - static Sync>> _cache; + static Sync>> _cache; + + // Note: we convert std::filesystem::path to Path because the + // former is not hashable on libc++. + Path absPath = makeAbsPath(path); { auto cache(_cache.lock()); - auto i = cache->find(path); + auto i = cache->find(absPath); if (i != cache->end()) return i->second; } std::optional st{std::in_place}; - if (::lstat(makeAbsPath(path).c_str(), &*st)) { + if (::lstat(absPath.c_str(), &*st)) { if (errno == ENOENT || errno == ENOTDIR) st.reset(); else @@ -103,7 +107,7 @@ std::optional PosixSourceAccessor::cachedLstat(const CanonPath & pa auto cache(_cache.lock()); if (cache->size() >= 16384) cache->clear(); - cache->emplace(path, st); + cache->emplace(absPath, st); return st; }