swift code being compiled 3 times
Nobody has claimed this yet.
- Dominant language
- Starlark
- Stars
- 209
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
Hello @thii!
We migrated all our project and its dependencies to bazel but we can't reduce the build time in incremental builds for swift targets.
I added the profiling flag to bazel build command and here are the results loaded in chrome, as you can see there are three "Compiling Swift module Apollo" steps in different threads.

And if I use the official Bazel rule there is only one "Compiling Swift module Apollo" step

So I think that the swift module is being compile 3 times, I tried to modify the swift_static_framework.bzl without success, as far as I understand I guess that it is compiling 3 times because of the 3 header maps (public, private, private angled), each one compiles a swift module?
Do you have the same behavior with Line's dependencies?
Here is the target definition:
```
load("@rules_apple_line//apple:apple_library.bzl", "swift_library")
swift_library(
name = "Apollo",
srcs = glob(["Apollo/Sources/Apollo/*.swift"]),
module_name = "Apollo",
visibility = ["//visibility:public"],
)
```
And the trace files:
[traces.zip](https://github.com/line/rules_apple_line/files/5777012/traces.zip)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining swift_static_framework.bzl and the apple_library.bzl swift_library entry point used by the target definition. Reproduce the Apollo build with the provided profiling traces and compare it with the official Bazel rule. Done means identifying why three Swift module compilation steps are scheduled and reducing the target to one compilation step.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100