rules_swift
rules_swift copied to clipboard
Add workaround for SR-15123
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
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)
optimized a bit for revertability here
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_swiftand add this PR to it
Instead of maintaining a fork, you can apply a patch with bazel: https://brentley.dev/patching-bazel-external-dependencies/
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
Got it, thank you 🙌
Lyft integration job started: https://buildkite.com/lyft/rules-swift/builds/262 (must be Lyft employee to view)
The linked SR is closed. Is it still a valid bug that should be reopened?
needs more investigation, i think there's a new one
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!