Commit Graph

155 Commits

Author SHA1 Message Date
Anthony Latsis
44c480e83b Mnually merge main -> rebranch
Conflicts:
* `lib/ClangImporter/ClangModuleDependencyScanner.cpp`:
  https://github.com/swiftlang/swift/commit/5e09125
*	`utils/build.ps1`: https://github.com/swiftlang/swift/pull/83523
2025-08-19 21:51:34 +01:00
Artem Chikin
5015ba683a [Dependency Scanning] Bridge Clang dependency scanner results on-demand
Instead of always bridging all of the discovered modules of all of the queries, only do so for modules which are not already cached
2025-08-15 14:55:42 -07:00
swift-ci
e1a541bffb Merge remote-tracking branch 'origin/main' into rebranch 2025-07-09 20:55:55 -07:00
Saleem Abdulrasool
9ee19116d4 ClangImporter: permit redundancy in the Generate PCM job
`-Xcc` flags are internal to the C compiler; we have `-vfsoverlay` now
which directly passes the VFS overlay. Because the VFS overlay flags are
automatically passed along to the clang scanner, we need to pass along
`-vfsoverlay` to the Swift frontend to ensure that any VFS overlays are
honoured. Most likely this was a workaround for `-vfsoverlay` not
getting propagated originally and when the restriction was lifted the
exercised codepath was not heavily tested.
2025-07-09 14:57:54 -07:00
swift-ci
e40d4b3c61 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-01 01:58:11 -07:00
Steven Wu
cebe173ada [ScanDependencies] Fix a bug in rewrite from #81454
When improving the speed of dependency scanning when the new clang API
to speed up bridging, some unintended change was introduced. This
restore the scanner to the behavior before #81454

