Commit Graph

682 Commits

Author SHA1 Message Date
Robert Widmann
9d06eef2a6 Close Soundness Hole in Incremental Build
Fix a longstanding bug in the driver where the incremental build would
fail to execute dependent jobs and allow errors in primaries in later
waves to become buried. A simplified version of a situation that exposes
this bug has been committed into the tests.

Imagine two files:

```
// one.swift

struct A {}

// two.swift

func use() {
  let _ = A()
}
```

After a clean build, we modify one.swift as follows:

```
// one.swift

struct B< {}
```

The syntax error in this file caused the baseline driver to fail the
build immediately and thus we would not schedule two.swift for
execution. This is incorrect! Consider correcting the syntax error in
one.swift:

```
// one.swift

struct B {}
```

two.swift _still_ won't be rebuilt because
1) It was never modified during any step of this process
2) The swiftdeps of two.swift have not been updated to flush out the
   dependency on A.

rdar://72800626
2021-01-12 19:07:43 -08:00
Artem Chikin
082fc48b25 [Dependency Scanning] Refactor dependency scanner to return an in-memory format as a result
This commit refactors ScanDependencies.cpp to split the functionality into two functional groups:
- Scan execution code that performs the mechanics of the scan and produces an in-memory result
- Dependency scanner entry-points used when the scanning action is invoked as a `swift-frontend` execution mode
This commit also adds the aforementioned in-memory dependency scanning result in `FullDependencies.h`, modeled after the InterModuleDependencyGraph representation in swift-driver
2021-01-07 09:08:20 -08:00
Artem Chikin
dad14358fb [Dependency Scanning] Factor out import prescan into separate utility 2021-01-07 09:08:20 -08:00
Artem Chikin
aabcb22df1 Rename SwiftScan directory into DependencyScan 2021-01-07 09:08:20 -08:00
Artem Chikin
79d559e361 [Dependency Scanning] Deprecate and remove -scan-clang-dependencies
Since it was introduced, its use-case has been entirely subsumed by batch scanning.
2021-01-07 09:08:20 -08:00
Artem Chikin
07e07a1d8c [Dependency Scanning] Add DependencyScanningTool entry-point for batch scanning 2021-01-07 09:08:20 -08:00
Artem Chikin
7d1d8a4661 [Dependency Scanning] Factor ModuleDependenciesCache out of a CompilerInstance into callers of scanDependencies
It is now the responsibility of the scanDependencies code to instantiate (and share) the cache.
e.g. FrontendTool instantiates a new cache per `-scan-dependencies` invocation, and the DependencyScanningTool keeps one shared cache across its lifetime.
2021-01-07 09:08:20 -08:00
Artem Chikin
f3d217edc3 [Dependency Scanning] Add a C++ itnerface for a tool that answers dependency-scanning queries. 2021-01-07 09:08:20 -08:00
Slava Pestov
e675bee26c AST: Split off DependencyCollector.h from EvaluatorDependencies.h
Also remove some unnecessary #includes from DependencyCollector.h,
which necessitated adding #includes in various other files.
2020-12-23 00:00:25 -05:00
Artem Chikin
915186ab47 Refactor Basic/Parseable-Output to remove dependency on Driver & Frontend
Introducing new entry-points that can be used from both Driver and Frontend clients, using an intermediary new type: `DetailedMessagePayload`, when needed.
2020-12-14 11:35:56 -08:00
Artem Chikin
269f1b91bc Add host-specific include for getpid() in FrontendTool. 2020-12-11 16:01:04 -08:00
Artem Chikin
86e039f21c Suppress the output of the PrintingDiagnosticConsumer when in Frontend Parseable-Output mode 2020-12-11 16:01:04 -08:00
Artem Chikin
942cb0855e Implement frontend parseable-output batch job quasi-PID assignment.
Starting at a crude -1000, each invocation primary input will get its own unique quasi-Pid.
Invocations with only one primary (non-batch) will get a real OS Pid.

