Skip to content

Commit

Permalink
Filter unextended module overlay VFS from serialized debugging options
Browse files Browse the repository at this point in the history
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.

rdar://problem/30934351
  • Loading branch information
adrian-prantl committed Mar 21, 2017
1 parent 5aa02eb commit 728c56c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
20 changes: 18 additions & 2 deletions lib/Serialization/Serialization.cpp
Expand Up @@ -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);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/Inputs/unextended-module-overlay.yaml
@@ -0,0 +1,4 @@
{
'version': 0,
'roots': []
}
4 changes: 3 additions & 1 deletion test/Serialization/search-paths-relative.swift
Expand Up @@ -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.
Expand All @@ -30,3 +30,5 @@ numeric(42)

// NEGATIVE-NOT: '.'
// NEGATIVE-NOT: '../Frameworks'
// This should be filtered out.
// NEGATIVE-NOT: -ivfsoverlay{{.*}}unextended-module-overlay.yaml

0 comments on commit 728c56c

Please sign in to comment.