Commit Graph

144 Commits

Author SHA1 Message Date
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
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
swift-ci
aa831950b4 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-19 07:36:06 -07:00
Xi Ge
d237455481 ModuleInterface: pass down -disable-availability-checking to module building command
Related to: rdar://80703470
2021-07-17 09:40:27 -07:00
Eric Miotto
ad6076a7bc Merge 'origin/main' into rebranch - 2021-07-16
Conflicts:
	lib/IRGen/IRGenFunction.cpp
    Take the changes made in #38386
2021-07-16 07:57:06 -07:00
Artem Chikin
d6f7a017ab [Dependency Scanning] Do not include -target in extraPCMArgs when scanning an interface
https://github.com/apple/swift/pull/37774 (related to rdar://72480261) has made it so that the target of built clang modules (even downstream from Swift interface dependencies) can be consistent with that of the main module. This means that when building transitive Clang dependencies of the main module, they will always have a matching triple to the main module itself (ensured with `-clang-target`). This means we no longer have to report the target triple in the set of `extraPCMArgs` which encode an interface-specific requirement for building its dependencies.
2021-07-15 16:24:37 -07:00
Evan Wilde
9bd93db2be Update all the APInt toStrings
Just went through and updated the rest of the APInt toString calls.
This should take care of them, I hope.
2021-06-25 10:44:13 -07:00
Xi Ge
49c64cf902 ModuleInterface: sanitize arch when interface file name and encoded flags disagree
It's a known issue that we are using arm64e interfaces contents for the arm64 target,
meaning the encoded module flags are specifying -target arm64e-x-x instead of
-target arm64-x-x. Fortunately, we can tell the target arch from the interface file
name, so we could sanitize the target to use by inferring arch from the file name.
2021-06-16 22:20:55 -07:00
Xi Ge
2dcb33bb00 Frontend: allow specifying a different target triple for internal clang instance to use
Before this change, we always use the Swift target triple to instantiate the internal
Clang instance. When loading a Swift module from the textual interface, we may pick up
a lower target triple to use to build the Swift module because the target is hard-coded
in the textual interface file. This implies we may end up building multiple versions of the
same Clang module, one for each target triple of the loading Swift module.

This change adds a new frontend flag -clang-target to allow clients to specify a
consistent clang target to use across the Swift module boundaries. This value won't change
because it's not part of .swiftinterface files.

swift-driver should pass down -clang-target for each frontend invocation, and its value should be
identical to -target.

Related to: rdar://72480261
2021-06-06 07:58:21 -07:00
Becca Royal-Gordon
77117b03a0 Emit a remark when rebuilding the standard library interface
Although users should usually use a prebuilt standard library, in those rare configurations where one needs to be built, the compiler appears to hang for several minutes, even on a trivial compilation. This commit adds a remark that's emitted when this happens, explaining that the standard library is being rebuilt and it will take a few minutes.
2021-05-22 15:45:16 -07:00
Xi Ge
62dddc1c53 ModuleInterface: teach module build action to use fall-back interface if building canonical interface failed. 2021-05-18 13:21:31 -07:00
Xi Ge
b6cd513534 Frontend: teach the compiler to use a backup directory to find .swiftinterface files to compile
This mechanism allows the compiler to use a backup interface file to build into a binary module when
a corresponding interface file from the SDK is failing for whatever reasons. This mechansim should be entirely opaque
to end users except several diagnostic messages communicating backup interfaces are used.

Part of rdar://77676064
2021-05-13 09:11:45 -07:00
Xi Ge
3d6662f382 ModuleInterface: refactor out a utility to extract compiler flags from a module interface file. NFC 2021-05-02 22:46:32 -07:00
Xi Ge
bbe5b83de9 Parser: teach canImport to take an additional parameter indicating the minimum module version
canImport should be able to take an additional parameter labeled by either version or
underlyingVersion. We need underlyingVersion for clang modules with Swift overlays because they
have separate version numbers. The library users are usually interested in checking the importability
of the underlying clang module instead of its Swift overlay.

Part of rdar://73992299
2021-05-02 17:47:44 -07: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
Alexis Laferriere
82cb31d629 [Frontend] Don't load modules from the prebuilt cache for private interfaces
rdar://73007024
2021-03-09 19:21:14 -08:00
Artem Chikin
6f3fda1369 Avoid false FileDependnecies among Implicitly-build Swift and Clang modules
`InterfaceSubContextDelegateImpl` causes sub-instances to inherit `-fmodule-map-file=` options.
Those Module Maps become file dependencies of all downstream PCMs and their depending Swift modules, even though they really aren't.
This causes frequent re-builds of the Module Cache contents when seemingly-unrelated files are touched.

Explicit Module Builds rely on these options for building Swift Interface files, so for now we just disable inheritance of these options in Implicit Module builds.
2021-02-03 16:47:46 -08: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
Xi Ge
8ccee27db7 ModuleInterface: refactor ModuleInterfaceChecker out of ModuleInterfaceLoader
This refactoring allows us to drop ModuleInterfaceLoader when explicit modules
are enabled. Before this change, the dependencies scanner needs the loader to be
present to access functionalities like collecting prebuilt module candidates.
2020-10-01 10:30:48 -07:00
Robert Widmann
f9e02946ef Restore InputMode For Module Interface 2020-09-12 00:09:05 -06: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
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
Xi Ge
028a75572c ModuleInterface: remark potential version differences between SDK and prebuilt modules
Prebuilt-module directory now contains a SystemVersion.plist file copied from the SDK
it's built from. This patch teaches the compiler to remark this version and the SDK version
when -Rmodule-interface-rebuild is specified. The difference between these versions could
help us debug unusable prebuilt modules.
2020-09-04 11:45:05 -07:00
Xi Ge
e107182f1a Merge remote-tracking branch 'apple/master' into master-rebranch 2020-09-02 18:36:37 -07:00
Xi Ge
a4d731ed9f ModuleLoader: remove several walk-arounds for not having a persistent ClangImporterOptions available. NFC 2020-09-02 15:10:50 -07:00
swift_jenkins
258b72273c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-24 21:36:02 -07:00