The selection of the constant starting point matches what the driver does when outputting its parseable output.
2020-12-11 16:01:04 -08:00
Artem Chikin
23e374ce78 Add support for emitting parseable-output "finished" message and per-primary messages for batched jobs
Inside swift-frontend
2020-12-11 16:01:03 -08:00
Robert Widmann
76d25e7097 [NFC] Fixup InputFile Convenience Getters
Follow programming guidelines for these getters more closely and have them return a non-owning view of the underlying data instead of relying on callers to take const references to the copy that is returned here.
2020-11-12 14:54:02 -08:00
Robert Widmann
a89f8e04d6 [NFC] Drop Unused Includes from FrontendTool 2020-11-12 14:54:02 -08:00
Robert Widmann
19e6bee374 [NFC] Use the Correct const-Qualification in Dependency Code
T *const does not prevent logically non-const accesses to the underlying data, it merely indicates that the pointer value itself is const. This modifier can be cast off by a copy, so it's not generally what you want here. Switch to const T * instead.
2020-11-12 10:57:56 -08:00
Robert Widmann
13c97a8905 [NFC] Downgrade CompilerInvocation to FrontendOptions 2020-11-11 14:33:24 -08:00
Robert Widmann
17143cb9c3 [NFC] Split ModuleTrace Infrastructure out of FrontendTool 2020-11-11 14:32:44 -08:00
Robert Widmann
adacecb47a [NFC] Split Make-Style Dependency Emission from FrontendTool 2020-11-11 14:32:43 -08:00
Ben Barham
b0577b0641 Merge pull request #34472 from bnbarham/benb/allow-errors-69815975
[Serialization] Add an option to output modules regardless of errors
2020-11-11 08:30:18 +10:00
Ben Barham
241559dc88 [Serialization] Add an option to output modules regardless of errors
Adds a new frontend option
"-experimental-allow-module-with-compiler-errors". If any compilation
errors occur while generating the .swiftmodule, this mode will skip SIL
entirely and only serialize the (likey invalid) AST.

This existence of this option during generation is serialized into the
resulting .swiftmodule. Errors found in deserialization are only allowed
if it is set.

Primarily intended for IDE requests (eg. indexing and code completion)
to ensure robust cross-module results, despite possible errors.

Resolves rdar://69815975
2020-11-10 14:47:22 +10:00
Xi Ge
e4916b8c85 Front-end: add a front-end action to print supported features of the compiler
This could help swift-driver to check whether a compiler feature is supported so
it could adjust arguments accordingly.
2020-11-09 14:34:49 -08:00
Erik Eckstein
1224cfa61b update and unify the "please file a bug report" message
The new message is:
"Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace."

1. In crash logs we used to print a message which points to the llvm bug tracking page. Now it points to the swift.org bug tracking guidelines.
2. Use the same message in all compiler diagnostics which ask the user to file a bug report.

rdar://problem/70488534
2020-10-23 11:57:22 +02:00
Brent Royal-Gordon
b440ab7331 [NFC] Move several types/functions to Import.h
To help consolidate our various types describing imports, this commit moves the following types and methods to Import.h:

* ImplicitImports
* ImplicitStdlibKind
* ImplicitImportInfo
* ModuleDecl::ImportedModule
* ModuleDecl::OrderImportedModules (as ImportedModule::Order)
* ModuleDecl::removeDuplicateImports() (as ImportedModule::removeDuplicates())
* SourceFile::ImportFlags
* SourceFile::ImportOptions
* SourceFile::ImportedModuleDesc

This commit is large and intentionally kept mechanical—nothing interesting to see here.
2020-10-09 18:57:07 -07:00
Robert Widmann
e646ef2cbe Add incrementalExternalDepend as an Incremental NodeKind 2020-09-25 01:16:01 -06:00
Robert Widmann
044f85ad9c Add ModuleDepGraphFactory
This completes the missing piece from #34073 and means the frontend may now serialize moduledecl-based dependencies.
2020-09-24 23:27:11 -06:00
Robert Widmann
76cd4bf160 [NFC] Differential Incremental External Dependencies in DependencyTracker
Also perform the plumbing necessary to convince the rest of the compiler that they're just ordinary external dependencies. In particular, we will still emit these depenencies into .d files, and code completion will still index them.
2020-09-24 23:25:47 -06:00
Robert Widmann
3c2b376aa2 [NFC] Refactor Reference Dependency Emission
Invert the responsibility of the entrypoint so that FrontendTool is directing the actual serialization work. The entrypoint now solely exists to construct a dependency graph.

