diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -106,7 +106,13 @@ return path; } +static DenseMap resolvedFrameworks; static Optional findFramework(StringRef name) { + CachedHashStringRef key(name); + auto entry = resolvedFrameworks.find(key); + if (entry != resolvedFrameworks.end()) + return entry->second; + SmallString<260> symlink; StringRef suffix; std::tie(name, suffix) = name.split(","); @@ -121,14 +127,18 @@ if (!fs::real_path(symlink, location)) { // only append suffix if realpath() succeeds Twine suffixed = location + suffix; - if (fs::exists(suffixed)) - return saver.save(suffixed.str()); + if (fs::exists(suffixed)) { + StringRef saved = saver.save(suffixed.str()); + return resolvedFrameworks[key] = saved; + } } // Suffix lookup failed, fall through to the no-suffix case. } - if (Optional path = resolveDylibPath(symlink.str())) + if (Optional path = resolveDylibPath(symlink.str())) { + resolvedFrameworks[key] = *path; return path; + } } return {}; } @@ -1098,6 +1108,7 @@ loadedArchives.clear(); syntheticSections.clear(); thunkMap.clear(); + resolvedFrameworks.clear(); firstTLVDataSection = nullptr; tar = nullptr;