@@ -137,56 +137,32 @@ void ClangImporter::recordModuleDependencies(
137
137
}
138
138
139
139
std::vector<std::string> swiftArgs;
140
- // We are using Swift frontend mode.
141
- swiftArgs.push_back (" -frontend" );
142
- // We pass the entire argument list via -Xcc, so the invocation should
143
- // use extra clang options alone.
144
- swiftArgs.push_back (" -only-use-extra-clang-opts" );
145
140
auto addClangArg = [&](Twine arg) {
146
141
swiftArgs.push_back (" -Xcc" );
147
142
swiftArgs.push_back (arg.str ());
148
143
};
149
- auto addClangFrontendArg = [&](Twine arg) {
150
- addClangArg (" -Xclang" );
151
- addClangArg (arg);
152
- };
153
144
154
- // Add args reported by the scanner.
155
- auto It = clangModuleDep.BuildArguments .begin ();
156
- auto ItEnd = clangModuleDep.BuildArguments .end ();
157
- // Skip -cc1.
158
- ++It;
159
-
160
- while (It != ItEnd) {
161
- StringRef arg = *It;
162
- // Remove the -target arguments because we should use the target triple
163
- // specified with `-clang-target` on the scanner invocation, or
164
- // from the depending Swift modules.
165
- if (arg == " -target" ) {
166
- It += 2 ;
167
- } else if (arg.startswith (" -fapinotes-swift-version=" )) {
168
- // Remove the apinotes version because we should use the language version
169
- // specified in the interface file.
170
- It += 1 ;
171
- } else {
172
- addClangFrontendArg (*It);
173
- ++ It;
174
- }
175
- }
145
+ // We are using Swift frontend mode.
146
+ swiftArgs.push_back (" -frontend" );
176
147
177
- // If the scanner is invoked with '-clang-target', ensure this is the target
178
- // used to build this PCM.
179
- if (Impl.SwiftContext .LangOpts .ClangTarget .hasValue ()) {
180
- llvm::Triple triple = Impl.SwiftContext .LangOpts .ClangTarget .getValue ();
181
- addClangArg (" -target" );
182
- addClangArg (triple.str ());
183
- }
148
+ // We pass the entire argument list via -Xcc, so the invocation should
149
+ // use extra clang options alone.
150
+ swiftArgs.push_back (" -only-use-extra-clang-opts" );
184
151
185
152
// Swift frontend action: -emit-pcm
186
153
swiftArgs.push_back (" -emit-pcm" );
187
154
swiftArgs.push_back (" -module-name" );
188
155
swiftArgs.push_back (clangModuleDep.ID .ModuleName );
189
156
157
+ // Ensure that the resulting PCM build invocation uses Clang frontend directly
158
+ swiftArgs.push_back (" -direct-clang-cc1-module-build" );
159
+
160
+ // Swift frontend option for input file path (Foo.modulemap).
161
+ swiftArgs.push_back (clangModuleDep.ClangModuleMapFile );
162
+
163
+ // Add args reported by the scanner.
164
+ llvm::for_each (clangModuleDep.BuildArguments , addClangArg);
165
+
190
166
// Pass down search paths to the -emit-module action.
191
167
// Unlike building Swift modules, we need to include all search paths to
192
168
// the clang invocation to build PCMs because transitive headers can only
@@ -201,8 +177,6 @@ void ClangImporter::recordModuleDependencies(
201
177
addClangArg ((path.IsSystem ? " -Fsystem" : " -F" ) + path.Path );
202
178
}
203
179
204
- // Swift frontend option for input file path (Foo.modulemap).
205
- swiftArgs.push_back (clangModuleDep.ClangModuleMapFile );
206
180
// Module-level dependencies.
207
181
llvm::StringSet<> alreadyAddedModules;
208
182
auto dependencies = ModuleDependencies::forClangModule (
0 commit comments