Skip to content

[ModuleInterfaceLoader] Save a parseArg in subInvocation #71890

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
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
32 changes: 13 additions & 19 deletions lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,17 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
interfacePath, diagnosticLoc))
return true;

// Prior to Swift 5.9, swiftinterfaces were always built (accidentally) with
// `-target-min-inlining-version target` prepended to the argument list. To
// preserve compatibility we must continue to prepend those flags to the
// invocation when the interface was generated by an older compiler.
if (auto toolsVersion = interfaceInfo.CompilerToolsVersion) {
if (toolsVersion < version::Version{5, 9}) {
interfaceInfo.Arguments.push_back("-target-min-inlining-version");
interfaceInfo.Arguments.push_back("target");
}
}

SmallString<32> ExpectedModuleName = subInvocation.getModuleName();
if (subInvocation.parseArgs(interfaceInfo.Arguments, *Diags)) {
return true;
Expand Down Expand Up @@ -2023,7 +2034,6 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
subInvocation.getFrontendOptions().InputsAndOutputs
.setMainAndSupplementaryOutputs(outputFiles, ModuleOutputPaths);

SmallVector<const char *, 64> SubArgs;
SwiftInterfaceInfo interfaceInfo;
// Extract compiler arguments from the interface file and use them to configure
// the compiler invocation.
Expand All @@ -2032,25 +2042,9 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
return std::make_error_code(std::errc::not_supported);
}

// Prior to Swift 5.9, swiftinterfaces were always built (accidentally) with
// `-target-min-inlining-version target` prepended to the argument list. To
// preserve compatibility we must continue to prepend those flags to the
// invocation when the interface was generated by an older compiler.
if (auto toolsVersion = interfaceInfo.CompilerToolsVersion) {
if (toolsVersion < version::Version{5, 9}) {
SubArgs.push_back("-target-min-inlining-version");
SubArgs.push_back("target");
}
}

SubArgs.insert(SubArgs.end(), interfaceInfo.Arguments.begin(),
interfaceInfo.Arguments.end());

// Insert arguments collected from the interface file.
BuildArgs.insert(BuildArgs.end(), SubArgs.begin(), SubArgs.end());
if (subInvocation.parseArgs(SubArgs, *Diags)) {
return std::make_error_code(std::errc::not_supported);
}
BuildArgs.insert(BuildArgs.end(), interfaceInfo.Arguments.begin(),
interfaceInfo.Arguments.end());

// If the target triple parsed from the Swift interface file differs
// only in subarchitecture from the original target triple, then
Expand Down