rdar://153851818
2025-06-30 10:49:44 -07:00
swift-ci
ef47f5dd87 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-25 13:36:52 -07:00
Argyrios Kyrtzidis
d385e8c87a Merge pull request #81792 from sina-mahdavi/sina-mahdavi/fix-llvm-prefix-mapping-calls
fix calls to llvm prefix mapping functions to use space-separated opt…
2025-06-25 13:19:21 -07:00
swift-ci
ff08cd384f Merge remote-tracking branch 'origin/main' into rebranch 2025-06-25 09:17:31 -07:00
Sina Mahdavi
7090b7e145 fix calls to llvm prefix mapping functions to use space-separated option format 2025-06-24 13:32:55 -07:00
Artem Chikin
39c096c388 [Dependency Scanning] Refactor 'ModuleDependenciesCache' to not hold a reference to the global 'SwiftDependencyScanningService'
While this made sense in the distant past where the scanning service provided backing storage for the dependency cache, it no longer does so and now makes for awkard layering where clients get at the service via the cache. Now the cache is a simple data structure while all the clients that need access to the scanning service will get it explicitly.
2025-06-23 13:39:43 -07:00
Artem Chikin
68883a1014 [Dependency Scanning] Refactor Swift Scanner loader to be standalone
- 'SwiftModuleScanner' will now be owned directly by the 'ModuleDependencyScanningWorker' and will contain all the necessary custom logic, instead of being instantiated by the module interface loader for each query
- Moves ownership over module output path and sdk module output path directly into the scanning worker, instead of the cache
2025-06-23 13:39:36 -07:00
Anthony Latsis
0981b71090 Adjust calls to clang::DiagnosticsEngine ctor (now takes ref vs. ptr)
See https://github.com/llvm/llvm-project/pull/139584
2025-06-13 21:57:36 +01:00
swift-ci
da8294cd98 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-12 12:54:38 -07:00
Artem Chikin
6816922dd4 [Dependency Scanning] Keep track of each imported module's access control
Adds an access control field for each imported module identified. When multiple imports of the same module are found, this keeps track of the most "open" access specifier.
2025-06-12 06:56:30 -07:00
swift-ci
1b641172fb Merge remote-tracking branch 'origin/main' into rebranch 2025-06-09 08:57:46 -07:00
Qiongsi Wu
1b003b2c51 Revert "[Dependency Scanning] Update Uses of ModuleDeps::ClangModuleDeps #81243" (#81658)
This reverts commit 024dbd040f, reversing
changes made to a08b1cbb1d.

The commit did not solve the fundamental issue we need to handle and is
no longer necessary.

rdar://144794793

<!--
If this pull request is targeting a release branch, please fill out the
following form:

https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1

Otherwise, replace this comment with a description of your changes and
rationale. Provide links to external references/discussions if
appropriate.
If this pull request resolves any GitHub issues, link them like so:

  Resolves <link to issue>, resolves <link to another issue>.

For more information about linking a pull request to an issue, see:

https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->

<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:

https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift!
-->
2025-06-09 08:36:35 -07:00
swift-ci
92dbe62f4f Merge remote-tracking branch 'origin/main' into rebranch 2025-05-27 11:14:34 -07:00
Steven Wu
391446d4b3 [DependencyScanning] Avoid extra cc1 arg round-trip to speed up bridging
Use the underlying compiler invocation inside module scanning result to
speed up the clang module dependency bridging. This avoids converting
cc1 arguments to compiler invocation and back, just to modify the cc1
arguments needed for building PCM using swift-frontend.

rdar://151705822
2025-05-20 09:54:54 -07:00
Anthony Latsis
fe575c66a9 Manually merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
lib/AST/RequirementMachine/RequirementLowering.cpp
2025-05-15 13:48:37 +01:00
Steven Wu
3c81c1ca9f [Caching] Remove CASFS clang module implemenation
Remove the CASFS based clang module implemenation as it is not longer
used.
2025-05-14 09:35:03 -07:00
swift-ci
558cbe8230 Merge remote-tracking branch 'origin/main' into rebranch 2025-05-12 09:58:12 -07:00
Artem Chikin
8ab726c2be Merge pull request #81361 from artemcm/DepScanFewerClangs
[Dependency Scanning][Refactor] Reduce the number of `ClangImporter` instances used by the scanner
2025-05-12 09:57:38 -07:00
swift-ci
fe02a055b6 Merge remote-tracking branch 'origin/main' into rebranch 2025-05-08 11:14:12 -07:00
Qiongsi Wu
024dbd040f Merge pull request #81243 from qiongsiwu/eng_144794793
[Dependency Scanning] Update Uses of `ModuleDeps::ClangModuleDeps`

https://github.com/llvm/llvm-project/pull/137421 changes the type of `ModuleDeps::ClangModuleDeps`. This PR updates Swift's use of this data structure to use the correct fields. 

rdar://144794793
2025-05-08 11:11:17 -07:00
Artem Chikin
8cd193fc08 [Dependency Scanning] Remove 'ClangImporter' instance from dependency scanning worker
Move relevant logic directly into the worker
2025-05-07 16:43:45 -07:00
Anthony Latsis
0c536923c9 Manually merge branch 'main' into rebranch 2025-05-07 14:05:43 +01:00
Artem Chikin
4b26a3d10a [Dependency Scanning] Emit a detailed error diagnostic on Clang module variant discovery
In expectation, this should never happen. Such a situation means that within the same scanning action, Clang Dependency Scanner has produced two different variants of the same module. This is not supposed to happen, but we are currently hunting down the rare cases where it does, seemingly due to differences in Clang Scanner direct by-name queries and transitive header lookup queries.
2025-05-06 08:55:57 -07:00
Qiongsi Wu
5ddff7c24c Fix the API breaking change introduced by https://github.com/llvm/llvm-project/pull/137421. 2025-05-01 16:03:45 -07:00
Anthony Latsis
5e0912508c ClangImporter: Adjust use of clang::tooling::dependencies::ModuleDeps::CASFileSystemRootID (type changed)
Per c3f10e5f166bb10afc091f21f549f0b1047701d0 (llvm-project).
2025-04-24 01:52:47 +01:00
Hiroshi Yamauchi
42fe7d90cb Merge pull request #79926 from hjyamauchi/explicit-module-build
Propagate vfs overlays and -fbuiltin-headers-in-system-modules
2025-03-28 21:58:40 -07:00
Hiroshi Yamauchi
8312f7ad9a Propagate vfs overlays and -fbuiltin-headers-in-system-modules
This fixes explicit module builds for a hello world program on Windows
as well as the ucrt import build failure as in the included test.
2025-03-27 20:57:13 -07:00
Artem Chikin
1c0caa6505 [Dependency Scanning] Carve out a special case for sdk-cache output path computation for Clang modules specifically defined in the compiler's runtime resource directory
This is, hopefully, a temporary measure while we account for why such modules are not reported as 'IsInStableDirectories'.
2025-03-19 15:37:07 -06:00
Artem Chikin
04015fef77 [Dependency Scanning] Adopt new clang scanner API to place stable modules into an SDK-specific module cache 2025-03-19 10:43:42 -06:00
Artem Chikin
88dec5199e [Dependency Scanning] Add support for placing explicitly-built SDK modules into a separate module cache
With '-sdk-module-cache-path', Swift textual interfaces found in the SDK will be built into a separate SDK-specific module cache.
Clang modules are not yet affected by this change, pending addition of the required API.
2025-03-19 09:17:04 -06:00
Cyndy Ishida
f8798ce9e6 [DependencyScanner] Update ModuleID to ModuleDeps in lookupModule calls (#80073)
This allows to read more attributes like isInSysroot.
2025-03-18 22:29:44 -07:00
Artem Chikin
0555764bb4 [Dependency Scanning] Refine cross-import overlay detection algorithm
The algorithm already performs pairwise checks on module dependencies brought into compilation per-source-file. Previously, the algorithm considered the entire sub-graph of a given source file. Actual source compiles do not consider the full transitive module dependency set for cross-import-overlay lookup, but rather only directly-imported modules in a given source file, and '@_exported import' Swift transitive dependencies.

This change adds tracking of whether a given import statement is 'exported' to the dependency scanner and then refines the cross-import overlay lookup logic to only consider transitive modules that are exported by directly-imported dependencies.
2025-02-27 15:48:11 -08:00
Saleem Abdulrasool
9c85fbc8da AST,DependencyScan,IRGen,Serialization,Tooling: track library style (#78777)
Track if the dependency is static or dynamic. This is in preparation for
helping rename the static library to differentiate it from import
libraries.
2025-02-06 13:22:56 -08:00
Steven Wu
9d59044bb1 [BrdigingHeader] Auto bridging header chaining
Add ability to automatically chaining the bridging headers discovered from all
dependencies module when doing swift caching build. This will eliminate all
implicit bridging header imports from the build and make the bridging header
importing behavior much more reliable, while keep the compatibility at maximum.

For example, if the current module A depends on module B and C, and both B and
C are binary modules that uses bridging header, when building module A,
dependency scanner will construct a new header that chains three bridging
headers together with the option to build a PCH from it. This will make all
importing errors more obvious while improving the performance.
2025-02-05 09:41:04 -08:00
Artem Chikin
477ba0dd97 [Dependency Scanning] Remove references to per-triple PCM variant compilation 2025-01-29 11:32:07 -08:00
Ian Anderson
cdb42c3535 [ClangImporter] clang's -iframework comes before builtin usr/local/include, but Swift's -Fsystem comes after
When Swift passes search paths to clang, it does so directly into the HeaderSearch. That means that those paths get ordered inconsistently compared to the equivalent clang flag, and causes inconsistencies when building clang modules with clang and with Swift. Instead of touching the HeaderSearch directly, pass Swift search paths as driver flags, just do them after the -Xcc ones.

Swift doesn't have a way to pass a search path to clang as -isystem, only as -I which usually isn't the right flag. Add an -Isystem Swift flag so that those paths can be passed to clang as -isystem.

rdar://93951328
2024-12-23 22:15:52 -08:00
Artem Chikin
d68b5b2b6e [Dependency Scan] Remove newly-introduced error failure on missing header dependency of a binary module dependency
Previous behavior had the scanner simply proceed if the header input of a binary Swift module dependency could not be resolved on the filesystem

Resolves rdar://139736789
2024-11-13 08:24:27 -08:00
Jan Svoboda
ec086e1a3c [ClangImporter] Fix build after LLVM #9573 (#77557) 2024-11-12 14:50:08 -08: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
swift-ci
9fd863f81e Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 10:50:24 -07:00
Steven Wu
cd07d532af [CAS] Use IncludeTreeFileList instead of full CASFS for caching
Use IncludeTreeFileList instead of full feature CASFS for swift
dependency filesystem. This allows smaller CAS based VFS that is smaller
and faster. This is enabled by the CAS enabled compilation does not
need to iterate file system.

rdar://136787368
2024-09-30 16:01:33 -07:00
Ben Barham
c15bc19946 Merge remote-tracking branch 'origin/main' into main-to-rebranch
Conflicts:
  - `lib/Serialization/ModuleFileSharedCore.cpp` new headers on main
2024-09-26 16:01:56 -07:00
Steven Wu
5a6f6e1d4d [NFC][ScanDependency] Remove some ununsed code
Clean up some code that no longer used.
2024-09-24 16:29:21 -07:00
Steven Wu
b2ea889721 [ScanDependency] Use -fsyntax-only to scan clang module dependencies
Use `-fsyntax-only` action to scan clang module dependencies instead of
`-c` option. This fixes a non-deterministic output on windows from
scan-dependency output because `-c` implies it needs a temporary object
file in the cc1 arguments that makes the pcm compilation command
different every run. This can also make the `-Xcc` commands for PCM
compilation simpler and more likely to be deduplicated by build system.

rdar://135319536
2024-09-05 16:22:28 -07:00
Steven Wu
23b0d80d7c [Caching] Avoid using clang CAS options in the command-line
Avoid constructing tasks with `-Xcc` options that references clang
CASOptions. This is going to make the cache hit/miss to be dependent on
CAS location/configuraitons.

Instead, only give swift CASOptions to constructed tasks and propagate
the configurations to underlying clang importer.

rdar://132255889
2024-07-24 09:20:22 -07:00