Commit Graph

212 Commits

Author SHA1 Message Date
Steven Wu
1852967fcf [Caching] Support -const-gather-protocols-file correctly
Previously, const-values output is not supported correctly as it is not
captured correctly as a dependency. The load of the input JSON file is
loaded via file system directly, that can cause issues like:
* False cache hit when the file is changed
* Cannot be prefix mapped to allow distributed caching

Try to support the input file by:
* Correctly capture the input
* Create a new driver flag `-const-gather-protocols-list` that can do
  path remapping correctly in swift-driver

rdar://169109358
2026-01-30 13:14:33 -08:00
Ian Anderson
fc628a8bfb [test][NFC] Add more keys to test SDKSettings files
Every time DarwinSDKInfo reads a new key out of SDKSettings, a boatload of test SDKSettings files need to be updated across several repositories and forks and branches. It’s tedious to be careful to update those with real values so that the tests are properly regression testing older SDKs. It’s important to be careful so that the tests are accurate, e.g. to prevent the scenario where DarwinSDKInfo starts reading a new key out of SDKSettings and assumes that it’s always available everywhere, when in reality it was only added a few releases ago and will break with older SDKs. If the test SDKSettings files continue to be updated ad hoc, it’s going to be really easy to copy/paste a default value everywhere, and then clients will see incorrect behaviors with the real SDKs, or even compiler crashes if the key is unconditionally read. Preemptively add all of the maybe-possibly-compiler relevant keys to the test SDKSettings files from the real SDKs so that the test files are an accurate representation and shouldn't need to be touched in the future. Where the test SDKSettings have intentionally doctored data, add a Comments key explaining what is changed from the real SDK, and alter the SDK name with a tag indicating the change.

rdar://168700857
2026-01-23 02:19:36 -08:00
Steven Wu
c5189de182 [ScanDependency] Fix canImport when versioned checks all eval to false
Fix a corner case when following conditions are met in a single module:
* Module A is imported in the current module
* There exists a versioned `canImport` check for a module A
* All `canImport` check within the module evaluated to false

If all above conditions are met, swift-frontend will not received the
version number from scanner, and it will be confused if version is
either not available (thus a warning, and treat as true), or condition
is not met (eval to false).

Now make sure if when scanner tries to resolve `canImport`, it will
record all instances that a module can be imported, or a version of the
module is found.

rdar://167784812
2026-01-12 15:57:52 -08:00
Steven Wu
1df1e2f781 Merge pull request #86398 from cachemeifyoucan/eng/PR-167640539
[TEST-ONLY] Disable flaky test on FreeBSD
2026-01-09 18:38:01 -08:00
Steven Wu
69b36e99e5 [TEST-ONLY] Disable flaky test on FreeBSD
Disable CAS/include-tree-cxx.swift test on FreeBSD.

rdar://167640539
2026-01-08 15:27:07 -08:00
Steven Wu
6b3b6608b6 Merge pull request #86363 from cachemeifyoucan/eng/PR-167707148
[Caching][DependencyScan] Fix main module header chaining
2026-01-08 14:46:15 -08:00
Ian Anderson
c0d0d73c4f [Test][Darwin] Add CanonicalName and SupportedTargets to all applicable SDKSettings
clang will start looking at CanonicalName and SupportedTargets soon, and error if those aren't as expected in the shipping SDKs. Pre-emptively add those to the test SDKSettings.

rdar://166277280
2026-01-07 23:59:29 -08:00
Steven Wu
7b4c2f37e5 [Caching][DependencyScan] Fix main module header chaining
Fix a programming mistake when chaining bridging header for the main
module. Main module never has the binary module, thus it always need to
chain the bridging header content directly without falling back to
embedded binary module. Previously, the scanner was wrongly error out
because it failed to locate the binary module for main module.

