Commit Graph

218 Commits

Author SHA1 Message Date
Alexis Laferrière
c42bdde30a Merge pull request #61980 from xymus/index-fix-silencing-swiftinterface
[ModuleInterface] Fix silencing errors mode in swiftinterface rebuild
2022-11-08 13:17:58 -08:00
Artem Chikin
d1cbf9c8d4 Inherit parent's extra Clang arguments when creating an interface build sub-invocation.
We would like to make sure they get propagated to downstream transitive Clang module dependencies also.

Resolves rdar://101923680
2022-11-08 09:32:30 -08:00
Alexis Laferrière
4a582806dc [ModuleInterface] Fix silencing errors mode in swiftinterface rebuild
Make sure we disable forwarding diagnostics from the underlying instance
when building a swiftinterface in silencing errors mode.
2022-11-08 09:31:17 -08:00
Alexis Laferrière
1ce67099de [ModuleInterface] Support aliasing a module loaded from a swiftinterface 2022-11-04 11:10:59 -07:00
Alexis Laferrière
47b29b68db Merge pull request #61649 from xymus/index-swiftinterfaces
[Index] Force indexing of system modules to read only from swiftinterfaces
2022-10-31 14:18:45 -07:00
Alexis Laferrière
83cd432785 [Frontend] Intro global control to force loading from swiftinterface
Intro ASTContext::setIgnoreAdjacentModules to change module loading to
accept load only resilient modules from their swiftinterfaces, ignoring
the adjacent module and any silencing swiftinterfaces errors.
2022-10-31 10:58:54 -07:00
Artem Chikin
c51efbed9c Add option to suppress emission of remarks ('-suppress-remarks')
And enforce it especially in downstream contexts such as building interfaces of SDK dependencies, where the remarks are not actionable by the user.
2022-10-28 10:49:27 -07:00
Adrian Prantl
3cc2831608 Don't require a strict revision match in LLDB.
For release-management purposes during development, LLDB's embedded Swift
compiler's version number can sometimes be off-by-one in the last digit
compared to the Swift compiler.

This patch restores the old behavior from before 17183629e4.

