rules_swift icon indicating copy to clipboard operation
rules_swift copied to clipboard

Add workaround for SR-15123

Open keith opened this issue 4 years ago • 9 comments

This works around an issue in Swift 5.5 / Xcode 13.0 beta 5 where absolute paths to the sources being compiled are always used and embedded in the case a vfs overlay is used. This tricks the compiler by using a vfs overlay for the source files as well.

https://bugs.swift.org/browse/SR-15123

keith avatar Sep 13 '21 21:09 keith

We might not need this pending https://github.com/apple/llvm-project/pull/3246 but it does appear to work (only with the change being reverted though, otherwise it fails)

keith avatar Sep 13 '21 21:09 keith

optimized a bit for revertability here

keith avatar Sep 14 '21 00:09 keith

I just hit this issue trying to update xcode from 12.5.1 to 13.2.1. In my case, what I observed is that #fileID returns an absolute path that ends up inside the binaries. Before finding this PR I did write a simple reproducible example here

Thanks for the multiple attempts to fix it in different repositories @keith 🙏

How are you currently dealing with this problem? I am not sure how to work around it considering that:

  • The bug is still present in the latest Xcode 13.2.1
  • This PR is a draft, did not make it to master

Some options on the top of my mind:

  • Wait for swift 5.6, which hopefully comes with a fix (this is probably not a good idea, as it may pass some time until next release)
  • Stop using vfs overlay
  • Maintain my own clone of rules_swift and add this PR to it

acecilia avatar Jan 05 '22 21:01 acecilia

Instead of maintaining a fork, you can apply a patch with bazel: https://brentley.dev/patching-bazel-external-dependencies/

brentleyjones avatar Jan 05 '22 22:01 brentleyjones

Yep that's what I would recommend in general, and what we're doing at Lyft. I felt a bit weird about merging this at the time because I wasn't sure if it would have any unexpected side-effects. Realistically we could probably merge it now, but I was hoping that my actual fixes upstream would land soon enough that we wouldn't need too. Unfortunately it looks like they won't be fixed until Swift 5.6, which I assume won't come to Xcode until the spring

keith avatar Jan 05 '22 22:01 keith

Got it, thank you 🙌

acecilia avatar Jan 05 '22 23:01 acecilia

Lyft integration job started: https://buildkite.com/lyft/rules-swift/builds/262 (must be Lyft employee to view)

lyft-lint-bot avatar Mar 18 '22 00:03 lyft-lint-bot

The linked SR is closed. Is it still a valid bug that should be reopened?

brentleyjones avatar Aug 05 '22 18:08 brentleyjones

needs more investigation, i think there's a new one

keith avatar Aug 05 '22 18:08 keith

as of Xcode 14 we have confirmed this is fixed, and don't see any new reason to use this at the moment. I believe it was fixed earlier, with Swift 5.6, but I didn't test before Swift 5.7. Please file an issue if you find any new case that needs this!

keith avatar Sep 22 '22 22:09 keith