rdar://167707148
2026-01-07 20:55:00 -08:00
Steven Wu
36e1f62119 [DebugInfo] CAS built swift TU should have CASID as dwo_name for PCM
When using compilation caching, make sure the debug info emitted in the
swift TU references PCM files via CASID instead of file path. This
allows dsymutil and lldb to load clang modules correctly from CAS,
instead of relying on file system to load the file.

rdar://167054494
2025-12-22 16:53:49 -08:00
Saleem Abdulrasool
4d4b82a641 Merge pull request #85978 from compnerd/cas-support
test: enable CAS tests on Windows
2025-12-18 08:08:53 -08:00
Saleem Abdulrasool
0ee389bd16 Merge pull request #86090 from compnerd/remapping
test: disable CAS.path_remap on Windows
2025-12-17 20:33:27 -08:00
Artem Chikin
dad62f8017 Merge pull request #86079 from artemcm/DependencyScanningMetrics
[Dependency Scanning] Add tracking of the number of dependency queries and emit them as remarks
2025-12-17 17:55:44 -08:00
Artem Chikin
7017034d20 [Dependency Scanning] Add tracking of the number of dependency queries and emit them as remarks
This change adds collection of three metrics to the scanner:
- number of Swift module lookups
- number of named Clang module lookups
- recorded number of Clang modules which were imported into a Swift module by name

It introduces '-Rdependency-scan', which acts as a super-set flag to the existing '-Rdependency-scan-cache' and adds emission of the above metrics as remarks when this flag is enabled. Followup changes will add further remarks about dependency scanner progress.
2025-12-17 12:50:33 -08:00
Saleem Abdulrasool
95e5c7b44e test: disable CAS.path_remap on Windows
This test is not possible to support on windows as we do not use
`-sysroot` and thus do not have any `-isysroot` flags in the invocation.
As we pick up the "sysroot" through the environment or registry, there
is not much to test here.
2025-12-16 11:01:01 -08:00
Saleem Abdulrasool
1caeb09f74 test: enable CAS tests on Windows
Enable the CAS test suite to execute on Windows.
2025-12-16 09:49:07 -08:00
Saleem Abdulrasool
15cb8d6fd1 Merge pull request #86073 from compnerd/extensions
test: acount for plugin extension on Windows
2025-12-16 08:18:05 -08:00
Saleem Abdulrasool
797476f791 Merge pull request #86054 from compnerd/checks
test: adjust test for more string matching flexibility
2025-12-15 22:06:39 -08:00
Saleem Abdulrasool
1ab037182b test: acount for plugin extension on Windows
The plugin server on Windows is an executable and thus has the `.exe`
extension that we did not match. Adjust the test for this naming
difference.
2025-12-15 14:11:09 -08:00
Saleem Abdulrasool
fe3200ee19 Merge pull request #86053 from compnerd/separators
test: accommodate path separators in CAS tests
2025-12-15 13:59:04 -08:00
Saleem Abdulrasool
c7e0d78d02 test: adjust test for more string matching flexibility
Use `FileCheck` for the test validation instead of `diff`. This allows
us to match the different file system arc separator on Windows which is
different across the CAS, where everything is normalised, and the
uncached path where we get mixed paths.
2025-12-15 08:54:51 -08:00
Saleem Abdulrasool
376840cad7 test: accommodate path separators in CAS tests
Adjust the test expectations to account for path separators on Windows.
2025-12-15 08:52:49 -08:00
Saleem Abdulrasool
2a7d500ea4 test: migrate additional tests to swift-build-modules
Migrate two more instances of the lit test `RUN` lines to
`swift-build-modules` to ensure that all the modules are available for
the CAS build.
2025-12-15 08:47:47 -08:00
Saleem Abdulrasool
3a4cd07e9a test: introduce swift-target-frontend-plain for CAS tests
This introduces a new substitution for use in the CAS tests. The plain
variant of the target frontend invokes the tool with the variant target
triple and resource dir only. This allows us to properly invoke the
frontend for the CAS tests.
2025-12-12 17:13:31 -08:00
Saleem Abdulrasool
528cca0c2f test: adjust the path compuation for plugins
DLLs on Windows are built/installed into the binary directory while only
import libraries are placed into the library directory to differentitate
between the distributable and developer content. Introduce a helper to
compute the appropriate plugin path.
2025-12-10 11:26:29 -08:00
Steven Wu
756e53967e [TEST-ONLY] Add utility to perform explicit module build
Add a script to build all dependencies for explicit module build in one
step. This reduces the boiling plate code needed to write a test for
explicit module build and allows the test to be more cross platform and
resilient to module dependencies changes.
2025-12-09 12:16:18 -08:00
Saleem Abdulrasool
d7991c8f52 tests: adjust invocatio of python tools
These test commands were relying on an arcane Unix specific behaviour
that is non-portable to execute the commands. Python scripts cannot be
run and must be interpreted - they must specify the interpreter.
Explicitly invoke the tools with the configured python interpreter to
allow running the tool on other platforms.
2025-12-04 08:22:08 -06:00
Steven Wu
b1d669bea1 [Caching] Fix multi-threaded WMO with MCCAS
MCCAS wasn't setup correctly when using parallel WMO. Make sure the
CAS ObjectStore and ResultCallbacks are passed to LLVM backend when
using parallel WMO.