While I'm here, prepare the way for serializing dependency graphs for modules by optimistically modeling a ModuleOrSourceFile input.
2020-09-24 20:07:02 -06:00
Mishal Shah
956b7a931c Merge pull request #34041 from apple/shahmishal/update-branch-doc
Update doc and links to support new main branch
2020-09-23 22:48:03 -07:00
Varun Gandhi
d3369f7711 [NFC] Rename ImportFilterKind cases to be clearer. 2020-09-23 12:50:20 -07:00
Mishal Shah
40024718ac Update doc and links to support new main branch 2020-09-22 23:53:29 -07:00
Robert Widmann
3287c4b271 [NFC] Refactor Main File Computation 2020-09-11 22:28:59 -06:00
Robert Widmann
c5a6cd6abe [NFC] Refactor getPrimaryOrMainSourceFile 2020-09-11 22:28:58 -06:00
Robert Widmann
a8766cce5b [NFC] Refactor InputFile's Accessors 2020-09-11 22:28:58 -06:00
Robert Widmann
8b725d8713 [NFC] Inline inputFileKindCanHaveTBDValidated 2020-09-11 21:24:26 -06:00
Robert Widmann
618b0b9eb6 Add doesActionPerformEndOfPipelineActions
For now, force the clang-based actions to skip the end of the pipeline. This restores the previous behavior of the frontend, but may not be desirable in the long run. For example, one may want to dump clang stats after running an -emit-pch job, but that is impossible without forcing the end of the pipeline to be more tolerant of ObjCHeader/modulemap-only inputs.

rdar://68587228
2020-09-11 13:57:28 -06:00
Robert Widmann
98765132c9 [Gardening] Document a Strange Sort 2020-09-09 10:39:22 -06:00
Max Desiatov
9685179e5f Merge pull request #33324 from kateinoigakukun/katei/swift-module-summary/frontend
[Frontend] Set up output file .swiftmodule.summary
2020-09-07 07:19:33 +01:00
Xi Ge
e107182f1a Merge remote-tracking branch 'apple/master' into master-rebranch 2020-09-02 18:36:37 -07:00
Varun Gandhi
4350a96303 Merge pull request #33640 from varungandhi-apple/vg-fix-module-trace-cycle
[ModuleTrace] Handle cycle detection edge case in module trace emission (ep2).
2020-09-02 11:59:52 -07:00
Varun Gandhi
3e7f33971c [ModuleTrace] Handle cycle detection edge case in module trace emission (ep2).
Fixes rdar://67704000.
2020-09-01 14:23:14 -07:00
Nathan Hawes
9da1d89520 Manually merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	lib/AST/ExtInfo.cpp
2020-08-31 10:50:54 -07:00
Robert Widmann
4c56c95674 Define doesActionRequireInputs 2020-08-27 16:17:20 -07:00
Robert Widmann
fe7444ffa3 Add doesActionRequireSwiftStandardLibrary 2020-08-27 16:17:20 -07:00
Robert Widmann
4c7ccf5abe [NFC] Clean Up FrontendTool
Try to impose a simple structure that splits performing actions from the
pre and post-pipeline conditions. Wherever actions would take more than
a simple return, split them into functions. Refine functions that
perform effects to return status codes when they fail. Finally,
delineate functions that need semantic analysis from those that do not.

Overall this should be NFC.
2020-08-27 16:15:44 -07: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
swift_jenkins
258b72273c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-24 21:36:02 -07: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
Nathan Hawes
280d4c995a Merge remote-tracking branch 'upstream/master' into HEAD 2020-08-21 22:23:58 -07:00