Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Incremental compilation cache poisoning #1126

Open
brentleyjones opened this issue Nov 2, 2023 · 1 comment
Open

Bug: Incremental compilation cache poisoning #1126

brentleyjones opened this issue Nov 2, 2023 · 1 comment

Comments

@brentleyjones
Copy link
Collaborator

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).

@bgeron
Copy link

bgeron commented Jan 9, 2024

I think I hit a similar case in bazelbuild/rules_apple#2357 , but in my case everything was local with a disk cache.

I think this is the sequence of events that happened:

  1. Upgrade Xcode (to 15.1)
  2. Select Xcode15.1 command line tools
  3. Build our project with Bazel. This fails at a later stage because minimum_os_version = "17.2" cannot be met.
  4. Open Xcode for the first time, to download and install the included iOS 17.2 SDK.
  5. Rebuild our project with Bazel.
  6. Get an error about not being able to compile with SDK 17.2 against dependency artefacts that were built for SDK 17.0.
  7. Remove all Bazel's caches and rebuild. This succeeds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants