@@ -101,28 +101,34 @@ getVersionedPrebuiltModulePath(Optional<llvm::VersionTuple> sdkVer,
101101 } while (true );
102102}
103103
104- void CompilerInvocation::setDefaultPrebuiltCacheIfNecessary () {
105-
106- if (!FrontendOpts.PrebuiltModuleCachePath .empty ())
107- return ;
108- if (SearchPathOpts.RuntimeResourcePath .empty ())
109- return ;
110-
111- SmallString<64 > defaultPrebuiltPath{SearchPathOpts.RuntimeResourcePath };
104+ std::string CompilerInvocation::computePrebuiltCachePath (
105+ StringRef RuntimeResourcePath, llvm::Triple target,
106+ Optional<llvm::VersionTuple> sdkVer) {
107+ SmallString<64 > defaultPrebuiltPath{RuntimeResourcePath};
112108 StringRef platform;
113- if (tripleIsMacCatalystEnvironment (LangOpts. Target )) {
114- // The prebuilt cache for macCatalyst is the same as the one for macOS, not iOS
115- // or a separate location of its own.
109+ if (tripleIsMacCatalystEnvironment (target )) {
110+ // The prebuilt cache for macCatalyst is the same as the one for macOS, not
111+ // iOS or a separate location of its own.
116112 platform = " macosx" ;
117113 } else {
118- platform = getPlatformNameForTriple (LangOpts. Target );
114+ platform = getPlatformNameForTriple (target );
119115 }
120116 llvm::sys::path::append (defaultPrebuiltPath, platform, " prebuilt-modules" );
121117
122118 // If the SDK version is given, we should check if SDK-versioned prebuilt
123119 // module cache is available and use it if so.
124- FrontendOpts.PrebuiltModuleCachePath =
125- getVersionedPrebuiltModulePath (LangOpts.SDKVersion , defaultPrebuiltPath);
120+ return getVersionedPrebuiltModulePath (sdkVer, defaultPrebuiltPath);
121+ }
122+
123+ void CompilerInvocation::setDefaultPrebuiltCacheIfNecessary () {
124+
125+ if (!FrontendOpts.PrebuiltModuleCachePath .empty ())
126+ return ;
127+ if (SearchPathOpts.RuntimeResourcePath .empty ())
128+ return ;
129+
130+ FrontendOpts.PrebuiltModuleCachePath = computePrebuiltCachePath (
131+ SearchPathOpts.RuntimeResourcePath , LangOpts.Target , LangOpts.SDKVersion );
126132}
127133
128134static void updateRuntimeLibraryPaths (SearchPathOptions &SearchPathOpts,
0 commit comments