Coder Social home page Coder Social logo

Comments (10)

jgavris avatar jgavris commented on May 24, 2024 1

+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.

dmishe avatar dmishe commented on May 24, 2024

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.

keith avatar keith commented on May 24, 2024

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.

allevato avatar allevato commented on May 24, 2024

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.

dmishe avatar dmishe commented on May 24, 2024

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.

jerrymarino avatar jerrymarino commented on May 24, 2024

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.

kastiglione avatar kastiglione commented on May 24, 2024

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.

sergiocampama avatar sergiocampama commented on May 24, 2024

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.

keith avatar keith commented on May 24, 2024

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.

allevato avatar allevato commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.