-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Frontend: set up output file .swiftsourceinfo #27277
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
Frontend: set up output file .swiftsourceinfo #27277
Conversation
7ec2641
to
7878e86
Compare
@swift-ci Please Build Toolchain macOS Platform |
@swift-ci Please Build Toolchain Linux Platform |
Linux Toolchain (Ubuntu 16.04) Install command |
macOS Toolchain Install command |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
@swift-ci Please Build Toolchain macOS Platform |
8d24ddf
to
8a237ef
Compare
@swift-ci Please Build Toolchain macOS Platform |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, also not happy how much it took. cc @davidungar for later thought on how to streamline some of this.
lib/Driver/Driver.cpp
Outdated
@@ -2786,6 +2789,41 @@ void Driver::chooseSwiftModuleOutputPath(Compilation &C, | |||
} | |||
} | |||
|
|||
void Driver::choosePrivateOutputFilePath(Compilation &C, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: can you put "module" in the name of this function somewhere? I don't know if all private outputs belong in the module folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternately, is it possible to combine this with the swiftdoc helper and just have a flag to say "Private" or not? Duplicated code is code that gets out of sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Will do.
lib/Driver/Driver.cpp
Outdated
llvm::sys::path::append(Path, "Private"); | ||
// If the build system has created a Private dir for us to include the file, use it. | ||
if (!llvm::sys::fs::exists(Path)) { | ||
llvm::sys::path::remove_filename(Path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, clever. And I guess we can look in both places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the source info loader should look into both places and prefer the Private
one.
lib/Driver/ToolChains.cpp
Outdated
@@ -907,6 +912,8 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job, | |||
|
|||
addOutputsOfType(Arguments, context.Output, context.Args, | |||
file_types::TY_SwiftModuleDocFile, "-emit-module-doc-path"); | |||
addOutputsOfType(Arguments, context.Output, context.Args, | |||
file_types::TY_SwiftSourceInfoFile, "-emit-module-source-info-path"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: 80 columns.
@@ -435,6 +435,12 @@ bool FrontendInputsAndOutputs::hasModuleDocOutputPath() const { | |||
return outs.ModuleDocOutputPath; | |||
}); | |||
} | |||
bool FrontendInputsAndOutputs::hasModuleSourceInfoOutputPath() const { | |||
return hasSupplementaryOutputPath( | |||
[](const SupplementaryOutputPaths &outs) -> const std::string & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: funny indentation here.
SharedTimer timer("Serialization, swiftsourceinfo, to buffer"); | ||
llvm::SmallString<1024> buf; | ||
llvm::raw_svector_ostream stream(buf); | ||
writeSourceInfoToStream(stream, DC); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harlanhaskins This always using a buffer is unfortunate; ideally we'd only use it when we're going to keep it in memory.
@@ -502,3 +502,7 @@ void serialization::writeDocToStream(raw_ostream &os, ModuleOrSourceFile DC, | |||
|
|||
S.writeToStream(os); | |||
} | |||
|
|||
void serialization::writeSourceInfoToStream(raw_ostream &os, ModuleOrSourceFile DC) { | |||
os << "Some stuff"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent source info. :-)
test/Driver/sourceinfo_file.swift
Outdated
// RUN: mkdir -p %t/build/Private | ||
// RUN: %swiftc_driver -driver-print-jobs -emit-module %s -emit-module-path %t/build/sourceinfo_file.swiftmodule -module-name sourceinfo_file | %FileCheck %s -check-prefix CHECK-PRIVATE | ||
|
||
// CHECK-PRIVATE: Private/sourceinfo_file.swiftsourceinfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check that this is build/Private/sourceinfo_file.swiftsourceinfo
?
@swift-ci please smoke test |
@swift-ci Please Build Toolchain macOS Platform |
@swift-ci Please Build Toolchain Linux Platform |
This patch will focus on teaching driver and frontend to emit this file. The actual content and de-serialization parts will come later. More details: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation/28794
a1d0f60
to
7013725
Compare
@swift-ci Please Build Toolchain macOS Platform |
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci Please test OS X platform |
Build failed |
LGTM |
@swift-ci please smoke test |
@swift-ci Please smoke test |
@nkcsgexi I think that this may have regressed the windows build: https://dev.azure.com/compnerd/windows-swift/_build/results?buildId=9686&view=logs&j=2d2b3007-3c5c-5840-9bb0-2b1ea49925f3&t=2fdae087-0aee-589c-2ab0-2b8fc539478d&l=184 |
Account for different path separators.
tests: fix test failure on Windows after #27277
Account for different path separators.
This patch will focus on teaching driver and frontend to emit this file.
The actual content and de-serialization parts will come later.
More details: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation/28794