rdar://101299168
2022-10-19 09:03:13 -07:00
Artem Chikin
625048a43f Merge pull request #61545 from artemcm/PropagateApplicationExtensionStatus
Propagate '-application-extension' to module interface loader sub-invocations.
2022-10-13 08:51:23 -07:00
Artem Chikin
0c470f238b Propagate '-application-extension' to module interface loader sub-invocations.
This flag restricts availability of certain symbols to ensure the code cannot use declarations that are explicitly unavalable to extensions. This restriction should be passed down to dependency modules also.
2022-10-11 11:24:48 -07:00
Dario Rexin
992cae456b [Frontend] Use experimental feature for layout prespecializations (#61451) 2022-10-06 15:21:01 -07:00
Robert Widmann
18b79ffcfd Resolve a Layering Violation in libBasic
Basic should not be allowed to link Parse, yet it was doing so
to allow Version to provide a constructor that would conveniently
parse a StringRef. This entrypoint also emitted diagnostics, so it
pulled in libAST.

Sink the version parser entrypoint down into Parse where it belongs
and point all the clients to the right place.
2022-09-09 00:21:30 -07:00
Allan Shortlidge
bbf189c8ab AST: Make the versioned variants of #if canImport() more reliable and consistent.
Previously, when evaluating a `#if canImport(Module, _version: 42)` directive the compiler could diagnose and ignore the directive under the following conditions:

- The associated binary module is corrupt/bogus.
- The .tbd for an underlying Clang module is missing a current-version field.

This behavior is surprising when there is a valid `.swiftinterface` available and it only becomes apparent when building against an SDK with an old enough version of the module that the version in the `.swiftinterface` is too low, making this failure easy to miss. Some modules have different versioning systems for their Swift and Clang modules and it can also be intentional for a distributed binary `.swiftmodule` to contain bogus data (to force the compiler to recompile the `.swiftinterface`) so we need to handle both of these cases gracefully and predictably.

Now the compiler will enumerate all module loaders, ask each of them to attempt to parse the module version and then consistently use the parsed version from a single source. The `.swiftinterface` is preferred if present, then the binary module if present, and then finally the `.tbd`. The `.tbd` is still always used exclusively for the `_underlyingVersion` variant of `canImport()`.

Resolves rdar://88723492
2022-09-07 14:18:05 -07:00
Artem Chikin
256c0ff04a [Explicit Modules] On an explicit interface build, early exit if the expected output is up-to-date. 2022-08-16 18:31:13 -07:00
Artem Chikin
6ca24c9239 Factor out checking if a binary module is up-to-date from the rest of 'ModuleInterfaceLoaderImpl' logic, to be used by other clients 2022-08-16 16:42:29 -07:00
Artem Chikin
a90d3e2de1 Factor out reading flags/version from an interface from setting up a Compiler sub-instance 2022-08-16 08:36:58 -07:00
Artem Chikin
7fd2a29fb7 Refactor 'ModuleInterfaceBuilder' to separate CompilerInstance setup logic from compilation logic (moved to ExplicitModuleInterfaceBuilder). 2022-08-16 08:36:55 -07:00
Artem Chikin
7bdec998b1 Add flag that allows ignoring compiler flags specified in an interface file when running a '-compile-module-from-interface' frontend action. 2022-08-02 10:54:52 -07:00
Xi Ge
cfb5fcda0f ModuleInterface: avoid remarking missing prebuilt module for stdlib by default
Prebuilt modules are only available for certain toolchain and SDK combinations. Therefore,
building modules from interface, even for the stdlib, is expected to happen.

related: rdar://96701615
2022-07-14 15:04:27 -07:00
swift-ci
8364d5b3d7 Merge pull request #40777 from ApolloZhu/fix-canImport-submodule-checking
Fix canImport submodule checking in loaders not supporting submodules
2022-07-01 15:10:13 -07:00
Alexis Laferrière
c8059a09e9 [Serialization] Soft-reject swiftmodules built against a different SDK
Change the way swiftmodules built against a different SDK than their
clients are rejected. This makes them silently ignored when the module
can be rebuilt from their swiftinterface, instead of reporting a hard
error.

rdar://93257769
2022-05-16 13:22:35 -07:00
Alexis Laferrière
c93a4a466b Merge pull request #42486 from xymus/ignore-adjacent-public-swiftmodule
[ModuleInterface] Ignore adjacent swiftmodules under the Frameworks folder
2022-04-25 09:17:42 -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
Alexis Laferrière
3aebf2850d [ModuleInterface] Ignore adjacent swiftmodules from the Frameworks folder
Always use the swiftinterfaces of modules under the public Frameworks
folder in the SDK. Distributed swiftmodules are unreliable, they should
only be used as a local cache. Let's avoid them when possible.

rdar://92037292
2022-04-20 10:44:21 -07:00
Xi Ge
8dd638fbd0 ModuleInterface: ensure -disable-clang-spi flag to propagate to module interface builders 2022-04-02 21:31:00 -07:00
Apollo Zhu
1f77f46e4f Report cannot load submodule if only able to load top module
For loaders that don't support loading submodules, canImportModule should report false instead of checking if can import top module.
2022-04-01 13:10:17 -07:00
Becca Royal-Gordon
bbcd980aff Add flag for minimum inlining version 2022-03-04 10:54:52 -08:00
Xi Ge
5964d4b683 DepScanner/ModuleInterface: fix a memory issue when passing down -serialized-path-obfuscate to interface building commands
rdar://88511163
2022-02-17 13:51:22 -08:00
Xi Ge
53d46841d4 ModuleInterface: pass-down paths obfuscator to module interface building commands
While implicitly building .swiftinterface, the interface may import other binary modules.
These binary modules may contain serialized search paths that have been obfuscated. To help
interface building commands recover these search paths, we need to pass down the obfuscators
to the module building commands.

rdar://87840268
2022-01-20 14:48:55 -08:00
ApolloZhu
683d469fcd Extends canImport to check for submodule availability 2021-12-28 22:54:47 -08:00
Alex Hoppen
669e3f34a6 Merge pull request #40155 from ahoppen/pr/improve-module-search-path-lookup
[Serialization] Improve module loading performance
2021-12-20 18:09:17 +01:00
Alex Hoppen
fe7878ecce [Serialization] Improve module loading performance
When looking for a Swift module on disk, we were scanning all module search paths if they contain the module we are searching for. In a setup where each module is contained in its own framework search path, this scaled quadratically with the number of modules being imported. E.g. a setup with 100 modules being imported form 100 module search paths could cause on the order of 10,000 checks of `FileSystem::exists`. While these checks are fairly fast (~10µs), they add up to ~100ms.

To improve this, perform a first scan of all module search paths and list the files they contain. From this, create a lookup map that maps filenames to the search paths they can be found in. E.g. for
```
searchPath1/
  Module1.framework

searchPath2/
  Module1.framework
  Module2.swiftmodule
```
we create the following lookup table
```
Module1.framework -> [searchPath1, searchPath2]
Module2.swiftmodule -> [searchPath2]
```
2021-12-14 12:44:13 +01:00
Alex Hoppen
63c31033fc [Frontend] Load standard libarary in CompilerInstance::setup
Instead of checking that the stdlib can be loaded in a variety of places, check it when setting up the compiler instance. This required a couple more checks to avoid loading the stdlib in cases where it’s not needed.

To be able to differentiate stdlib loading failures from other setup errors, make `CompilerInstance::setup` return an error message on failure via an inout parameter. Consume that error on the call side, replacing a previous, more generic error message, adding error handling where appropriate or ignoring the error message, depending on the context.
2021-12-13 15:32:08 +01:00
Ellie Shin
5da881256f Module aliasing: Use real module names with -scan-dependencies
Resolves rdar://85991587
2021-12-02 15:45:30 -08:00
Xi Ge
f77ca2e2ae Frontend: add a flag to downgrade all module interface verification errors to warnings
Ideally, module interface verification should fail the build when fatal error occurs when
type checking emitted module interfaces. However, we found it's hard to stage this phase in
because the ideal case requires all Swift adopters to have valid interfaces. This new front-end flag allows
driver to downgrade all interface verification errors to warnings as an intermediate step.
2021-11-09 15:58:42 -08:00
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
swift-ci
3f8fea8508 Merge remote-tracking branch 'origin/main' into rebranch 2021-10-06 10:17:29 -07:00
elsh
55b9fa11d8 Load modules using real names if module aliases are used
rdar://83591943
2021-10-05 10:55:22 -07:00
Meghana Gupta
f458d9b490 Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)
* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag

This includes a bit in the module format to represent if the module was
compiled with -enable-ossa-modules flag. When compiling a client module
with -enable-ossa-modules flag, all dependent modules are checked for this bit,
if not on, recompilation is triggered with -enable-ossa-modules.

* Updated tests
2021-10-04 18:46:40 -07:00
swift-ci
b5ac11a2ab Merge remote-tracking branch 'origin/main' into rebranch 2021-09-15 17:33:26 -07:00
Becca Royal-Gordon
e16cf3085f Override -triple on fallback to arm64e interface
When we fall back to loading an arm64e module interface during an arm64 build, we want to compile it for the arm64 target so that it is fully compatible with the module that will load it, even though the flags in the file specify the arm64e target. Rewrite the sub-invocation's TargetTriple property in this specific situation. If the two targets differ by more than just the sub-architecture, we will continue to respect the -target flag in the file.

Fixes <rdar://83056545>.
2021-09-15 12:36:17 -07:00
swift-ci
88d5cced81 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-02 16:33:04 -07:00
Artem Chikin
1b7d55582d Do not build Swift interface files into binary modules when performing a canImport query.
We should hold off actually building the binary module file until it is imported.
`canImport` queries can happen, for example, during dependency scanning, when we do not wish to have the scanner tool execute any module builds.

Resolves rdar://82603098
2021-09-02 12:09:57 -07:00
swift-ci
86f6f2e622 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-22 14:34:00 -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
Arnold Schwaighofer
5a83172a55 Merge remote-tracking branch 'upstream/main' into rebranch 2021-08-05 12:04:56 -07:00
Xi Ge
9cdc39df65 ExplicitModuleLoader: allow explicit module input map to indicate whether a module is a system module 2021-08-03 17:09:06 -07:00
Xi Ge
3fd5cd1fe4 Frontend: remove -swift-module-file. NFC
We are now using a JSON file for explicit module inputs, so this argument can be removed.
2021-07-30 15:27:55 -07:00
swift-ci
79532b66e5 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-28 21:53:11 -07:00
Xi Ge
2132a9034d DependenciesScanner: include -sdk in Swift module building command
Swift module building commands need -sdk because dependencies sometimes use
sdk-relative paths (prebuilt modules for example). Without -sdk, the command
will not be able to local these dependencies, leading to unnecessary
rebuilding from textual interfaces.

rdar://81177968
2021-07-28 18:12:07 -07:00