Comments (10)
+1 Here in case the discussion continues...I understand Swift's compilation model presents unique challenges :) Same with @keith, we have a fairly large Swift application, and for development, incremental builds are the only way we could be productive. We plan on adopting bazel for all the other dependencies, and relying on Xcode for Swift.
from rules_apple.
Bazel in general does not support this. Each build gets a clean sandbox, so keeping previous object files is not possible. Changing the way bazel works is a much harder problem, sadly.
That said, we currently use WMO on debug builds to speed up compilation. You can put "-wmo" into copts of a swift_library target to do that.
from rules_apple.
Since our project is entirely written in Swift, even wmo builds take minutes, where incremental builds take < 10 seconds normally. Because of that I think it would never be feasible for us to use a tool that didn't support Swift incremental compilation.
I'm surprised to hear that bazel has no support for this for any language? But I guess since this isn't really feasible to change we can close this. Thanks for the context!
from rules_apple.
I'm going to reöpen this issue because I think it highlights an important area where we (that is, Bazel) could do better, even if we don't have any immediate clean solutions yet. I'll give it an appropriately low priority.
FWIW, sandboxing can be disabled for individual actions (set nosandbox
to True
in the execution requirements), but Bazel's hermeticity requirements would imply that you should be able to pass those .o
files from previous builds as inputs to subsequent builds, and you have no guarantee that those files will exist at any time (e.g., bazel clean
).
@dmishe likely has more info or possible workarounds.
from rules_apple.
Right, one way to achieve this is to make swift_library output intermediary files into a location outside of bazel tree, say, /tmp. This way bazel will only cleanup the final products, but swiftc will see previously built objects and use that. You will also need to add a global dependency map output (see https://github.com/apple/swift/blob/master/docs/Driver.md#output-file-maps) to make this work.
The other, more sophisticated but also not hermetic, approach is to use a relatively new Bazel feature called persistent workers. This is in fact something we wanted to use in the long run. Let's keep this issue open to track this.
from rules_apple.
First off, kudos to getting swift compiling under bazel 👍 I'm using swift for some small projects - my builds are running exclusively through Xcode, where swiftc
's incremental compilation seems to work. I'm wondering if bazel can provide any speedup's over Xcode.
I had a minute to look at the swift rules this morning, based on my ( weak ) understanding of bazel, I think it may work nicely with swifts compilation model. Have you considered:
- breaking up the swift compilations into individual targets, where each compilation outputs a partial swift model.
- creating a target that depends on all of the partial targets, and simply links all of the partial modules together.
I think a design similar to this could leverage bazel's hermaticness, caching, and incremental build abilities. This is just speculation: I haven't had a chance to implement this yet.
Tangentially related, I was looking at some of the work the Swift team has done for Swift PM. They have been implementing a quite nice build system, lower level build system, which should also do incremental builds. I wonder how llb
overlaps with bazel.
from rules_apple.
Is there a misunderstanding here? According to the user manual, incremental builds are a "primary goal" of Bazel: https://docs.bazel.build/versions/master/user-manual.html#correctness
I made a small cc_library
with two files, and when I changed one of the files, only that one file was recompiled (according to --subcommands
). This is what I would expect, but this issue is saying Bazel doesn't support this. 🤔
from rules_apple.
I believe dmishe was referring more about bazel's model being different enough to Swift's model to make incremental builds for Swift incompatible.
from rules_apple.
Are there any related issues elsewhere about supporting the Swift-style incremental compilation model? It sounds like kotlin and rust might also benefit from support for this in bazel, although I'm not 100% sure they use exactly the same model.
from rules_apple.
Since the swift_library
in rules_apple is deprecated in favor of bazelbuild/rules_swift, I've opened an issue over there to track this: bazelbuild/rules_swift#48
from rules_apple.
Related Issues (20)
- `ios_build_test` and `ios_application ` cannot be directly used with default platform from apple_support HOT 4
- iOS app tutorial steps produce an app that crashes on launch HOT 1
- xctoolrunner failed: error executing in Downstream CI with Bazel@HEAD HOT 2
- How to build for multiple architectures HOT 10
- Support XCFramework Signatures HOT 5
- Failed xctoolrunner error executing AssetCatalogCompile command with Bazel@HEAD HOT 2
- Terminating app due to uncaught exception 'IBPlatformToolFailureException', reason: 'The tool closed the connection (AssetCatalogSimulatorAgent) HOT 1
- Bazel 7: Linking actions missing`-framework` flags for framework imports HOT 2
- iOSApp.ipa: code object is not signed at all HOT 1
- framework import by apple_static_framework_import crashed after update bazel from 5.4.1 to 6.5.0 HOT 3
- Duplicate symbols from apple_static_xcframework
- [Bazel 7] ios_application linking issue - "Could not find or use auto-linked framework" HOT 3
- [Bazel CI] Rule fails to build with error: 'struct' value has no field or method 'to_json' HOT 2
- `target_compatible_with` appears to be broken in Bazel 7.x
- `security` tool fails when codesigning with 3.5.0 HOT 2
- Support extension blocks in DocC rule
- Question: data attribute for macos_command_line_application or alternative
- Unable to nest app bundles within a macos_application
- How should I build a Network Extension about Xcode HOT 4
- Generated XCFramework fails on Xcode 15.3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_apple.