Skip to content

Comments

Pass -object_path_lto <path> linker flag for LTO builds#420

Merged
keith merged 1 commit intobazelbuild:masterfrom
sanju-naik:bugfix/lto_builds
Aug 6, 2025
Merged

Pass -object_path_lto <path> linker flag for LTO builds#420
keith merged 1 commit intobazelbuild:masterfrom
sanju-naik:bugfix/lto_builds

Conversation

@sanju-naik
Copy link
Contributor

@sanju-naik sanju-naik commented Jul 31, 2025

This is needed for LTO builds, this is the path to which linker writes one big object file after performing link time optimisations, and then this object file would be used during final linking to create the App binary, without this file binary would contain invalid debug symbols, more info - bazelbuild/rules_swift#1529 .

To enable this you need to pass bazel build --features=full_lto or bazel build --features=thin_lto, along with rules_swift LTO features.

Closes - bazelbuild/rules_swift#1529

This is needed for LTO builds, this is the path to which linker writes one big object file after performing link time optimisations, and then this object file would be used during final linking to create the App binary, without this file binary would contain invalid debug symbols, more info - bazelbuild/rules_swift#1529
@sanju-naik sanju-naik marked this pull request as ready for review July 31, 2025 19:15
@sanju-naik
Copy link
Contributor Author

Thank you @keith for helping on this 🙏

@keith keith merged commit 61b44d1 into bazelbuild:master Aug 6, 2025
11 checks passed
keith added a commit that referenced this pull request Aug 28, 2025
Fixes #423

We should re-apply with the actual configs for full_lto and thin_lto, we
should be able to write a test to verify it works too.

This reverts commit 61b44d1.
keith added a commit that referenced this pull request Aug 28, 2025
Fixes #423

We should re-apply with the actual configs for full_lto and thin_lto, we
should be able to write a test to verify it works too.

This reverts commit 61b44d1.
keith added a commit that referenced this pull request Aug 28, 2025
…" (#426)

Fixes #423

We should re-apply with the actual configs for full_lto and thin_lto, we
should be able to write a test to verify it works too.

This reverts commit 61b44d1.
ma-oli added a commit to ma-oli/apple_support that referenced this pull request Sep 2, 2025
The following commit (in 1.23.0) was reverted recently (in 1.23.1):
* commit 61b44d1
* revert 4c51f10

This patch is a new attempt at getting that feature merged, but without
the LTO related issues that came up in the first patch. The difference
is that we're adding that feature unconditionally now, as it won't hurt
linking actions when LTO is disabled anyway. And enabling the bazel lto
features changes the linking workflow in a way that isn't necessary on
Apple platforms.

Initial commit log below.
---

This is needed for LTO builds, this is the path to which linker writes
one big object file after performing link time optimisations, and then
this object file would be used during final linking to create the App
binary, without this file binary would contain invalid debug symbols,
more info - bazelbuild/rules_swift#1529 .

Closes - bazelbuild/rules_swift#1529

Co-authored-by: Mathieu Olivari <[email protected]>
Co-authored-by: Sanju Naik <[email protected]>
keith pushed a commit that referenced this pull request Sep 2, 2025
The following commit (in 1.23.0) was reverted recently (in 1.23.1):
* commit 61b44d1
* revert 4c51f10

This patch is a new attempt at getting that feature merged, but without
the LTO related issues that came up in the first patch. The difference
is that we're adding that feature unconditionally now, as it won't hurt
linking actions when LTO is disabled anyway. And enabling the bazel lto
features changes the linking workflow in a way that isn't necessary on
Apple platforms.

Initial commit log below.
---

This is needed for LTO builds, this is the path to which linker writes
one big object file after performing link time optimisations, and then
this object file would be used during final linking to create the App
binary, without this file binary would contain invalid debug symbols,
more info - bazelbuild/rules_swift#1529 .

Closes - bazelbuild/rules_swift#1529

Co-authored-by: Sanju Naik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants