Commit Graph

148 Commits

Author SHA1 Message Date
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
Ben Barham
7cee600bcd [SILGen] Add flag to skip typechecking and SIL gen for function bodies
Adds a new flag "-experimental-skip-all-function-bodies" that skips
typechecking and SIL generation for all function bodies (where
possible).

`didSet` functions are still typechecked and have SIL generated as their
body is checked for the `oldValue` parameter, but are not serialized.
Parsing will generally be skipped as well, but this isn't necessarily
the case since other flags (eg. "-verify-syntax-tree") may force delayed
parsing off.
2020-11-06 12:08:19 +10:00
Brent Royal-Gordon
f71923778b Add -testable-import-module frontend flag
This is just like -import-module, but it does an @testable import. Simple, right?

Fixes rdar://66544654.
2020-10-09 18:59:20 -07:00
Xi Ge
00eb2e9db2 Frontend: add a frontend flag to disable building module from textual interface
This is for testing purposes to ensure prebuilt modules are up to date.

rdar://68770805
2020-10-05 11:52:05 -07:00
Robert Widmann
574ee39397 Stage in frontend flags for experimental cross-module incremental builds 2020-09-24 17:11:28 -06:00
Artem Chikin
12c356b3d2 Merge pull request #34028 from artemcm/dependencies-prescan
[Dependency Scanner] Add option to execute an import prescan
2020-09-22 14:48:56 -07:00
Artem Chikin
e0dbba569b [Dependency Scanner] Add option to execute an import prescan
With this option enabled, the dependency scanner gathers all import statements in source files of the main module (non-transitive) and outputs a list of imported modules.
This will be used by build systems and the swift-driver as a way to avoid redundant re-scanning in incremental contexts.
2020-09-22 11:04:31 -07:00
Varun Gandhi
7b967a8030 Merge pull request #33085 from varungandhi-apple/vg-clang-types-in-sil-retry
Propagate Clang function types through SIL
2020-09-22 08:48:34 -07:00
Varun Gandhi
983399c1e7 [Printer] Conditionally print Clang types in emitted SIL. 2020-09-16 10:34:43 -07:00
Robert Widmann
9fd5918786 Swap InputFileKind for ParseInputMode
Tying InputFile to this option meant that every input that was not one of the explictly-blessed kinds was modeled as a Swift file.

With the new InputFile that infers file kinds, we no longer need CompilerInvocation::setInputKind
2020-09-11 22:28:58 -06:00
Robert Widmann
d4b2e167ac Model ObjCHeader Inputs
These inputs were previously modeled as Swift files, which would lead to bizarre situations where parts of the pipeline expecting Swift inputs actually wound up parsing Objective-C.
2020-09-11 13:55:48 -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
Robert Widmann
4c56c95674 Define doesActionRequireInputs 2020-08-27 16:17:20 -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
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
Xi Ge
9988911232 Frontend: add a new action -scan-clang-dependencies to scan a PCM's dependencies
For the issue mentioned in rdar://67079780, swift-driver needs to run clang dependencies
scanner multiple times with different target triples for a Swift target. This patch adds
a new scanning action to generate the JSON file for a given clang module to accommodate
this requirement.

Resolves: rdar://problem/67269210
2020-08-17 22:02:32 -07:00
Brent Royal-Gordon
9bc787ef5f Add a “typecheck module interface” mode 2020-08-07 16:00:15 -07:00
Dario Rexin
0850436d9f Properly compute resource folder when linking statically
- deduplicate the logic to compute the resource folder
- install headers and module files in shared and static resource folders
- forward -static flag when calling swiftc with -print-target-info
2020-07-30 15:07:03 -07:00
Robert Widmann
2198d7174c Remove -debug-time-compilation
This flag no longer does anything now that the unified statistics
reporting infrastructure exists. It is better to use
-driver-time-compilation to see a bird's eye view of timing statistics
for frontend jobs, and -stats-output-dir to see a down-and-dirty view of
everything including performance counters.
2020-07-16 17:35:50 -07:00
Xi Ge
5f219cdc11 Front-end: disable interface file locking for the -compile-module-from-interface action
The situations where we use this action, e.g. explicit module building and
generating prebuilt module cache, don't need synchronization. We should avoid
using lock files for them.

rdar://65005528
2020-07-02 09:58:10 -07:00
Hamish Knight
7bc5440d17 [Frontend] Internalize createDependencyTracker
Expand the FrontendOptions to allow the enabling
of the dependency tracker for non-system
dependencies, and switch the previous clients of
`createDependencyTracker` over to using this
option. This ensures that the dependency tracker
is now set only during `CompilerInstance::setup`.
2020-06-29 15:26:26 -07:00
Doug Gregor
46f9f2147c [Frontend] Add --version as a frontend flag.
The new driver will defer to the frontend to print version information,
rather than embedded the version information itself.
2020-06-24 21:35:35 -07:00
Hamish Knight
0825fa5181 [Frontend] Enforce restrictions on private interfaces
Previously we may have silently bailed if a private
module interface path was specified, but the
frontend action didn't support it. Instead, make
sure we enforce the same restrictions that we
enforce for public module interfaces.
2020-06-18 08:58:30 -07:00
Xi Ge
01c18d01c1 Frontend: move ExplicitSwiftModules into SearchPathOptions, NFC 2020-06-02 16:51:45 -07:00
Xi Ge
3a214d99f6 Frontend: add an argument to disable implicitly built Swift modules 2020-06-02 16:51:45 -07:00
Hamish Knight
72bb47ee90 [Frontend] Remove InputFileKind::SwiftREPL 2020-05-07 11:00:02 -07:00
Hamish Knight
b78f47490a Move AST transforms out of the Frontend
Move the playground and debugger transforms out
of the Frontend and into `performTypeChecking`, as
we'd want them to be applied if
`performTypeChecking` was called lazily.
2020-04-28 14:44:17 -07:00
Doug Gregor
71e7d6a913 [Dependency scanning] Add implicit Swift and SwiftOnoneSupport dependencies 2020-04-24 12:58:45 -07:00
Doug Gregor
33cdd61835 Fast dependency scanning for Swift
Implement a new "fast" dependency scanning option,
`-scan-dependencies`, in the Swift frontend that determines all
of the source file and module dependencies for a given set of
Swift sources. It covers four forms of modules:

1) Swift (serialized) module files, by reading the module header
2) Swift interface files, by parsing the source code to find imports
3) Swift source modules, by parsing the source code to find imports
4) Clang modules, using Clang's fast dependency scanning tool

A single `-scan-dependencies` operation maps out the full
dependency graph for the given Swift source files, including all
of the Swift and Clang modules that may need to be built, such
that all of the work can be scheduled up front by the Swift
driver or any other build system that understands this
option. The dependency graph is emitted as JSON, which can be
consumed by these other tools.
2020-04-24 12:58:41 -07:00
Hamish Knight
453667f659 [Frontend] Validate ImplicitImportModuleNames early
Check whether the user has provided a valid
identifier when parsing the options. Also make
ImplicitImportModuleNames a private member of
FrontendOptions to prevent mutation after being
parsed.
2020-04-20 13:20:35 -07:00
Nathan Hawes
a785fa6cee [Frontend][Index] Add frontend option to skip indexing the stdlib (for test performance)
Several tests related to indexing system modules were taking a considerable
amount of time (100+ seconds in the worst case) indexing the standard library.
This adds a frontend option to skip it and updates those tests to pass it.
2020-03-25 14:36:23 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Xi Ge
df0493c288 PrintAsObjC: allow users to specify bridging header relative path for printing
Compatibility header may #import bridging header if specified with -import-underlying-module.
How these two headers are relative to each other is subject to project setting. To accommodate
this, we should allow users to specify bridging header directory for header generating purposes.

rdar://59110975
2020-03-11 17:09:53 -07:00
Robert Widmann
f85ec3825f Address review feedback 2020-03-03 16:46:04 -08:00
Robert Widmann
d3edb5b15a [Incremental] Plumb -verify-incremental-dependencies Through The Frontend and Driver
When enabled at the driver level, the frontends will inherit the flag. For each frontend that recieves this option, all primaries will have their reference dependencies validated.
2020-03-02 16:45:37 -08:00
Xi Ge
8c2a041822 Front-end: add an option to not lock interface file when building module
This could help fix a flaky test.

