@@ -101,28 +101,34 @@ getVersionedPrebuiltModulePath(Optional<llvm::VersionTuple> sdkVer,
101
101
} while (true );
102
102
}
103
103
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};
112
108
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.
116
112
platform = " macosx" ;
117
113
} else {
118
- platform = getPlatformNameForTriple (LangOpts. Target );
114
+ platform = getPlatformNameForTriple (target );
119
115
}
120
116
llvm::sys::path::append (defaultPrebuiltPath, platform, " prebuilt-modules" );
121
117
122
118
// If the SDK version is given, we should check if SDK-versioned prebuilt
123
119
// 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 );
126
132
}
127
133
128
134
static void updateRuntimeLibraryPaths (SearchPathOptions &SearchPathOpts,
0 commit comments