Skip to content

[Serialization] Don't filter out unextended-module-map VFS in explicit builds. #76811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,14 +1167,19 @@ void Serializer::writeHeader() {
auto &Opts = Options.ExtraClangOptions;
for (auto Arg = Opts.begin(), E = Opts.end(); Arg != E; ++Arg) {
StringRef arg(*Arg);
if (arg.starts_with("-ivfsoverlay")) {
if (!Options.ExplicitModuleBuild && arg.starts_with("-ivfsoverlay")) {
// 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.
//
// This is not done for explicit modules builds. In an explicit
// build LLDB needs to be able import the unmodified .pcms, so
// having the exact same flags matters there, and there is no risk
// of a recompilation failure, because nothing is recompiled.
auto Next = std::next(Arg);
if (Next != E &&
StringRef(*Next).ends_with("unextended-module-overlay.yaml")) {
Expand Down
9 changes: 8 additions & 1 deletion test/Serialization/search-paths-relative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

// Output paths differ in the new driver, so force SWIFT_USE_OLD_DRIVER for now.
// RUN: cd %t/secret && env SWIFT_USE_OLD_DRIVER=1 %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: cd %t/secret && env SWIFT_USE_OLD_DRIVER=1 %target-swiftc_driver -emit-module -o %t/explicit.swiftmodule -parse-stdlib -parse-as-library %S/../Inputs/empty.swift -Xfrontend -disable-implicit-swift-modules -Xfrontend -serialize-debugging-options -Xcc -ivfsoverlay -Xcc %S/../Inputs/unextended-module-overlay.yaml -Xcc -DDUMMY
// RUN: %target-swift-frontend %s -typecheck -I %t

// Ensure that in Swift 6 mode we do not read out search paths, thus are no longer able to
Expand All @@ -15,8 +16,10 @@

// Check the actual serialized search paths.
// RUN: llvm-bcanalyzer -dump %t/has_xref.swiftmodule > %t/has_xref.swiftmodule.txt
// RUN: llvm-bcanalyzer -dump %t/explicit.swiftmodule > %t/explicit.swiftmodule.txt
// RUN: %FileCheck %s < %t/has_xref.swiftmodule.txt
// RUN: %FileCheck -check-prefix=NEGATIVE %s < %t/has_xref.swiftmodule.txt
// RUN: %FileCheck -check-prefix=EXPLICIT %s < %t/explicit.swiftmodule.txt

import has_xref

Expand All @@ -36,6 +39,10 @@ numeric(42)
// NEGATIVE-NOT: '.'
// NEGATIVE-NOT: '../Frameworks'
// This should be filtered out.
// NEGATIVE-NOT: -ivfsoverlay{{.*}}unextended-module-overlay.yaml
// NEGATIVE-NOT: -ivfsoverlay
// NEGATIVE-NOT: unextended-module-overlay.yaml
// EXPLICIT: -ivfsoverlay
// EXPLICIT: unextended-module-overlay.yaml
// EXPLICIT: -DDUMMY

// SWIFT6: error: missing required modules: 'has_alias', 'struct_with_operators'