rdar://164409895
2025-11-13 12:20:31 -08:00
Steven Wu
3067602eb7 Merge pull request #85386 from cachemeifyoucan/eng/PR-164205657
[CAS] Don't leak `-iapinotes-modules` clang flag in caching build
2025-11-10 15:51:15 -08:00
Steven Wu
22ca80e4fd Merge pull request #85375 from cachemeifyoucan/eng/PR-164208526
[CAS] Support legacy prefix map option
2025-11-10 10:52:28 -08:00
Steven Wu
d6c39cd360 [CAS] Don't leak -iapinotes-modules clang flag in caching build
The search paths for apinotes are leaked when using compilation caching
but they are not needed like other search path because the apinotes are
found and stored inside include-tree.

rdar://164205657
2025-11-07 11:01:33 -08:00
Steven Wu
4e0484201d Merge pull request #83621 from cachemeifyoucan/eng/PR-gmodule-with-cas-id-update
Update swift compiler after clang gmodule CAS build update
2025-11-07 10:03:44 -08:00
Steven Wu
23b42cf6c9 [CAS] Support legacy prefix map option
Bring back legacy prefix map option to allow an older swift-driver to
work with newer swift-frontend. For old swift-driver, it will always
send the old style prefix map option, so the new compiler needs to
support that.

rdar://164208526
2025-11-06 20:35:10 -08:00
Steven Wu
eae4555213 [CAS] Add -no-cache-compile-job frontend option
Add a negative frontend to turn off compilation caching. This allows
turn off compilation caching by just appending argument.

rdar://162547707
2025-10-31 11:03:05 -07:00
Steven Wu
ee09790748 Update swift compiler after clang gmodule CAS build update
Fix swift compiler build and test to work with new clang gmodule build
with CAS, which encodes references to clang PCMs as CASIDs.
2025-10-28 11:35:44 -07:00
Adrian Prantl
1d28b8073b Add CAS test for module dependencies 2025-10-23 16:56:00 -07:00
Steven Wu
6deed71732 [TEST-ONLY] Fix CAS/legacy_layout_remap.swift on non-macos target
Fix CAS/legacy_layout_remap test when running on non mascOS target.
2025-10-21 15:34:10 -07:00
Steven Wu
bd2b3c7aeb [Caching] Allow prefix mapping on legacy layout file
To support distributed caching for targets that need to use legacy
layout file, the path of legacy layout needs to be remapped.

