Skip to content

Virtualize swift compiler outputs #63206

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

Conversation

cachemeifyoucan
Copy link
Contributor

Step 1 of making swift compiler output cacheable. Virtualize swift compiler outputs (not everything yet, but most of the important output to show feasibility) and add a mechanics to verify the output determinism through the newly added function.

Need some changes in LLVM swiftlang/llvm-project#6112

Feedbacks about how to structurally pass through VirtualBackends in swift compiler is welcomed.

@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci Please test

@cachemeifyoucan
Copy link
Contributor Author

Ah, I break lldb of course. let me try smoke test first.

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

@xedin xedin removed their request for review January 25, 2023 18:52
artemcm
artemcm previously approved these changes Jan 25, 2023
Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

Looks good to me.
Cool to have the frontend output determinism tests in-suite.

@cachemeifyoucan
Copy link
Contributor Author

For deterministic check to be really useful, need to add an option to bypass the laziness when modhash matches.

Also thinking I should just put the output backend into ASTContext which will make the code a lot cleaner.

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-swift-virtualize-output branch from d940dbe to fef81b9 Compare January 26, 2023 02:03
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

@cachemeifyoucan
Copy link
Contributor Author

Update: fix the tests and remove withOutputFile helper function to encourage use of output backend.

Now properly capture swiftdeps output but it is NOT deterministic.

@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-swift-virtualize-output branch from d3edb11 to 4a4fda1 Compare January 26, 2023 21:02
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

1 similar comment
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-swift-virtualize-output branch from 08920e3 to e73b6f3 Compare January 27, 2023 00:58
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-swift-virtualize-output branch 2 times, most recently from c6cffe4 to c148737 Compare February 1, 2023 21:48
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-swift-virtualize-output branch from 62b9ce1 to 6674e1b Compare April 4, 2023 06:26
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-swift-virtualize-output branch from 6674e1b to 11a25b8 Compare April 4, 2023 07:36
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

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

There were a couple of my minor comments from January that seemed to have been lost, but otherwise LGTM.

@@ -1135,6 +1135,13 @@ def enable_emit_generic_class_ro_t_list :
HelpText<"Enable emission of a section with references to class_ro_t of "
"generic class patterns">;

def enable_swift_deterministic_check :
Flag<["-"], "enable-swift-deterministic-check">,
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment wasn't addressed

@@ -1135,6 +1135,13 @@ def enable_emit_generic_class_ro_t_list :
HelpText<"Enable emission of a section with references to class_ro_t of "
"generic class patterns">;

def enable_swift_deterministic_check :
Flag<["-"], "enable-swift-deterministic-check">,
HelpText<"Check swift compiler output determinisim by run it twice">;
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment wasn't addressed

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-swift-virtualize-output branch from 11a25b8 to b15877b Compare April 4, 2023 23:01
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-swift-virtualize-output branch from b15877b to bfa53ff Compare April 5, 2023 00:46
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows future virtualization of swift
compiler outputs.
Add option to test swift compiler determinism by running the job twice
and compare the output produced.
Add an option to skip module hash checking that checks if swift compiler can
skip object file generation because it is going to produce the same
result. Always generation object file output when flag is used so we can
check for output determinism.
Batch mode depscan also gets diagnostics for output errors.
Support makefile style dependency file and imported modules. Need
improvements to virtual backend to allow emit loaded module trace file.
Add unit-tests for already virtualized outputs
@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-swift-virtualize-output branch from bfa53ff to 9be198f Compare April 5, 2023 07:04
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

Fix broken test cases on non-macos platforms.
@cachemeifyoucan
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#6112

@swift-ci please smoke test

@cachemeifyoucan cachemeifyoucan merged commit 09b8af8 into swiftlang:main Apr 5, 2023
@cachemeifyoucan cachemeifyoucan deleted the eng/PR-swift-virtualize-output branch April 5, 2023 15:34
kavon pushed a commit to kavon/swift that referenced this pull request Apr 7, 2023
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
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.

3 participants