rules_swift icon indicating copy to clipboard operation
rules_swift copied to clipboard

Incremental compilation issue? `output 'foo.swiftinterface' was not created`

Open jpsim opened this issue 3 years ago • 5 comments

This is a possible incremental compilation issue that I often run into when building Envoy Mobile.

$ ./bazelw build --config=ios //library/swift:ios_framework
DEBUG: /private/var/tmp/_bazel_jsimard/e99b8d924fe95f277e909ecdb8681535/external/rules_python/python/pip.bzl:46:10: pip_install is deprecated. Please switch to pip_parse. pip_install will be removed in a future release.
WARNING: /Users/jsimard/src/envoy/mobile/library/common/jni/BUILD:95:27: target 'libndk_envoy_jni.jnilib' is both a rule and a file; please choose another name for the rule
INFO: Analyzed target //library/swift:ios_framework (203 packages loaded, 6726 targets configured).
INFO: Found 1 target...
ERROR: /Users/jsimard/src/envoy/mobile/library/swift/BUILD:9:14: output 'library/swift/Envoy.swiftinterface' was not created
ERROR: /Users/jsimard/src/envoy/mobile/library/swift/BUILD:9:14: Compiling Swift module //library/swift:ios_lib failed: not all outputs were created or valid
Target //library/swift:ios_framework failed to build
INFO: Elapsed time: 175.004s, Critical Path: 13.14s
INFO: 517 processes: 5 internal, 511 darwin-sandbox, 1 worker.
FAILED: Build did NOT complete successfully
$ echo "// Touch" >> library/swift/EngineBuilder.swift
$ ./bazelw build --config=ios //library/swift:ios_framework
DEBUG: /private/var/tmp/_bazel_jsimard/e99b8d924fe95f277e909ecdb8681535/external/rules_python/python/pip.bzl:46:10: pip_install is deprecated. Please switch to pip_parse. pip_install will be removed in a future release.
WARNING: /Users/jsimard/src/envoy/mobile/library/common/jni/BUILD:95:27: target 'libndk_envoy_jni.jnilib' is both a rule and a file; please choose another name for the rule
INFO: Analyzed target //library/swift:ios_framework (2 packages loaded, 3330 targets configured).
INFO: Found 1 target...
INFO: From Linking library/swift/ios_framework-arm64-apple-ios12.0-simulator-fl.a:
...
Target //library/swift:ios_framework up-to-date:
  bazel-bin/library/swift/ios_framework.zip
INFO: Elapsed time: 36.327s, Critical Path: 31.53s
INFO: 16 processes: 3 internal, 12 darwin-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions

I understand this isn't enough information to debug on your end, so please advise what files you'd like me to share or commands I should run in order to help you investigate this.

  • Bazel version: 6.0.0-pre.20220706.4
  • rules_swift version: e769f8d6a4adae93c244f244480a3ae740f24384
  • .bazelrc: https://github.com/envoyproxy/envoy/blob/main/mobile/.bazelrc
  • Other deps versions: https://github.com/envoyproxy/envoy/blob/main/mobile/bazel/envoy_mobile_repositories.bzl

jpsim avatar Dec 06 '22 17:12 jpsim

ah yea i think this is a bug because likely not many folks do incremental with this file, i think we need to handle it here https://github.com/bazelbuild/rules_swift/blob/7d8769a9d5024200da8a34999e5934b23f441e90/tools/worker/output_file_map.cc#L153-L174

keith avatar Dec 06 '22 17:12 keith

Since we don't have much Swift in our project, would you suggest we disable incremental compilation as a temporary workaroud?

We only have a single module, 71 Swift files and ~2k lines of code.

jpsim avatar Dec 06 '22 18:12 jpsim

yea probably won't make a huge difference to just use WMO always until we fix. i wouldn't be surprised if it's actually faster always since it's not a huge module

keith avatar Dec 06 '22 18:12 keith

yea probably won't make a huge difference to just use WMO always until we fix.

Sounds good. Is there a feature to use WMO that applies to all compilation modes? I see swift.opt_uses_wmo but that seems to only apply to -c opt and I also see swift._wmo_in_swiftcopts but there's a comment saying that feature should never be used directly.

jpsim avatar Dec 06 '22 18:12 jpsim

--swiftcopt=-wmo is the recommendation atm

keith avatar Dec 06 '22 18:12 keith