Related to: rdar://58578342
2020-02-25 12:13:14 -08:00
Robert Widmann
53b368b34f Always write out nested types tables
Remove the option to switch off nested types tables. In a world where
re-entrant direct lookup will cause deserialization to fail (or worse),
disabling these tables will only lead to further instability in the
compiler.
2020-02-10 10:41:23 -08:00
Varun Gandhi
d9a7a7d49e Revert "[Printer] Conditionally print Clang types in emitted SIL."
This reverts commit a27c5f0a16.
2020-01-22 09:04:52 -08:00
Varun Gandhi
a27c5f0a16 [Printer] Conditionally print Clang types in emitted SIL.
Hopefully, this helps us debug Clang type mismatches better.
2020-01-17 16:22:39 -08:00
Doug Gregor
61c83d2415 [Driver] Switch -print-target-triple to -print-target-info and add more info.
Rather than only emitting the target triple, provide additional
information about that particular target, including the module triple
(i.e., what file names will be used for Swift modules for that
triple), the runtime compatibility version if there is one, and
whether linking with rpaths is required for the standard library and
other libraries shipped with Swift. Encode this as JSON so we can
extend it in the future. For now, it looks like this:

```
{
  "target": {
    "triple": "arm64-apple-ios12.0",
    "moduleTriple": "arm64-apple-ios",
    "swiftRuntimeCompatibilityVersion": "5.0",
    "librariesRequireRPath": true
  }
}
```

Which you can deserialize into a TargetInfo instance as defined below:

```
struct Target: Codable {
  /// The target triple.
  var triple: String
  /// The triple used for module file names.
  var moduleTriple: String
  /// If this platform provides the Swift runtime, the Swift language
  version
  /// with which that runtime is compatible.
  var swiftRuntimeCompatibilityVersion: String?
  /// Whether linking against the Swift libraries requires the use of
  rpaths.
  var librariesRequireRPath: Bool
}

struct TargetInfo: Codable {
  var target: Target
}
```

Implements rdar://problem/47095159.
2019-12-06 22:17:29 -08:00
Doug Gregor
cfe25eabb0 [Driver/Frontend] Add -print-target-triple
Add a -print-target-triple command line option to the Swift frontend
and driver to allow other tools (e.g., SwiftPM) to query the host
triple as it is understood by the Swift compiler. This follows the
precedent set by Clang. Implements rdar://problem/57434967.
2019-12-05 17:23:13 -08:00
David Ungar
62ae2bfd2f Merge pull request #28164 from davidungar/WIP-custom-diff
[Incremental compilation] Source-range-based dependencies
2019-11-21 23:47:52 -08:00
Doug Gregor
ec70b62d5e Merge pull request #28107 from allevato/emit-pcm
Add driver flag to precompile Swift-compatible explicit Clang modules.
2019-11-14 10:25:53 -08:00
David Ungar
742c3985bd Source-range-based dependencies
Frontend outputs source-as-compiled, and source-ranges file with function body ranges and ranges that were unparsed in secondaries.
Driver computes diffs for each source file. If diffs are in function bodies, only recompiles that one file. Else if diffs are in what another file did not parse, then the other file need not be rebuilt.
2019-11-12 20:41:02 -08:00
Robert Widmann
422bb372d3 Teach the frontend how to parse TypeCheckerOptions 2019-11-12 09:54:06 -08:00
Tony Allevato
3c45041b17 Add driver modes to emit and dump Clang precompiled modules. 2019-11-11 15:00:51 -08:00
Harlan Haskins
104a568222 [TBDGen] Skip non-inlinable function bodies in InstallAPI
For now, until we figure out the right way to present
-experimental-skip-non-inlinable-function-bodies, make
-tbd-is-installapi imply that, for testing.
2019-10-17 10:25:44 -07:00
Xi Ge
0a396ab38f Front-end: add an option to ignore .swiftsourceinfo file for testing purposes
We generate .swiftsourceinfo for stdlib in the build directory because ABI checker
could issue diagnostics to the stdlib source. However, this may also change other
diagnostic tests. Both Brent and Jordan have raised concern about this. After
adding this flag, other diagnostic tests could ignore .swiftsourceinfo files even
though when they are present so our tests will reflect what most users experience
when sources for stdlib are unavailable.
2019-10-15 10:52:46 -07:00
Harlan Haskins
b904133c42 [Modules] Add flag to skip non-inlinable function bodies
This flag, currently staged in as `-experimental-skip-non-inlinable-function-bodies`, will cause the typechecker to skip typechecking bodies of functions that will not be serialized in the resulting `.swiftmodule`. This patch also includes a SIL verifier that ensures that we don’t accidentally include a body that we should have skipped.

There is still some work left to make sure the emitted .swiftmodule is exactly the same as what’s emitted without the flag, which is what’s causing the benchmark noise above. I’ll be committing follow-up patches to address those, but for now I’m going to land the implementation behind a flag.
2019-09-26 10:40:11 -07:00