Commit Graph

254 Commits

Author SHA1 Message Date
Xi Ge
c8fa52b96d FineModuleTracing/CAS: move the computation of whether fine module trace will be emitted to an early stage.
CAS needs to determine if an output is needed very early (when computing supplementary outputs) in the pipeline so we can do caching and replays.

Resolves: rdar://141850408
2024-12-20 19:09:35 -08:00
Xi Ge
c965343f54 Frontend: add a flag to disable fine-grained module tracing 2024-12-13 16:07:15 -08:00
Pavel Yaskevich
7c8000b3a5 [Frontend] Switch -interface-compiler-version to Version
`SWIFT_COMPILER_VERSION` has more than 4 components and it's
easier to use `Version` API over `VersionTuple` as well.
2024-11-18 15:11:36 -08:00
Allan Shortlidge
67c59279a4 Frontend: Rename -dump-type-refinement-contexts to -dump-availability-scopes. 2024-11-12 11:34:25 -08:00
Allan Shortlidge
239720897a AST: Rename TypeRefinementContext to AvailabilityScope. 2024-11-12 11:34:25 -08:00
Usama Hameed
305ac20716 Serialize and Deserialize Debug Scopes (#76934)
This patch adds support for serialization and deserialization of
debug scopes.

Debug scopes are serialized in post order and enablement is 
controlled through the experimental-serialize-debug-info flag which
is turned off by default. Functions only referred to by these debug
scopes are deserialized as zombie functions directly.
2024-11-05 11:01:35 -08:00
Artem Chikin
8e3a6207b9 Merge pull request #76915 from artemcm/AsyncScanExperiment
[Dependency Scanning] Parallelize Clang module queries
2024-11-05 10:04:31 -08:00
Michael Gottesman
4763251427 [sil] Add the ability for the frontend to dump LoweredSIL before IRGen.
This is something that I have wanted to add for a while and have never had the
need to. I need it now to fix a bug in the bots where I am forced to use IRGen
output to test ThunkLowering which causes platform level differences to show up
in the FileCheck output. With this, I can just emit the actual lowered SIL
output and just test it at that level. There are other cases like this where we
are unable to test lowered SIL so we use IRGen creating this brittleness.
Hopefully this stops this problem from showing up in the future.

rdar://138845396
2024-11-01 03:16:55 -07:00
Artem Chikin
0f50693aa5 [Dependency Scanning] Parallelize Clang module queries
This change refactors the top-level dependency scanning flow to follow the following procedure:

Scan():
1. From the source target under scan, query all imported module identifiers for a *Swift* module. Leave unresolved identifiers unresolved. Proceed transitively to build a *Swift* module dependency graph.
2. Take every unresolved import identifier in the graph from (1) and, assuming that it must be a Clang module, dispatch all of them to be queried in-parallel by the scanner's worker pool.
3. Resolve bridging header Clang module dpendencies
4. Resolve all Swift overlay dependencies, relying on all Clang modules collected in (2) and (3)
5. For the source target under scan, use all of the above discovered module dependencies to resolve all cross-import overlay dependencies
2024-10-30 11:10:10 -07:00
Pavel Yaskevich
84a62fc170 [Frontend/Serialization] Narrow -swift-compiler-version to -interface-compiler-version
It might be unexpected to future users that `-swift-compiler-version`
would produce a version aligned to .swiftinterface instead of one used
to build the .swiftmodule file. To avoid this possible confusion, let's
scope down the version to `-interface-compiler-version` flag and
`SWIFT_INTERFACE_COMPILER_VERSION` option in the module.
2024-10-28 13:45:27 -07:00
Pavel Yaskevich
83995f2ae0 [Frontend] Don't set "current" compiler version for modules built from swiftinterface
If swiftinterface doesn't have `-swift-compiler-version` flag
it means that it was generated with an older version of the
Swift compiler. In such cases it would be incorrect to use
"current" compiler version because the field is intended to
indicate the compiler the swiftinterface was built with.
2024-10-25 17:05:16 -07:00
Pavel Yaskevich
3bd4853626 [Frontend] Add -swift-compiler-version option to frontend, module interfaces
This option is going to be used to indicate what compiler was used
to build swift interface/module which is required for SE-0438.
2024-10-24 17:06:14 -07:00
Ryan Mansfield
1001f9eb41 Add -print-zero-stats option and use it in ensure_no_astgen.swift
to verify ExportedSourceFileRequest == 0.

In release mode only non-zero stats are printed by default now.

Fix diagnostic when compiler is built without statistics support.
2024-10-15 23:11:15 -04:00
Slava Pestov
c77fae3a2d Basic: Add -fine-grained-timers flag
By default, -stats-output-dir does not collect per-request timers and
counters, because of overhead.
2024-09-23 18:04:25 -04:00
Artem Chikin
6990b89ec2 Merge pull request #72854 from artemcm/DefaultParallelDepScan
[Dependency Scanning] Enable parallel dependency scanning by-default
2024-09-13 14:30:01 -07:00
Artem Chikin
1ce178bc11 Merge pull request #76372 from artemcm/PrebuiltModulesEnvVar
[Prebuilt Module Cache] Add an environment variable overload to specify location of the prebuilt module cache
2024-09-11 13:07:53 -07:00
Artem Chikin
12b7df87ee [Prebuilt Module Cache] Add an environment variable overload to specify location of the prebuilt module cache
Useful for allowing e.g. CI systems to share this parameter without needing to plumb through a new compiler flag everywhere

Resolves rdar://135033114
2024-09-11 09:36:45 -07:00
Alexis Laferrière
3fe97c2eb8 Frontend: Intro -public-module-name flag
Introduce the concept of public facing module name designed to hide support module from external clients. This name should be set on a support module that is an implementation detail of a public module, the public module name of the support module should be the name of the public module. For example, BigKitCore’s public module name can be set to BigKit for diagnostics to refer to both modules as BigKit.

This name is used to refer to the support module in diagnostics for external clients. We determine if a client is external if they also import the module identified by the public module name. If a client doesn’t import the public module, diagnostics will always use the real name of the module.

The public module name is set with the flag -public-module-name and it's preserved in textual swiftinterfaces and binary swiftmodules.

rdar://134527933
2024-09-04 16:20:06 -07:00
Artem Chikin
e7a76653aa [Dependency Scanning] Enable parallel dependency scanning by-default 2024-08-01 14:26:05 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Saleem Abdulrasool
dc131ee180 Frontend: share the module cache path with clang
Rather than trying to re-compute the cache path manually for the
default, use the clang provided interface to home the module cache. This
ensures that we do not write the files into a top-level directory on
Windows.
2024-06-11 08:58:53 -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
Allan Shortlidge
b11b64273b Frontend: Allow any experimental feature to be enabled when compiling a module.
When building a module from its interface, do not diagnose whether or not a
feature is available in production compilers. This is important since older
compilers may be expected to build .swiftinterfaces that were produced by newer
compilers where the feature has been enabled by default.

Resolves rdar://125500318
2024-03-27 11:43:48 -07:00
Ellie Shin
951e2abdea Create features mapped to package optimization flags to
allow a more standard way to pass experimental features
from build systems. Also moved other flags relevant to
diagnostics from Frontend options to Lang options.

Ref: rdar://124648653
2024-03-15 14:18:33 -07:00
Becca Royal-Gordon
fd9ae4c8ac Merge pull request #72023 from beccadax/lazy-objc-workaround
Add workaround flag for lazy import-as-member
2024-03-05 16:12:32 -08:00
Ellie Shin
30669fca65 Currently when checking if resilience check can be bypassed within a package,
we only check if the loaded module is built from a package interface. This is
not enough as a binary module could just contain exportable decls if built with
experimental-skip-non-exportable-decls, essentially resulting in content equivalent
to interface content. This might be made a default behavior so this PR requires
a module to opt in to allow non-resilient access by a participating client in the
same package.

Since it affects module format, SWIFTMODULE_VERSION_MINOR is updated.

rdar://123651270
2024-03-01 15:13:58 -08:00
Becca Royal-Gordon
1a97803c8c Add flag for dumping ClangImporter lookup tables
ClangImporter’s SwiftLookupTables map Swift names to their corresponding Clang declarations. These tables are built into a module’s clang .pcm file and missing or inaccurate entries can cause name lookup to fail to find an imported declaration.

Swift has always included a helper function that would dump these tables, and swift-ide-test has a command-line switch that would invoke it, but these tools are clumsy to use in many debugging scenarios. Add a frontend flag that dumps the tables at the end of the frontend job, making it a lot easier to get at this information in the context of a specific compilation.
2024-02-29 17:51:00 -08:00
Artem Chikin
8c53fe8b63 [Dependency Scannin] Fallback on system default cache directory when no explicit cache path is specified by the user 2024-02-29 11:40:50 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Steven Wu
3986937e03 [Caching][NFC] Restructure CASOption in swift. NFC
Clean up how CASOptions are kept and passed inside swift to make the
code more readable. Also avoid a copy of CAS configuration in
ClangImporter.
2024-02-11 14:08:09 -08:00
Allan Shortlidge
67661ccf93 Frontend: Ignore lazy typechecking flags when emitting non-resilient modules.
The `-experimental-lazy-typecheck` and `-experimental-skip-non-exportable-decls`
flags are not safe to use when emitting a non-resilient module because the
clients of non-resilient modules expect to have access to all the members of a
type in order to e.g. compute the size the type. The
`-experimental-skip-non-exportable-decls` flag skips serialization of
non-public members and would therefore cause mis-compilation. The
`-experimental-lazy-typecheck` is theoretically safe for non-resilient modules
but more requestification work is needed before it can be used successfully.

Resolves rdar://122272758
2024-02-04 09:10:46 -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
f3c5e6a142 [Caching] Remove temporary caching test option
Remove `-allow-unstable-cache-key-for-testing` frontend flag. It is a
test only flag when the infrastructure is not ready to write tests for
fully cachable tasks. It is no longer needed after all the related tests
are rewritten to use dependency scanner.
2024-01-28 22:06:59 -08:00
Allan Shortlidge
5e5578aa0b Frontend: Ignore -experimental-lazy-typecheck when verifying module interfaces. 2023-11-29 10:51:24 -08:00
Allan Shortlidge
606bb391ff Frontend: Add -experimental-skip-non-inlinable-function-bodies-is-lazy.
This option causes the -experimental-lazy-typecheck and
-experimental-skip-non-exportable-decls options to be inferred from the
presense of -experimental-skip-non-inlinable-function-bodies. This new option
is meant to be a temporary testing aid that allows lazy typechecking to be
tested on projects without full build system support for passing the other
flags to the right jobs.

Resolves rdar://118938251
2023-11-29 10:51:24 -08:00
Rintaro Ishizaki
0c9f099d88 [Macros] Add option to disable sandbox for exectuable plugins
`-disable-sandbox` to disable sandboxing when invoking subprocess from
from the frontend. Since `sandbox(7)` in macOS doesn't support nested
sandbox, complation used to fail when the parent build process is sandboxed.
2023-11-27 13:44:40 -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
Allan Shortlidge
f374a41112 Frontend: Don't force decl skipping with -experimental-lazy-typecheck.
Reverts https://github.com/apple/swift/pull/69214.

Resolves rdar://117020997
2023-10-24 22:58:51 -07:00
Evan Wilde
312bd47f4c Merge remote-tracking branch 'main' into 'rebranch' 2023-10-16 23:00:12 -07:00
Allan Shortlidge
619b6e6755 Frontend: Temporarily force decl skipping with -experimental-lazy-typecheck.
Until a swiftc with https://github.com/apple/swift-driver/pull/1465 is
available widely, enable -experimental-skip-non-exportable-decls whenever
-experimental-lazy-typecheck is specified.

Resolves rdar://117020908
2023-10-16 14:19:20 -07:00
swift-ci
d967b1878a Merge remote-tracking branch 'origin/main' into rebranch 2023-10-10 20:08:25 -07:00
Allan Shortlidge
f131c8a3f5 Frontend: Introduce -experimental-skip-non-exportable-decls.
Rename -experimental-serialize-external-decls only to
-experimental-skip-non-exportable-decls in preparation for the flag being used
to influence more than just serialization.

Resolves rdar://116771543
2023-10-10 16:07:04 -07:00
swift-ci
4a749b3e3d Merge remote-tracking branch 'origin/main' into rebranch 2023-10-05 16:59:34 -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
Evan Wilde
0453158f8e Merge remote-tracking branch 'main' into rebranch
Conflict in CAS options when
`std::vector<std::string> CacheReplayPrefixMap;` was added.

Conflicts:
  include/swift/Frontend/FrontendOptions.h

Resolution: Take both
2023-10-04 14:28:43 -07:00
Steven Wu
5be305e839 [CompilerCaching] Teach CachedDiagnostics to replay with prefix map
Teach CachedDiagnosticsProcessor to replay diagnostics for all consumers
with a different path using a path prefix map. This allows diagnostics
to be replayed for the actual path on disk after the scanner
canonicalized the path for compilation.
2023-09-26 12:36:43 -07:00
swift-ci
d86c449532 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-25 09:36:22 -07:00
Artem Chikin
6e3f896962 [Dependency Scanning] Refactor primary scan operations into 'ModuleDependencyScanner' class
From being a scattered collection of 'static' methods in ScanDependencies.cpp
and member methods of ASTContext. This makes 'ScanDependencies.cpp' much easier
to read, and abstracts the actual scanning logic away to a place with common
state which will make it easier to reason about in the future.
2023-09-22 14:09:45 -07:00
Shubham Sandeep Rastogi
7a1a3d61ed Add MCCAS options to swift and guard mccas.swift properly
Revert "Revert "Add driver options to swift to enable MCCAS.""

This reverts commit 0e8554bb15.
2023-09-12 14:10:59 -07:00
Evan Wilde
0e8554bb15 Revert "Add driver options to swift to enable MCCAS."
This reverts commit 3c949028e8.
2023-09-11 13:36:36 -07:00