Current handling of the legacy layout file is to ingest all layout files
to the CAS FileSystem as part of the compiler resource files. But it
cannot convey remapped legacy layout file path to the swift-frontend
when distributed caching is enabled. In order to properly support path
remapping, the legacy layout file is ingested on demand (thus it doesn't
need to be ingested for module compilation), and the remapped path is
communicated to swift-front via frontend flag.

rdar://162793678
2025-10-17 15:53:52 -07:00
Henrik G. Olsson
186b3336e8 Update CAS tests (NFC)
Updates 3 additional tests broken by the TMP_DIR addition to
PathSanitizingFileCheck.
2025-10-12 23:29:16 -07:00
Steven Wu
88b719d7fc [Caching] Adjust the bridging header chaining rule
Adjust the rule for how bridging header chaining is performed to
increase compatibilities with existing project configuration.

Previously in #84442, bridging header chaining was done via content
concatenation, rather than `#include` via absolute path, to enable prefix
mapping to drop references to absolute path. This triggers an
incompatibility since the directory of the header file is also
considered as part of the search path when resolve the include
directives in the file. Simple concatenation will result in some
`#include` can no longer be resolved.

Now relax the rule to do header content concatenation only when prefix
map is used. This will keep the breakage minimal, and the breakage can
always be fixed by additional include paths when turning on prefix
mapping.

In the future, we should move towards internal bridging header
implementation to avoid the need of chaining completely.

rdar://161854282
2025-10-03 16:34:51 -07:00
Steven Wu
818d0a026f Merge pull request #84658 from cachemeifyoucan/eng/PR-161835182
[Caching] Fix -access-note-path when using caching
2025-10-02 20:26:47 -07:00
Steven Wu
a1a67997b7 [Caching] Fix -access-note-path when using caching
Make sure to capture access-note when building with swift caching.

rdar://161835182
2025-10-02 12:09:14 -07:00
swift-ci
6cf902227a Merge remote-tracking branch 'origin/main' into rebranch 2025-09-25 15:15:11 -07:00
Steven Wu
b7329f4ea7 [Caching] Allow prefix mapping for generated bridging header
To allow prefix mapping of the bridging header to achieve cache hit when
source files are located in different location, the generated chained
bridging header should not include absolute paths of the headers. Fix
the problem by concat the chained bridging header together.

Fixes: https://github.com/swiftlang/swift/issues/84088
2025-09-24 10:14:10 -07:00
swift-ci
74964cc412 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-26 12:43:09 -07:00
Steven Wu
492f5ab611 [Caching] Do not infer default on disk cas path when parsing options
Currently, swift-frontend will always try to infer a default CASPath if
no `-cas-path` is passed. The function `getDefaultOnDiskCASPath` called
to infer the default path can fatal error in some environment where no
caching directory and home directory, no matter if caching is used or
not.

Remove the inferred path during parsing since that is not strictly
necessary. If caching is enabled and no CASPath is passed, error can be
issued during CAS construction time.

rdar://158899187
2025-08-22 12:32:24 -07:00
swift-ci
d27620fc73 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-20 10:19:17 -07:00
Steven Wu
b18e865b0a [Caching] Fix typecheck swiftinterface with prefix map
SwiftVerifyEmittedModuleInterface job is configured to be built within
the SubInvocation and it needs to inherit the caching replay prefix map
in order to load macro plugin library correctly.

rdar://158692095
2025-08-19 10:28:20 -07:00
swift-ci
c08ba7749f Merge remote-tracking branch 'origin/main' into rebranch 2025-08-09 02:55:57 -07:00
Michael Gottesman
d7e6054dc9 [concurrency] Remove from test RUN lines uses of enable-upcoming-feature RegionBasedIsolation when it is already inferred from strict-concurrency=complete. 2025-08-08 19:04:07 -07:00
Steven Wu
b103f31a3d [TEST-ONLY] Check swift generated PCM has correct dwo path
This is a testcase for rdar://156759645
2025-08-05 15:06:24 -07:00