Commit Graph

650 Commits

Author SHA1 Message Date
QuietMisdreavus
419483863f Revert "[Driver][Frontend] add the symbol graph dir to the supplementary file map" 2021-04-22 12:20:14 -06:00
Victoria Mitchell
97a4cba250 add the symbol graph dir to the supplementary file map
rdar://75582169
2021-03-24 09:44:23 -05:00
Argyrios Kyrtzidis
f4f3d52de5 Merge pull request #36456 from ahoppen/pr/no-xcrun-in-sourcekitd
[Driver] Don't validate arclite linking if the driver is only set up to get the swift-frontend invocation
2021-03-16 20:11:27 -07:00
Alex Hoppen
7e6b5b24a4 [Driver] Don't validate arclite linking if the driver is only set up to get the swift-frontend invocation
If the driver is only set up to get the frontend invocation (e.g. from sourcekitd), don't validate that we can link against ARCLite because
a) we don't care about link-time when we are only interested in the frontend invocation
b) finding arclite might cause us to find clang using xcrun which in turn can cause sourcekitd to hang.

rdar://50659268
2021-03-16 23:47:50 +01:00
Owen Voorhees
77efd77d23 [APIDigester] Build the API digester as a frontend tool instead of a standalone executable 2021-03-10 19:30:10 -08:00
Nathan Hawes
117f03b2f5 [Driver][Index] Add driver support to specify an overriding output path to record in the index data
The frontend supports this via new options -index-unit-output-path and
-index-unit-output-path-filelist that mirror -o and -output-filelist. These are
intended to allow sharing index data across builds in separate directories (so
different -o values) that are otherwise equivalent as far as the index data is
concerned (e.g. an ASAN build and a non-ASAN build) by supplying the same
-index-unit-output-path for both.

This change updates the driver to add these new options to the frontend
invocation 1) when a new "index-unit-output-path" entry is specified for one
or more input files in the -output-file-map json or 2) if -index-file is
specified, when a new -index-unit-output-path driver option is passed.

Resolves rdar://problem/74816412
2021-03-06 13:44:14 +10:00
Steven Wu
02c41656be swift-api-extract to generate JSON API information
Add a new swift-frontend driver option that extract APIs in the swift
module and print in JSON format. This is to allow tooling to understand
and process swift APIs without the need to be a swift compiler or
understand swift module/AST.
2021-02-15 15:04:52 -08:00
Robert Widmann
1884e382b0 Merge pull request #35741 from CodaFi/a-distinction-without-a-difference 2021-02-04 08:31:36 -08:00
Xi Ge
dd83f17fbc Frontend: allow retrying expanding response files in argument lists
We've seen bad file descriptor errors in certain build environments (rdar://73157185) and retrying
opening those files seems to be a walkaround. In this change, we allow the
compiler to retry expanding reponse files in argument lists.

rdar://73892564
2021-02-03 16:05:40 -08:00
Robert Widmann
764df6dc70 Fold Incremental External Dependency Nodes Into External Dependency Nodes
Remove this distinction without a difference. Originally, the thought
was to
1) Isolate the cross-module build infrastructure
2) Provide a signal to the driver that a dependency had swiftdeps info
   in it

But the driver need only notice swiftmodule files as external
dependencies and try to extract that information if it can to divine the
signal it needs. Additionally, we can give it fingerprints as priors to
let it know there might be incremental info to be had.
2021-02-03 11:46:04 -08:00
Robert Widmann
129f6eb90f [NFC] Silence -Wsuggest-override Warnings 2021-02-02 09:22:18 -08:00
Robert Widmann
d427d38bd2 Remove SourceComparator 2021-01-13 22:42:17 -08:00
Robert Widmann
d15bcc3670 Remove Argument Parsing For Source Ranges 2021-01-13 17:12:27 -08:00
Robert Widmann
127a33ec8c Remove SourceRangeBasedInfo 2021-01-13 17:11:20 -08:00
Robert Widmann
35c45949a2 Remove IncrementalSchemeComparator 2021-01-13 16:49:19 -08:00
Artem Chikin
b827875c5e Sink the parseable-output library into Basic from Driver 2020-12-11 16:01:03 -08:00
Robert Widmann
859b87fd8c Move The Last Pieces for Cross-Module Incremental Builds
We're going to play a dirty, dirty trick - but it'll make our users'
lives better in the end so stick with me here.

In order to build up an incremental compilation, we need two sources of
dependency information:

1) "Priors" - Swiftdeps with dependency information from the past
   build(s)
2) "Posteriors" - Swiftdeps with dependencies from after we rebuild the
   file or module or whatever

With normal swift files built in incremental mode, the priors are given by the
swiftdeps files which are generated parallel to a swift file and usually
placed in the build directory alongside the object files. Because we
have entries in the output file map, we can always know where these
swiftdeps files are. The priors are integrated by the driver and then
the build is scheduled. As the build runs and jobs complete, their
swiftdeps are reloaded and re-integrated. The resulting changes are then
traversed and more jobs are scheduled if necessary. These give us the
posteriors we desire.

