bazelbuild / bazelbuild/rules_swift
Bug: Incremental compilation cache poisoning
- Dominant language
- Starlark
- Stars
- 353
- Forks
- 172
- Avg merge
- 23h 14m
- Merged PRs (30d)
- 8
Description
I _assume_ it's from incremental compilation, because I don't know how a normal compile could do this.
I have a case where _somehow_ (I think a failed or cancelled compile) an old version of a `.swiftmodule` was uploaded to the remote cache. For example, I have an action that sets these env variables:
```
"environmentVariables": [{
"name": "APPLE_SDK_PLATFORM",
"value": "MacOSX"
}, {
"name": "APPLE_SDK_VERSION_OVERRIDE",
"value": "14.2"
}, {
"name": "SWIFT_AVOID_WARNING_USING_OLD_DRIVER",
"value": "1"
}, {
"name": "XCODE_VERSION_OVERRIDE",
"value": "15.1.0.15C5042i"
}]
```
but I'm getting back a `.swiftmodule` from the remote cache that was compiled against macOS SDK 14.0:
```
/Users/brentley/Developer/rules_xcodeproj/tools/generators/lib/PBXProj/src/Dictionary+Extensions.swift:1:8: Cannot load module 'OrderedCollections' built with SDK 'macosx14.0' when using SDK 'macosx14.2': /Users/brentley/Developer/rules_xcodeproj/bazel-output-base/rules_xcodeproj.noindex/build_output_base/execroot/_main/bazel-out/macos-arm64-min13.0-applebin_macos-darwin_arm64-dbg-ST-95054d4cebee/bin/external/_main~non_module_deps~com_github_apple_swift_collections/OrderedCollections.swiftmodule
```
I feel there is an edge case in the incremental compilation support that could allow something like this to happen (because it has old versions laying around).
Contributor guide
Research direction
No source file or test is named. Start by tracing the incremental compilation and remote-cache handling described in the report, reproduce with the listed Apple SDK and Xcode environment variables, and compare the cached .swiftmodule SDK version with the requested SDK; done means an old module can no longer be returned after a failed or cancelled compile.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100