diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index a9916f44b0442..867b399308528 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -738,8 +738,24 @@ void Serializer::writeHeader(const SerializationOptions &options) { options_block::XCCLayout XCC(Out); SDKPath.emit(ScratchRecord, M->getASTContext().SearchPathOpts.SDKPath); - for (const std::string &arg : options.ExtraClangOptions) { - XCC.emit(ScratchRecord, arg); + auto &Opts = options.ExtraClangOptions; + for (auto Arg = Opts.begin(), E = Opts.end(); Arg != E; ++Arg) { + // FIXME: This is a hack and calls for a better design. + // + // Filter out any -ivfsoverlay options that include an + // unextended-module-overlay.yaml overlay. By convention the Xcode + // buildsystem uses these while *building* mixed Objective-C and Swift + // frameworks; but they should never be used to *import* the module + // defined in the framework. + if (StringRef(*Arg).startswith("-ivfsoverlay")) { + auto Next = std::next(Arg); + if (Next != E && + StringRef(*Next).endswith("unextended-module-overlay.yaml")) { + ++Arg; + continue; + } + } + XCC.emit(ScratchRecord, *Arg); } } } diff --git a/test/Inputs/unextended-module-overlay.yaml b/test/Inputs/unextended-module-overlay.yaml new file mode 100644 index 0000000000000..e3428038165bb --- /dev/null +++ b/test/Inputs/unextended-module-overlay.yaml @@ -0,0 +1,4 @@ +{ + 'version': 0, + 'roots': [] +} diff --git a/test/Serialization/search-paths-relative.swift b/test/Serialization/search-paths-relative.swift index a9987705a5c14..fe1b26310bd3f 100644 --- a/test/Serialization/search-paths-relative.swift +++ b/test/Serialization/search-paths-relative.swift @@ -3,7 +3,7 @@ // RUN: mkdir -p %t/Frameworks/has_alias.framework/Modules/has_alias.swiftmodule/ // RUN: %target-swift-frontend -emit-module -o %t/Frameworks/has_alias.framework/Modules/has_alias.swiftmodule/%target-swiftmodule-name %S/Inputs/alias.swift -module-name has_alias -// RUN: cd %t/secret && %target-swiftc_driver -emit-module -o %t/has_xref.swiftmodule -I . -F ../Frameworks -parse-as-library %S/Inputs/has_xref.swift %S/../Inputs/empty.swift -Xfrontend -serialize-debugging-options -Xcc -DDUMMY +// RUN: cd %t/secret && %target-swiftc_driver -emit-module -o %t/has_xref.swiftmodule -I . -F ../Frameworks -parse-as-library %S/Inputs/has_xref.swift %S/../Inputs/empty.swift -Xfrontend -serialize-debugging-options -Xcc -ivfsoverlay -Xcc %S/../Inputs/unextended-module-overlay.yaml -Xcc -DDUMMY // RUN: %target-swift-frontend %s -typecheck -I %t // Check the actual serialized search paths. @@ -30,3 +30,5 @@ numeric(42) // NEGATIVE-NOT: '.' // NEGATIVE-NOT: '../Frameworks' +// This should be filtered out. +// NEGATIVE-NOT: -ivfsoverlay{{.*}}unextended-module-overlay.yaml