A module flips this on its head. The swiftdeps information serialized
in a module functions as the *posterior* since the driver consuming the
module has no way of knowing how to rebuild the module, and because its
dependencies are, for all intents and purposes, fixed in time. The
missing piece of the puzzle is the priors. That is, we need some way of
knowing what the "past" interface of the module looked like so we can
compare it to the "present" interface. Moreover, we need to always know
where to look for these priors.

We solve this problem by serializing a file alongside the build record:
the "external" build record. This is given by a... creative encoding
of multiple source file dependency graphs into a single source file
dependency graph. The rough structure of this is:

   SourceFile => interface <BUILD_RECORD>.external
   | - Incremental External Dependency => interface <MODULE_1>.swiftmodule
   | | - <dependency> ...
   | | - <dependency> ...
   | | - <dependency> ...
   | - Incremental External Dependency => interface <MODULE_2>.swiftmodule
   | | - <dependency> ...
   | | - <dependency> ...
   | - Incremental External Dependency => interface <MODULE_3>.swiftmodule
   | - ...

Sorta, `cat`'ing a bunch of source file dependency graphs together but
with incremental external dependency nodes acting as glue.

Now for the trick:

We have to unpack this structure and integrate it to get our priors.
This is easy. The tricky bit comes in integrate itself. Because the
top-level source file node points directly at the external build record,
not the original swift modules that defined these dependency nodes, we
swap the key it wants to use (the external build record) for the
incremental external dependency acting as the "parent" of the dependency
node. We do this by following the arc we carefully laid down in the
structure above.

For rdar://69595010
Goes a long way towards rdar://48955139, rdar://64238133
2020-12-10 18:45:21 -08:00
Robert Widmann
905c3d8830 [Gardening] Document Compilation::Result 2020-12-09 19:28:50 -08:00
Robert Widmann
d4e76d0a47 [NFC] Use Result::code to Simplify Some Callsites 2020-12-09 19:28:50 -08:00
Robert Widmann
d4022929c1 [NFC] Mark Result as move-only
This required dropping some superfluous 'const' qualification in the module dependency graph.
2020-12-09 19:28:50 -08:00
Robert Widmann
3ecb0b0b06 [NFC] Move "HadAbnormalExit" Flag Into Compilation::Result 2020-12-09 19:25:56 -08:00
Robert Widmann
d815e2724a [NFC] Add Compilation::Result
In order to extract the module dependency graph from the compilation the driver just ran, define a separate semantic type to hold a result code and the graph itself.
2020-12-09 19:25:56 -08:00
Robert Widmann
2b2c5dcf79 [NFC] Move findJobsToRecompileWhenNodesChange Into The Headers
So the compiler has a chance to see the definition for itself, rather than having to. manually force a specialization.
2020-12-07 15:22:15 -08:00
Robert Widmann
27d29262b0 [NFC] Traffic in Fingerprints 2020-11-18 12:20:14 -08:00
Robert Widmann
e2e19dcf82 Add Compilation "Wave" Assertion in +Asserts Builds
The "wave" of a compilation job describes the number of indirections through other compile jobs the driver required to reach the decision to schedule a job. In incremental mode, it should always be the case that it takes no more than two complete waves to arrive at a fixpoint in the build. This is a natural consequence of the structure of the dependencies emitted by the Swift frontend - namely we rely on transitivity in dependency arcs.

A quick proof sketch: Suppose an arbitrary perturbation of the inputs to an incremental compilation session are made. In the first wave, dependency edges from the prior build's state (the "zeroeth wave") are loaded and the files corresponding to invalidated edges are scheduled into the first wave. Supposing the second wave is not the null set - the trivial case - there are additional arcs that were invalidated. Now suppose that there were a third wave. Take an arbitrary arc invalidated by this third wave. It must be the case that the file containing the use is not new - else it would be scheduled. Further it must be the case that its def was not invalidated by the zeroeth or first waves of compilation otherwise we would have scheduled it into the first or second waves. Finally, it must have a use that was discovered in the second wave. But in order for that use to have been included in the second wave, there must have been an invalidated arc created by the first wave. By transitivity of dependency arcs, there must therefore be a dependency arc from a definition invalidated in the first wave to our third wave job, which implies that the file would be scheduled into the second wave!

[Insert contradiction pig image here]
2020-10-21 19:36:43 -07:00
Robert Widmann
4f49b6ab81 Merge pull request #34231 from CodaFi/skippy
Skip Merge-Modules When We Can
2020-10-08 14:41:01 -07:00
Robert Widmann
164bd08623 Merge pull request #34219 from CodaFi/negative-externalities
Keep a Cache of Externally-Dependent Jobs
2020-10-07 19:40:30 -07:00
Robert Widmann
a81cf936ee [NFC] Promote MergeModuleJobAction to an IncrementalJobAction 2020-10-07 16:56:48 -07:00
Robert Widmann
d29dcf8901 [NFC] Upgrade CompileJobAction::InputInfo::Status to an enum class 2020-10-07 16:56:48 -07:00
Robert Widmann
83f5162f9e [NFC] Reorder InputInfo::Status In Terms of Impact on the Incremental Build 2020-10-07 16:56:48 -07:00
Robert Widmann
25978e1ac9 [NFC] Add InputInfo::makeNeedsCascadingRebuild 2020-10-07 16:56:48 -07:00
Robert Widmann
d3c6d36af9 Fixup Use-of-Temporary
The Optional parameter here was being copied instead of being taken by
const reference. The expectation is that we call this function and
extract the data from a ModuleDepGraphNode node, but instead we were
extracting a copy which would promptly blow up.

