Commit Graph

60 Commits

Author SHA1 Message Date
Arnold Schwaighofer
b30bd40b83 Add code to create llvm::RemarkStreamer objects for all the LLVMModules in WMO mode
rdar://154403078
2025-07-01 07:19:33 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Steven Wu
3e903688a2 [ScanDependency] Do not use public/private swiftinterface in the same package
When scanning finds a dependency in the same package, do not load
public/private swiftinterface since they do not have the package level
decl to compile the current module. Always prefer package module (if
enabled), or use binary module, unless it is building a public/private
swiftinterface file in which case the interface file is preferred.

This also does some clean up to sync up the code path between implicit
and explicit module finding path.

rdar://122356964
2024-02-28 17:34:03 -08:00
Steven Wu
b4e5e78bce [SupplementaryOutputs][NFC] Simplify boilerplate output checks.
Reduce some boilerplate code to check if supplementary outputs exist.
2024-02-01 13:43:40 -08:00
Steven Wu
76bde39ee7 [Caching] Encoding cache key for input file with index instead of path
Avoid path encoding difference (for example, real_path vs. path from
symlink) by eliminating the path from cache key. Cache key is now
encoded with the index of the input file from all the input files from
the command-line, reguardless if those inputs will produce output or
not. This is to ensure stable ordering even the batching is different.

Add a new cache computation API that is preferred for using input index
directly. Old API for cache key is deprecated but still updated to
fallback to real_path comparsion if needed.

As a result of swift scan API change, rename the feature in JSON file to
avoid version confusion between swift-driver and libSwiftScan.

rdar://119387650
2023-12-18 14:06:00 -08:00
Ellie Shin
e8d43434db Merge pull request #69733 from apple/es-pkg-intf
Introduce a package interface
2023-11-15 03:53:49 -08:00
Ellie Shin
aba3b6c24e Introduce a package interface.
It has an extension .package.swiftinterface and contains package decls
as well as SPIs and public/inlinable decls. When a module is loaded
from interface, it now looks up the package-name in the interface
and checks if the importer is in the same package. If so, it uses
that package interface found to load the module. If not, uses the existing
logic to load modules.

Resolves rdar://104617854
2023-11-08 14:56:20 -08:00
Steven Wu
30cfa3deb2 [Caching] Re-associate diagnostics cache key with InputFile
Change how cached diagnostics are stored inside the CAS. It used to be
stored as a standalone entry for a frontend invocation in the cache and
now it is switched to be associated with input files, stored together
with other outputs like object files, etc.

This enables cleaner Cache Replay APIs and future cached diagnostics
that can be splitted up by file contribution.
2023-10-30 16:02:19 -07:00
Allan Shortlidge
e1f2e25ed5 Frontend: Introduce -emit-api-descriptor flag.
An "API descriptor" file is JSON describing the externally accessible symbols
of a module and metadata associated with those symbols like availability and
SPI status. This output was previously only generated by the
`swift-api-extract` alias of `swift-frontend`, which is desgined to take an
already built module as input. Post-processing a built module to extract this
information is inefficient because the module and the module's dependencies
need to be deserialized in order to visit the entire AST. We can generate this
output more efficiently as a supplementary output of the -emit-module job that
originally produced the module (since the AST is already available in-memory).
The -emit-api-descriptor flag can be used to request this output.

This change lays the groundwork by introducing frontend flags. Follow up
changes are needed to make API descriptor emission during -emit-module
functional.

Part of rdar://110916764.
2023-10-05 11:40:53 -07:00
Steven Wu
c153210505 [CAS] Add test case for cache key computation
Add tool swift-cache-tool for caching related testing and inspection.
2023-04-24 13:56:33 -07:00
Steven Wu
c7d66b8845 Teach swift to compute cache key for compiler outputs
Teach swift how to serialize its input into CAS to create a cache key
for compiler outputs. To compute the cache key for the output, it first
needs to compute a base-key for the compiler invocation. The base key is
computed from: swift compiler version and the command-line arguments for
the invocation.

