Commit Graph

235 Commits

Author SHA1 Message Date
Eric Miotto
7d12cad37f Merge main into next - 2021-07-16
Conflicts:
	lib/IRGen/IRGenFunction.cpp
    Take the changes made in #38386
2021-07-16 09:15:42 -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
0aafd09835 F_None was renamed OF_None
This patch updates usages of F_None to OF_None, as LLVM changed that in
commit 3302af9d4c39642bebe64dd60a3aa162fefc44b2.
2021-06-23 10:36:39 -07:00
Artem Chikin
7e2c8e97fc [Dependency Scanning] Add ability for -scan-dependencies action to serialize and deserialize dependency scanner cache from a .moddepcache file.
Using the serialization format added in https://github.com/apple/swift/pull/37585.

- Add load/save code for the `-scan-dependencies` code-path.
- Add `libSwiftDriver` entry-points to load/store the cache of a given scanner instance.
2021-06-01 14:45:50 -07:00
Artem Chikin
14229f13b0 [Dependency Scanning] Add a binary serialization format for the Inter-Module Dependencies Cache
- Adds serialization format based on the LLVM Bitcode File Format (https://llvm.org/docs/BitCodeFormat.html).
- Adds Serialization and Deserialization code.
2021-05-21 14:31:00 -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
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
Artem Chikin
c96c511e7f [DependencyScanning] Reset LLVM option occurences for each batch scan entry
We must reset option occurences on each entry because we are handling an unrelated command-lines to those parsed before. We must do so because LLVM options parsing is done using a managed static `GlobalParser`.

Resolves rdar://75247030
2021-03-10 16:59:08 -08:00
Artem Chikin
799bef5d2f [Dependency Scanning] When re-using a CompilerInvocation in batch scanning, update it with the entry-specific arguments.
Otherwise, the arguments from the parent invocation of the batch scanner may overrule the arguments the batch entry expects.

Resolves rdar://74812312
2021-03-04 14:40:34 -08:00
Artem Chikin
1825cbf21e [Dependency Scanning] Batch Scanning: Update ClangImporter arguments when re-using a compiler instane.
Additional arguments that the compiler must pass to the Clang Importer (Clang dep scanner), incl. search paths, must come from the invocation that launched the scan in order to correctly match the specific target being scanned, instead of re-using those from a cached CompilerInstance.
2021-02-05 14:08:37 -08:00
Artem Chikin
02b42e2552 Merge pull request #35356 from artemcm/DependencyScannerUseCacheWhenAppropriate
[Dependency Scanning] Optionally, resolve direct dependencies of a module using only the `ModuleDependenciesCache`.
2021-01-13 12:01:12 -08:00
Artem Chikin
96e8ec3e81 [Dependency Scanning] Distinguish Swift Textual and Swift Binary modules when resolving direct dependencies
The intent is two-fold:
1. This fixes a bug where we would only attempt to resolve direct dependencies as Clang modules for Swift Binary modules.
2. Ensures that we only query the presence of a Bridging Header for textual Swift modules.

Resolves rdar://73015075
2021-01-12 15:07:56 -08:00
Artem Chikin
8ecdfcbfd5 [Dependency Scanning] Optionally, resolve direct dependencies of a module using only the ModuleDependenciesCache.
This speeds up contexts where we need to resolve dependencies after the main scanning action is complete.
For example: libSwiftScan binary graph generation and cycle detection.

This is necessary because ordinarily, ModuleDependenciesCache must be queried on a per-loader basis.
For example, we first search for Swift modules with the SerializedModuleLoaderBase, at which point we check the cache for previously-found Swift modules. If cache is not hit, we search the filesystem.
Then we search for Clang moduels with the ClangLoader, at which point we check the cache for previously-found Clang modules. If cache is not hit, we search the filesystem.

This change allows to eliminate a bunch of filesystem searching in step (1) when we know we have completed the scan and no longer need to be concerned with the correctness of the cache contents.
2021-01-11 14:50:14 -08:00
Artem Chikin
94b727fb2b [Dependency Scanning] Update cached batch scan compiler instances with up-to-date search paths on successive scanner invocations
To ensure they do not get stuck with stale search paths when scanning successive targets.
2021-01-07 09:08:21 -08:00
Artem Chikin
41f65d780f Do not use Designated Initializers as they are not yet supported by all of our build compilers. 2021-01-07 09:08:21 -08:00
Artem Chikin
39483f0a91 [Dependency Scanning] Cache compiler instance/module depenency cache used for batched versioned-PCM scans. 2021-01-07 09:08:21 -08:00
Artem Chikin
58e5402807 [Dependency Scanning] Use size_t for array sizes and re-arrange array struct type fields to be consistent. 2021-01-07 09:08:21 -08:00
Artem Chikin
295e4f41b9 [Dependency Scanning] Bugfix: check for null C string before checking if it is empty 2021-01-07 09:08:21 -08:00
Artem Chikin
41a09a4092 [Dependency Scanning] Establish object ownership convention by using a Foundation-style ownership signals naming scheme across the API surface.
Foundation-style ownership signals documentation:
https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-CJBEJBHH
2021-01-07 09:08:21 -08:00
Artem Chikin
d1cc689c01 [Dependency Scanning] Fix the DependencyScan unit test harness to reflect C API changes. 2021-01-07 09:08:21 -08:00
Artem Chikin
f91c8a8574 [Dependency Scanning] Refactor string implementation to always malloc and tie lifetime to owning object. 2021-01-07 09:08:21 -08:00
Artem Chikin
d017fd430b [Dependency Scanning] Add setters for the scanner invocation context and a creation method to return an isntance of the opaque invocation 2021-01-07 09:08:20 -08:00
Artem Chikin
ca1694442d [Dependency Scanning] Export opaque types as pointers to C structs instead of void* for better type-safety and cleaner code 2021-01-07 09:08:20 -08:00
Artem Chikin
cff741b60f [Dependency Scanning] Make the prescan dependency scan result (import set) an opaque structure 2021-01-07 09:08:20 -08:00
Artem Chikin
409de733f7 [Dependency Scanning] Make the overall dependency scan result (inter-module dependency graph) an opaque structure 2021-01-07 09:08:20 -08:00
Artem Chikin
5cacff4d84 [Dependency Scanning] Make a module's dependency info an opaque structure 2021-01-07 09:08:20 -08:00
Artem Chikin
fcf943370e [Dependency Scanning] Change C API prefix to: swiftscan from ds and adopt query method naming scheme of:
`<prefix>_<object>_<action>`
2021-01-07 09:08:20 -08:00
Artem Chikin
d0220e50ff [Dependency Scanning] Add entry-point to DependencyScanningTool and the corresponding C API for a batch scan operation 2021-01-07 09:08:20 -08:00
Artem Chikin
2ad960083a [Dependency Scanning] Use an opaque type for dependency module details with API query functions for individual fields 2021-01-07 09:08:20 -08:00
Artem Chikin
75b8a0ea44 [Dependency Scanning] Add entry-point to DependencyScanningTool and the corresponding C API for an import prescan operation 2021-01-07 09:08:20 -08:00
Artem Chikin
75a8cfa048 [Dependency Scanning] Add a C API layer for dependency scanning tool, scanning actions, and scan results.
Adds a C API layer consisting of:
- Data structures used to represent in-memory result of dependency scanning
- Opaque dependency scanner tool (C wrapper for `DependencyScanningTool`)

Refactors `ScanDependencies.cpp` to produce dependency scanning result in the form of the above binary format.
2021-01-07 09:08:20 -08:00
Artem Chikin
082fc48b25 [Dependency Scanning] Refactor dependency scanner to return an in-memory format as a result
This commit refactors ScanDependencies.cpp to split the functionality into two functional groups:
- Scan execution code that performs the mechanics of the scan and produces an in-memory result
- Dependency scanner entry-points used when the scanning action is invoked as a `swift-frontend` execution mode
This commit also adds the aforementioned in-memory dependency scanning result in `FullDependencies.h`, modeled after the InterModuleDependencyGraph representation in swift-driver
2021-01-07 09:08:20 -08:00
Artem Chikin
dad14358fb [Dependency Scanning] Factor out import prescan into separate utility 2021-01-07 09:08:20 -08:00
Artem Chikin
aabcb22df1 Rename SwiftScan directory into DependencyScan 2021-01-07 09:08:20 -08:00