Thanks ASAN!
2020-10-07 16:13:03 -07:00
Robert Widmann
e5737bc5cb [NFC] Insert IncrementalJobAction into the Action Hierarchy
This will be used to extend incremental behavior to merge-modules and the bridging header precompile step.
2020-10-07 12:07:16 -07:00
Robert Widmann
b0f0587963 Keep a Cache of Externally-Dependent Jobs
A more durable form of #34218. Keep a side cache of externally-dependent
jobs for now. This ensures our pseudo-Jobs don't get prematurely
deallocated before the tracing machinery has had a chance to report the
structure of the Job graph.

rdar://70053563
2020-10-07 10:39:17 -07:00
Robert Widmann
d7cd605c31 Adjust the Registration of the Pseudo-Job for External Incremental Dependencies
Register the module the external dependencies ride in with the pseudo-job in the Driver. This is a hack.
2020-10-05 18:42:28 -07:00
Robert Widmann
964f640636 Drop "Private Deps" Flag
In order for type body fingerprints to work, these declarations must always be included. Drop the ability to turn this off.
2020-10-01 14:40:45 -07:00
Robert Widmann
74765a8ba8 Remove Type Body Fingerprints Flags
This infrastructure has more than proven itself. Drop the code paths and tests supporting the status quo.
2020-10-01 13:09:00 -07:00
Robert Widmann
7917d723c3 Teach the Driver to Read Fine-Grained Dependency Graphs in Swiftdeps Files 2020-09-25 11:36:11 -06:00
Robert Widmann
3ba33b93eb Install Faux Cross-Module Incremental Infrastructure In Driver
Treat any incremental external depends like normal external depends. This will eventually become the fallback behavior for cross-module incremental builds.
2020-09-25 01:16:01 -06:00
Robert Widmann
48415ad228 [NFC] Stage in driver flags for experimental cross-module incremental builds 2020-09-24 17:10:57 -06:00
Robert Widmann
14188f4428 Remove ~moduleonly Duplicate of Compilation Record
We thought we would need this while exploring  certain pre-build optimizations a la rdar://problem/37725110. This information was never used.
2020-09-24 11:42:06 -06:00
Michael Gottesman
f196c16532 Merge pull request #32430 from kateinoigakukun/katei/llvm-lto-driver
[LTO] Support LLVM LTO for driver
2020-09-18 14:49:07 -05:00
Yuta Saito
43fb346b67 [Frontend] Set up output file .swiftmodule.summary
This patch focus on teaching frontend and driver to emit this file.
The actual serialization and deserialization implementation will come
later.
2020-08-27 00:41:16 +09:00
Brent Royal-Gordon
8fbd449501 Merge pull request #33114 from brentdax/check-your-interfaces-at-the-door
Verify that just-emitted module interfaces parse and typecheck
2020-08-24 20:33:58 -07:00
David Zarzycki
1e940c2c7e [NFC] Fix -Wsuggest-override warnings
LLVM, as of 77e0e9e17daf0865620abcd41f692ab0642367c4, now builds with
-Wsuggest-override. Let's clean up the swift sources rather than disable
the warning locally.
2020-08-13 16:17:46 -04:00
Brent Royal-Gordon
5f523fee66 Add flag to verify just-emitted module interfaces
The driver can now schedule jobs which typecheck just-emitted module interfaces to ensure that they can be consumed later. This can be enabled manually by passing `-verify-emitted-module-interface` to the driver.
2020-08-07 17:45:03 -07:00
Yuta Saito
d6cddaabb5 [LTO] Support LLVM LTO for driver
This commit adds LTO support for handling linker options and LLVM BC
emission. Even for ELF, swift-autolink-extract is unnecessary because
linker options are embeded in LLVM BC content when LTO.
2020-07-31 10:17:59 +09:00
Florian Friedrich
67073c7a67 Fix typo in comparison in comments and help text 2020-07-09 18:05:25 +02:00
martinboehme
40104ba8b1 Link against the C++ standard library when C++ interop is enabled (#30914)
This doesn't yet allow including C++ headers on platforms where libc++
isn't the default; see comments in UnixToolChains.cpp for details.

However, it does, for example, allow throwing and catching exceptions in C++
code used through interop, unblocking
https://github.com/apple/swift/pull/30674/files.

The flags (-enable-experimental-cxx-interop and -experimental-cxx-stdlib) carry
"experimental" in the name to emphasize that C++ interop is still an
experimental feature.

Co-authored-by: Michael Forster <forster@google.com>
2020-07-09 15:59:26 +02:00
Saleem Abdulrasool
71309a8fa9 Revert "[LTO] Support LLVM level link time optimization on Darwin, Linux and Windows" 2020-06-07 11:25:48 -07:00