Skip to content

Commit 4b5e3f0

Browse files
jayzhuangCQ Bot
authored and
CQ Bot
committedFeb 5, 2025
[rust] Link dylibs with LTO
This currently only applies to libstd, and automatically to future dylibs introduced to the build. We start to properly set `-Zdylib-lto` since https://fxrev.dev/1001661. Context on linking dylibs in LTO: rust-lang/rust#31854 (comment) Bug: 394439548 Change-Id: I48237a739cb1b2bd02c284306d6e82d43eb83cc0 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1192917 Commit-Queue: Jay Zhuang <[email protected]> Reviewed-by: David Turner <[email protected]> Reviewed-by: Gulfem Savrun Yeniceri <[email protected]>
1 parent fff6b3c commit 4b5e3f0

File tree

3 files changed

+0
-21
lines changed

3 files changed

+0
-21
lines changed
 

Diff for: ‎build/config/BUILDCONFIG.gn

-13
Original file line numberDiff line numberDiff line change
@@ -3018,19 +3018,6 @@ template("_fuchsia_shared_library") {
30183018
_link_output_dir =
30193019
rebase_path(get_path_info(link_output_file, "dir"), root_build_dir)
30203020

3021-
# rustc doesn't support building dylibs with LTO enabled without the
3022-
# `-Zdylib-lto` flag. For now we just disable LTO on these targets.
3023-
if (defined(configs) && defined(crate_type)) {
3024-
configs += [
3025-
"//build/config/lto",
3026-
"//build/config/lto:thinlto",
3027-
]
3028-
configs -= [
3029-
"//build/config/lto",
3030-
"//build/config/lto:thinlto",
3031-
]
3032-
}
3033-
30343021
# Note: the manifest-related metadata is added to the builder target as
30353022
# some targets (e.g. drivers) depend on it directly in the builder
30363023
# toolchain.

Diff for: ‎examples/rust/dylib/rust-bin/BUILD.gn

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ rustc_test("rust-bin") {
2121
"//examples/rust/dylib/rust-shared",
2222
"//src/lib/fuchsia",
2323
]
24-
25-
# rustc doesn't support linking to dylibs while using LTO unless the
26-
# `-Zdylib-lto` flag is passed. For now we exclude this binary from building
27-
# with any LTO variants.
28-
exclude_toolchain_tags = [ "lto" ]
2924
}
3025

3126
fuchsia_unittest_package("rust-shared") {

Diff for: ‎src/lib/ui/carnelian/BUILD.gn

-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ rustc_library("carnelian") {
129129
}
130130

131131
configs += [ ":carnelian-performance" ]
132-
133-
# Dynamic linking libstd is incompatible with LTO.
134-
configs -= [ "//build/config/fuchsia:dynamic_rust_standard_library" ]
135132
}
136133

137134
config("carnelian-performance") {

0 commit comments

Comments
 (0)
Please sign in to comment.