Skip to content

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

Merged
merged 6 commits into from
Sep 25, 2019

Conversation

nkcsgexi
Copy link
Contributor

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

@nkcsgexi nkcsgexi force-pushed the add-source-info-to-driver branch 2 times, most recently from 7ec2641 to 7878e86 Compare September 20, 2019 23:10
@nkcsgexi
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

@nkcsgexi
Copy link
Contributor Author

@swift-ci Please Build Toolchain Linux Platform

@swift-ci
Copy link
Contributor

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - 7878e8657efe96c9831d7546f15cac4d0081b4ef

Install command
tar zxf swift-PR-27277-277-ubuntu16.04.tar.gz
More info

@swift-ci
Copy link
Contributor

macOS Toolchain
Download Toolchain
Git Sha - 7878e8657efe96c9831d7546f15cac4d0081b4ef

Install command
tar -zxf swift-PR-27277-373-osx.tar.gz --directory ~/

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

@nkcsgexi nkcsgexi force-pushed the add-source-info-to-driver branch from 8d24ddf to 8a237ef Compare September 23, 2019 21:21
@nkcsgexi
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi changed the title [WIP] Frontend: set up output file .swiftsourceinfo Frontend: set up output file .swiftsourceinfo Sep 23, 2019
Copy link
Contributor

@jrose-apple jrose-apple left a 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.

@@ -2786,6 +2789,41 @@ void Driver::chooseSwiftModuleOutputPath(Compilation &C,
}
}

void Driver::choosePrivateOutputFilePath(Compilation &C,
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Will do.

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@@ -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");
Copy link
Contributor

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 & {
Copy link
Contributor

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);
Copy link
Contributor

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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent source info. :-)

// 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
Copy link
Contributor

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?

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

@nkcsgexi
Copy link
Contributor Author

@swift-ci Please Build Toolchain Linux Platform

@nkcsgexi nkcsgexi force-pushed the add-source-info-to-driver branch from a1d0f60 to 7013725 Compare September 24, 2019 20:52
@nkcsgexi
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

@nkcsgexi
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@nkcsgexi
Copy link
Contributor Author

@swift-ci please test

@nkcsgexi
Copy link
Contributor Author

@swift-ci Please test OS X platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7878e8657efe96c9831d7546f15cac4d0081b4ef

@davidungar
Copy link
Contributor

LGTM

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

@swift-ci Please smoke test

@nkcsgexi nkcsgexi merged commit adb0e6e into swiftlang:master Sep 25, 2019
@compnerd
Copy link
Member

compnerd added a commit to compnerd/apple-swift that referenced this pull request Sep 26, 2019
Account for different path separators.
compnerd added a commit that referenced this pull request Sep 27, 2019
tests: fix test failure on Windows after #27277
roop pushed a commit to roop/swift that referenced this pull request Nov 5, 2019
Account for different path separators.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants