Skip to content

staticlib with lto=fat now includes compiler_builtins as llvm bitcode after rustup update #146145

Closed

Description

@behdad

In HarfBuzz we use cargo to build a staticlib, then link it to harfbuzz using meson. We use lto="fat" and that's essential to the performance of the generated rust code binary.

This used to work with gcc as the final linker with rustc 1.91.0-nightly (898aff7 2025-08-14), but after updating to rustc 1.91.0-nightly (51ff895 2025-09-02), now the generated libharfbuzz_rust.a includes: a harfbuzz_rust .o file that is an ELF binary, but also a compiler_builtins .o that is in LLVM IR bitcode. This makes the gcc linker fail linking with unknown file format error. Is this intentional?

Meta

rustc --version --verbose:

rustc 1.91.0-nightly (51ff89506 2025-09-02)
binary: rustc
commit-hash: 51ff895062ba60a7cba53f57af928c3fb7b0f2f4
commit-date: 2025-09-02
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 3, 2025
  2. Noratrieb commented on Sep 3, 2025

    @Noratrieb
    Member

    likely regressed in #145368, there's already been another issue about that PR #146109 @rcvalle @dianqk

  3. added
    A-linkageArea: linking into static, shared libraries and binaries
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    A-LTOArea: Link-time optimization (LTO)
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 3, 2025
  4. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Sep 3, 2025
  5. lqd commented on Sep 3, 2025

    @lqd
    Member

    If so, this should be fixed soon by the revert #146133

  6. apiraino commented on Sep 3, 2025

    @apiraino
    Contributor

    Assigning priority (discussion on Zulip).

    @rustbot label -I-prioritize +P-critical

  7. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Sep 3, 2025
  8. behdad commented on Sep 3, 2025

    @behdad
    Author

    Note that even trying to do the final link with lld fails, with:

    ld.lld: error: src/rust/libharfbuzz_rust.a(compiler_builtins-e82ecba48a5a77b2.compiler_builtins.c83520de7ece3beb-cgu.00.rcgu.o): Unknown attribute kind (102) (Producer: 'LLVM21.1.0-rust-1.91.0-nightly' Reader: 'LLVM 19.1.7')

  9. bjorn3 commented on Sep 3, 2025

    @bjorn3
    Member

    Is that the system lld or the rust-lld shipped with rustc? The system lld likely uses a too old LLVM version.

  10. 4 remaining items

  11. behdad commented on Sep 3, 2025

    @behdad
    Author

    Does using lld together with a nightly rustc from before this regression also regress performance? Aka is the performance regression from using lld or from compiler-builtins participating in LTO.

    My bad. I was measuring with different codegen-units. Setting codegen-units=1 I see the same performance with all scenarios.

  12. rcvalle commented on Sep 3, 2025

    @rcvalle
    Member

    @rustbot claim

  13. added a commit that references this issue on Sep 3, 2025
  14. rcvalle commented on Sep 4, 2025

    @rcvalle
    Member

    Fixed in #146133.

  15. added 3 commits that reference this issue on Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LTOArea: Link-time optimization (LTO)A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions