Open
Description
When using swift_import
in Xcode 15-16 we noticed the .swiftinterface
files were trying to be found at the MacOSX
SDK root:
error: cannot open file '/Applications/Xcode-16.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/bazel-out/darwin_arm64-fastbuild/bin/test/fixtures/module_interface/library/toy_outputs/ToyModule.swiftinterface' (No such file or directory)
Which then causes issues building downstream targets. This seems to only happen for swift_import
targets that have deps
which are other swift_import
targets. One use-case of this we have is pre-compiling swift-syntax
where the built products are exposed as swift_import
targets.
See #1460 for an example that reproduces the issue.
Examples
Sandboxed (Xcode 15.4.0)
bazel clean --expunge && bazel build //test/fixtures/module_interface:client --xcode_version=15.4.0
ERROR: /Users/lpadron/Development/rules_swift/test/fixtures/module_interface/BUILD:33:13: Compiling Swift module ToyModuleConsumer from textual interface failed: (Exit 1): worker failed: error executing SwiftCompileModuleInterface command (from target //test/fixtures/module_interface:toy_module_consumer) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/tools/worker/worker swiftc @bazel-out/darwin_arm64-fastbuild/bin/test/fixtures/module_interface/ToyModuleConsumer.swiftmodule-0.params
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
<unknown>:0: error: cannot open file 'bazel-out/darwin_arm64-fastbuild/bin/test/fixtures/module_interface/library/toy_outputs/ToyModule.swiftinterface' (No such file or directory)
bazel-out/darwin_arm64-fastbuild/bin/test/fixtures/module_interface/library_consumer/toy_consumer_outputs/ToyModuleConsumer.swiftinterface:1:1: error: failed to build module 'ToyModuleConsumer' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
// swift-interface-format-version: 1.0
^
Sanbodxed (Xcode 16.1.0)
bazel clean --expunge && bazel build //test/fixtures/module_interface:client --xcode_version=16.1.0
<unknown>:0: error: cannot open file '/Applications/Xcode-16.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/bazel-out/darwin_arm64-fastbuild/bin/test/fixtures/module_interface/library/toy_outputs/ToyModule.swiftinterface' (No such file or directory)
bazel-out/darwin_arm64-fastbuild/bin/test/fixtures/module_interface/library_consumer/toy_consumer_outputs/ToyModuleConsumer.swiftinterface:4:1: error: failed to build module 'ToyModuleConsumer' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
2 | // swift-compiler-version: Apple Swift version 6.0.2 effective-5.10 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
3 | // swift-module-flags: -target arm64-apple-macos13.0 -enable-objc-interop -enable-library-evolution -static -enforce-exclusivity=checked -Onone -enable-experimental-feature AccessLevelOnImport -enable-bare-slash-regex -module-name ToyModuleConsumer
4 | import Swift
| `- error: failed to build module 'ToyModuleConsumer' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
Spawn strategy local (Xcode 15.4.0)
bazel clean --expunge && bazel build //test/fixtures/module_interface:client --spawn_strategy=local --xcode_version=15.4.0
INFO: Found 1 target...
Target //test/fixtures/module_interface:client up-to-date:
bazel-bin/test/fixtures/module_interface/client
INFO: Elapsed time: 9.571s, Critical Path: 2.78s
INFO: 43 processes: 13 internal, 30 local.
INFO: Build completed successfully, 43 total actions
Spawn strategy local (Xcode 16.1.0)
bazel clean --expunge && bazel build //test/fixtures/module_interface:client --spawn_strategy=local --xcode_version=16.1.0
ERROR: /Users/lpadron/Development/rules_swift/test/fixtures/module_interface/BUILD:33:13: Compiling Swift module ToyModuleConsumer from textual interface failed: (Exit 1): worker failed: error executing SwiftCompileModuleInterface command (from target //test/fixtures/module_interface:toy_module_consumer) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/tools/worker/worker swiftc @bazel-out/darwin_arm64-fastbuild/bin/test/fixtures/module_interface/ToyModuleConsumer.swiftmodule-0.params
<unknown>:0: error: cannot open file '/Applications/Xcode-16.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/bazel-out/darwin_arm64-fastbuild/bin/test/fixtures/module_interface/library/toy_outputs/ToyModule.swiftinterface' (No such file or directory)
bazel-out/darwin_arm64-fastbuild/bin/test/fixtures/module_interface/library_consumer/toy_consumer_outputs/ToyModuleConsumer.swiftinterface:4:1: error: failed to build module 'ToyModuleConsumer' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
2 | // swift-compiler-version: Apple Swift version 6.0.2 effective-5.10 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
3 | // swift-module-flags: -target arm64-apple-macos13.0 -enable-objc-interop -enable-library-evolution -static -enforce-exclusivity=checked -Onone -enable-experimental-feature AccessLevelOnImport -enable-bare-slash-regex -module-name ToyModuleConsumer
4 | import Swift
| `- error: failed to build module 'ToyModuleConsumer' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
5 | import ToyModule
6 | import _Concurrency
This seems to be a regression only when --spawn_strategy=local
and going from Xcode 15 -> Xcode 16 🙃