Skip to content

Commit 3f64d99

Browse files
Merge pull request #75357 from cachemeifyoucan/eng/PR-132046247
[ExplicitModule] Include `-Xcc -D` into module hash
2 parents fc8cc33 + 2bc4080 commit 3f64d99

File tree

6 files changed

+10
-22
lines changed

6 files changed

+10
-22
lines changed

include/swift/ClangImporter/ClangImporter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,7 @@ class ClangImporter final : public ClangModuleLoader {
517517
std::string getClangModuleHash() const;
518518

519519
/// Get clang import creation cc1 args for swift explicit module build.
520-
std::vector<std::string>
521-
getSwiftExplicitModuleDirectCC1Args(bool isInterface) const;
520+
std::vector<std::string> getSwiftExplicitModuleDirectCC1Args() const;
522521

523522
/// If we already imported a given decl successfully, return the corresponding
524523
/// Swift decl as an Optional<Decl *>, but if we previously tried and failed

lib/Basic/LangOptions.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ namespace {
729729
"-working-directory=",
730730
"-working-directory"};
731731

732-
constexpr std::array<std::string_view, 16>
732+
constexpr std::array<std::string_view, 15>
733733
knownClangDependencyIgnorablePrefiexes = {"-I",
734734
"-F",
735735
"-fmodule-map-file=",
@@ -744,8 +744,7 @@ namespace {
744744
"-isystem",
745745
"-isysroot",
746746
"-working-directory=",
747-
"-working-directory",
748-
"-D"};
747+
"-working-directory"};
749748
}
750749

751750
std::vector<std::string> ClangImporterOptions::getRemappedExtraArgs(

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4095,7 +4095,7 @@ std::string ClangImporter::getClangModuleHash() const {
40954095
}
40964096

40974097
std::vector<std::string>
4098-
ClangImporter::getSwiftExplicitModuleDirectCC1Args(bool isInterface) const {
4098+
ClangImporter::getSwiftExplicitModuleDirectCC1Args() const {
40994099
llvm::SmallVector<const char*> clangArgs;
41004100
clangArgs.reserve(Impl.ClangArgs.size());
41014101
llvm::for_each(Impl.ClangArgs, [&](const std::string &Arg) {
@@ -4145,14 +4145,6 @@ ClangImporter::getSwiftExplicitModuleDirectCC1Args(bool isInterface) const {
41454145
PPOpts.MacroIncludes.clear();
41464146
PPOpts.Includes.clear();
41474147

4148-
// Clear specific options that will not affect swiftinterface compilation, but
4149-
// might affect main Module.
4150-
if (isInterface) {
4151-
// Interfacefile should not need `-D` but pass to main module in case it
4152-
// needs to directly import clang headers.
4153-
PPOpts.Macros.clear();
4154-
}
4155-
41564148
if (Impl.SwiftContext.ClangImporterOpts.UseClangIncludeTree) {
41574149
// FileSystemOptions.
41584150
auto &FSOpts = instance.getFileSystemOpts();

lib/DependencyScan/ModuleDependencyScanner.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
383383
std::vector<std::string> buildArgs;
384384
if (ScanASTContext.ClangImporterOpts.ClangImporterDirectCC1Scan) {
385385
buildArgs.push_back("-direct-clang-cc1-module-build");
386-
for (auto &arg : clangImporter->getSwiftExplicitModuleDirectCC1Args(
387-
/*isInterface=*/false)) {
386+
for (auto &arg : clangImporter->getSwiftExplicitModuleDirectCC1Args()) {
388387
buildArgs.push_back("-Xcc");
389388
buildArgs.push_back(arg);
390389
}

lib/Serialization/ScanningLoaders.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ SwiftModuleScanner::scanInterfaceFile(Twine moduleInterfacePath,
186186
Args.push_back("-direct-clang-cc1-module-build");
187187
auto *importer =
188188
static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
189-
for (auto &Arg : importer->getSwiftExplicitModuleDirectCC1Args(
190-
/*isInterface=*/true)) {
189+
for (auto &Arg : importer->getSwiftExplicitModuleDirectCC1Args()) {
191190
Args.push_back("-Xcc");
192191
Args.push_back(Arg);
193192
}

test/ScanDependencies/module_hash.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-1.json Library modulePath > %t/path-1
1919
// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-2.json Library modulePath > %t/path-2
2020
// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-3.json Library modulePath > %t/path-3
21-
// RUN: diff %t/path-1 %t/path-2
21+
// RUN: not diff %t/path-1 %t/path-2
2222
// RUN: not diff %t/path-1 %t/path-3
2323

2424
/// Check build command (exclude dependency module file path). 1 and 2 should match, but not 3.
2525
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-1.json Library | grep -v fmodule-file= > %t/lib-1.cmd
2626
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-2.json Library | grep -v fmodule-file= > %t/lib-2.cmd
2727
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-3.json Library | grep -v fmodule-file= > %t/lib-3.cmd
28-
// RUN: diff %t/lib-1.cmd %t/lib-2.cmd
28+
// RUN: not diff %t/lib-1.cmd %t/lib-2.cmd
2929
// RUN: not diff %t/lib-1.cmd %t/lib-3.cmd
3030

3131
/// Test direct-cc1 mode.
@@ -42,12 +42,12 @@
4242
// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-4.json Library modulePath > %t/path-4
4343
// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-5.json Library modulePath > %t/path-5
4444
// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-6.json Library modulePath > %t/path-6
45-
// RUN: diff %t/path-4 %t/path-5
45+
// RUN: not diff %t/path-4 %t/path-5
4646
// RUN: not diff %t/path-4 %t/path-6
4747
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-4.json Library | grep -v fmodule-file= > %t/lib-4.cmd
4848
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-5.json Library | grep -v fmodule-file= > %t/lib-5.cmd
4949
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-6.json Library | grep -v fmodule-file= > %t/lib-6.cmd
50-
// RUN: diff %t/lib-4.cmd %t/lib-5.cmd
50+
// RUN: not diff %t/lib-4.cmd %t/lib-5.cmd
5151
// RUN: not diff %t/lib-4.cmd %t/lib-6.cmd
5252

5353
//--- main.swift

0 commit comments

Comments
 (0)