SwiftASTContext when parsing swiftmodules currently applies the
working-directory flag if found in the ExtraClangOptions (see here).
This works well in most use cases, but in the case of distributed builds - for distributed builds (on remote machines), the paths may be invalid (as they're a path on the remote machine, not the local one).
For Bazel, which supports distributed builds, we pass relative paths for all compilation inputs as well as a
-fdebug-prefix-map=<execution root>=. to make all embedded paths relative. This works well, except for the folowing:
- SwiftASTContext doesn't respect any previous
-fdebug-prefix-map=in the extra args, only remappings specified from the dSYMs/target source map.
- The SearchPaths embedded inside the swift modules are also absolute paths (therefore also remote paths); I'm not sure if this is even consumed (or remapped) by
SwiftASTContextor at all.
I'm not sure about the second point, but due to the first point, distributed Swift builds are failing to load modules since the paths are absolute paths for the remote machine instead of the local one.
I think the best way to fix this would be to add
-fdebug-prefix-map= support to
ClangArgs handling, but I'm not sure. If the second point is an issue as well, we'll also need to fix up those.
Any ideas @Adrian_Prantl?