[Modules] Avoid false swift module sharing

When the swiftmodule is built with different clang importer arguments,
they can have the same module hash, causing them to be wrongly re-used even
they contains different interfaces. Add ReducedExtraArgs to the module hash to
disambiguate them.

However, some Xcc arguments, most commonly `-D` options do not affect the
swiftmodule being generated. Do not pass `-Xcc -DARGS` to swift
interface compilation to reduce the amount of module variants in the
build.

rdar://131408266
This commit is contained in:
Steven Wu
2024-07-10 11:12:04 -07:00
parent 4993f4bf22
commit a32dd9539b
8 changed files with 114 additions and 22 deletions

View File

@@ -381,7 +381,8 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
std::vector<std::string> buildArgs;
if (ScanASTContext.ClangImporterOpts.ClangImporterDirectCC1Scan) {
buildArgs.push_back("-direct-clang-cc1-module-build");
for (auto &arg : clangImporter->getSwiftExplicitModuleDirectCC1Args()) {
for (auto &arg : clangImporter->getSwiftExplicitModuleDirectCC1Args(
/*isInterface=*/false)) {
buildArgs.push_back("-Xcc");
buildArgs.push_back(arg);
}