Each compiler output from swift will gets its own key. The key for the
output is computed from: the base key for the compiler invocation + the
primary input for the output + the output type.
2023-04-24 13:55:38 -07:00
Artem Chikin
b1fee939f1 Add supplementary output path handling for extracted compile-time-known values 2022-07-19 16:24:26 -07:00
Josh Soref
38c0de0598 Spelling frontend (#42465)
* spelling: calculated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: compilations

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: containing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: dependency

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: dependent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: diagnose

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: explicit

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: explicitly

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: feature

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: fulfill

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: fulfillment

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: invoke

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: module

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: multiple

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: nonexistent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: omitted

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: optimization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: performing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: primaries

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: propagate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: sacrifices

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: scanned

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: substitution

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: successful

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: typecheck

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unobtrusive

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: utilities

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-20 15:18:37 -07:00
Alex Lorenz
2e3aa87737 Revert "Revert "Merge pull request #41831 from hyp/unify-header""
This reverts commit 4c9582c295.
2022-03-19 13:36:28 -07:00
Alex Lorenz
4c9582c295 Revert "Merge pull request #41831 from hyp/unify-header"
This reverts commit cd93d23bac, reversing
changes made to f9f5476e9a.
2022-03-18 10:03:07 -07:00
Alex Lorenz
9d52099d5b [cxx-interop] start to emitting a unified header file for a Swift module
This change removes the -emit-cxx-header option, and adds a new -emit-clang-header-path option instead. It's aliased to -emit-objc-header-path for now, but in the future, -emit-objc-header-path will alias to it. After this change Swift can start emitting a single header file that can be expose declarations to C, Objective-C, or C++. For now C++ interface is generated (for all public decls) only when -enable-cxx-interop flag is passed, but that behavior will change once  attribute is supported.
2022-03-17 10:34:47 -07:00
Alex Lorenz
6486c3c1d8 [interop] add an option to emit C++ header interface for a module 2022-01-19 18:55:14 -08:00
Xi Ge
2d43a9259e Frontend: teach final module emitting jobs to dump a placeholder file for module semantic info
This additional supplement output should capture semantic info the compiler has
captured while building a Swift module. Similar to the source info file, the content of
the semantic info file should only be consumed by local tooling written in Swift.
2021-10-11 18:19:26 -07:00
Argyrios Kyrtzidis
d3ba531e64 [frontend] Support passing the optimization record file via the supplemental outputs map
The Swift driver is passing the optimization record file path via the supplementals output, instead of the flag, on certain circumstances.
Enhance the frontend to check supplemental outputs otherwise the record file will not get emitted when using the new swift driver.
2021-09-02 11:13:34 -07:00
Xi Ge
1a660c08ca Frontend: teach -compile-module-from-interface action to emit ABI descriptor as byproduct
We have implemented a libSwiftDriver-based tool to generate prebuilt module cache for
entire SDKs. Anchored on the same infrastructure, we could also generate ABI baselines
for entire SDKs.
2021-08-20 15:47:10 -07: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
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
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
Rintaro Ishizaki
bf5d22257a [Frontend] Opt-in missing file recovery 2020-12-04 15:23:43 -08:00
Robert Widmann
a8766cce5b [NFC] Refactor InputFile's Accessors 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
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
Alexis Laferrière
901392896d [Frontend] Output the private module interface with the SPI info 2020-02-19 14:17:14 -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
Jordan Rose
8ff1dac381 [AST] Break some header dependencies for faster rebuilds (#27374)
DiagnosticEngine.h no longer depends on Attr.h.
Expr.h no longer depends on TypeRepr.h.

No functionality change.
2019-09-26 09:17:10 -07:00
Xi Ge
70137251c6 Address Jordan's code review comments 2019-09-24 13:52:17 -07:00
Xi Ge
3103b5cec1 Frontend: set up output file .swiftsourceinfo
This patch will focus on teaching driver and frontend to emit this file.
The actual content and de-serialization parts will come later.

More details: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation/28794
2019-09-24 13:52:17 -07:00
Harlan Haskins
c82c9b8210 [ModuleInterfaces] Remove references to 'parseable' interfaces everywhere
Now that we've settled on Module Interface as the name, let's remove the
vestiges of "Parseable Interfaces"
2019-09-13 14:55:48 -07:00
Graydon Hoare
4f315363f8 [ModuleInterface] Change TY_SwiftModuleInterfaceFile to TY_SwiftParseableInterfaceFile 2018-10-11 23:56:19 -07:00
Jordan Rose
73d5ebaad2 Rename "textual interface" to "parseable interface" (#19713)
We already have something called "module interfaces" -- it's the
generated interface view that you can see in Xcode, the interface
that's meant for developers using a library. Of course, that's also a
textual format. To reduce confusion, rename the new module stability
feature to "parseable [module] interfaces".
2018-10-04 17:49:55 -07:00
Jordan Rose
d9e47650d5 Add a new SourceFileKind and InputFileKind for textual interfaces
And test this by tweaking the rules to allow functions without
definitions, like SIL files.
2018-08-07 08:55:07 -07:00
Jordan Rose
67a6a4ff18 Move swift/Frontend/FileTypes.h down to Basic
The next commit will take advantage of this, but this is just a
mechanical change.
2018-07-25 22:23:00 -07:00
Jordan Rose
798496c488 Consistently get extensions from swift/Frontend/FileTypes.h
...instead of sometimes hardcoding them and sometimes using Strings.h.
The exceptions are the libraries that sit below Frontend; these can
continue using strings.
2018-07-25 21:49:01 -07:00
Jordan Rose
b9ae66d768 [Frontend] Add a new -emit-interface-path option
...but don't hook it up to anything yet.

This is the very very start of the module stability / textual
interfaces feature described at

  https://forums.swift.org/t/plan-for-module-stability/14551/

For now I've just made it a frontend option (not a driver option),
which is good enough for testing.
2018-07-20 16:40:51 -07:00
Ben Cohen
2b04e9f105 Suppress a number of warnings in no-assert builds (#17721)
* Supress a number of warnings about things used only in asserts

* Re-use a couple of variables instead of supressing the warning
2018-07-04 07:15:14 -07:00
David Ungar
aa2f2eb239 Call forEachNonPrimaryInput directly instead of providing useless semantics for forEachInputNotProducingSupplementaryOutput. 2018-05-10 14:20:49 -07:00
David Ungar
aaf51f7853 Addressing review comments. 2018-05-10 10:38:09 -07:00
David Ungar
34f423fb5b Add clarifying comment to forEachInputNotProducingSupplementaryOutput. 2018-05-09 20:55:46 -07:00
David Ungar
02fcbf7226 optional pointer to consumer replaces NullDiagnosticConsumer placeholder 2018-05-09 18:09:40 -07:00
Michael Gottesman
26a569b33c [stringref-upgrade] Change FrontendInputsAndOutputs::numberOfPrimaryInputsEndingWith to take a StringRef instead of a const char *.
This is in prepration for changing Strings.h to use StringLiteral.
2018-04-16 09:50:54 -07:00
David Ungar
026882d090 Use first primary name for batch input file name. 2018-03-03 19:30:13 -08:00
David Ungar
4866df6dfd Move SupplementaryOutputs into each InputFile. 2018-02-28 09:41:49 -08:00
David Ungar
488db9fb9b Fix ReferencedNameTracker in preparation for batch mode. 2018-02-16 22:28:10 -07:00