Commit Graph

693 Commits

Author SHA1 Message Date
Alexis Laferrière
758351110a [Sema] Allow the use of SPI in API for SPI modules
When the whole module has an SPI distribution, SPI declarations can be
used in API.

rdar://75335462
2021-04-20 15:02:51 -07:00
Varun Gandhi
cc14992281 [Frontend] Add -emit-irgen option to driver and frontend.
Fixes SR-14389, fixes rdar://75715690.
2021-03-31 11:56:36 -07:00
Ben Barham
a17593f026 [Frontend] Always output swiftdeps when allowing errors
A module is always output when allowing errors, make sure to output its
dependencies as well.
2021-03-25 16:19:09 +10:00
Ben Barham
ab5a42160c [Frontend] Always emit generated ObjectiveC header when allowing errors
Resolves rdar://75754282
2021-03-25 16:19:09 +10:00
Michael Gottesman
504b5f2058 [ossa][frontend] Separately namespace enable-ossa-modules in the prebuilt module cache so that the flag causes recompilation of imported resilient modules when the flag is enabled.
This will enable users to try out the '-enable-ossa-modules' flag if their
compiler supports it and get OSSA code on all inlinable code that they use. The
idea is that this is a nice way to stage this in and get more testing.

The specific implementation is that the module interface loader:

1. Knows if enable ossa modules is enabled not to search for any compiled
modules. We always rebuild from the interface file on the system.

2. Knows that if enable ossa modules is enabled to mixin a bit into the module
interface loader cache hash to ensure that we consider the specialized ossa
compiled modules to be different than the modules in that cache from the system.

This ensures that when said flag is enabled, the user transparently gets all
their code in OSSA form from transparent libraries.
2021-03-18 13:03:51 -07:00
Robert Widmann
7f7978370b Merge pull request #36111 from CodaFi/cross-over-episode
Add Real Enable/Disable Flags for Cross-Module Incremental Builds
2021-03-02 16:07:11 -08:00
Robert Widmann
28a37a427f Add Real Enable/Disable Flags for Cross-Module Incremental Builds
In the legacy driver, these flags will merely be propagated to the
frontends to indicate that they should disable serialization of
incremental information in swift module files.

In the new driver, these flags control whether the Swift driver performs
an incremental build that is aware of metadata embedded in the module.

Kudos to David for coming up with our new marketing name: Incremental
Imports.

rdar://74363450
2021-03-01 10:15:25 -08:00
Nathan Hawes
821345c834 [Frontend] Add a new -index-unit-ouput-path and filelist equivalent to the frontend
These new options mirror -o and -output-filelist and are used instead
of those options to supply the output file path(s) to record in the
index store. This is intended to allow sharing index data across
builds in separate directories that are otherwise equivalent as far
as the index data is concered (e.g. an ASAN build and a non-ASAN build)
by supplying the same -index-unit-output-path for both.

Resolves rdar://problem/74816412
2021-02-27 13:06:22 +10:00
Varun Gandhi
f9570b2d34 [NFC] Pass full convention printing boolean for types etc.
When -experimental-print-full-convention is set, we should be printing
the full convention in diagnostics, doc comments etc.
2021-01-25 18:47:39 -08:00
Robert Widmann
cc0d919653 Remove Compiled Source 2021-01-13 23:00:16 -08:00
Robert Widmann
2475095021 Remove Ranges File Type 2021-01-13 22:42:17 -08:00
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