Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 950275 - dev-lang/rust-1.85.0 - musl targets defaulting to static linking
Summary: dev-lang/rust-1.85.0 - musl targets defaulting to static linking
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Randy Barlow
URL:
Whiteboard:
Keywords: PullRequest
: 940722 950258 950286 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-02-25 15:12 UTC by vadorovsky
Modified: 2025-02-25 19:30 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vadorovsky 2025-02-25 15:12:21 UTC
Rust (upstream) defaults to static linking on *-musl targets, which goes against the expected workflow for Linux distros (dynamic linking by default, static linking opt-in).

There is an initiative to fix that and default to dynamic linking:

https://github.com/rust-lang/compiler-team/issues/422

And there is even this commit, which got released in 1.85.0 and made us think that the issue got fixed:

https://github.com/rust-lang/rust/commit/9c37c14aa2456315bf7b3fa7b3e089bc13a43ee9

But unfortunately, it still enforces static linking for existing targets - see the specific target files in the commit. The actual upstream work to fix the existing targets still needs to be done.

In all versions before 1.85.0, we were applying a patch which defaults to musl builds. We need to restore and rebase that patch for 1.85.0 as well.

Reproducible: Always

Steps to Reproduce:
1. emerge =dev-lang/rust-1.85.0
2. Try installing an ebuild which depends on shared libraries. A good example is gnome-base/librsvg
Actual Results:  
Build fails with:

  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: ld.lld: error: unable to find library -lcairo
          ld.lld: error: unable to find library -lpng16
          ld.lld: error: unable to find library -lcairo-gobject
          ld.lld: error: unable to find library -lpng16
          ld.lld: error: unable to find library -lgio-2.0
          ld.lld: error: unable to find library -licuuc
          ld.lld: error: unable to find library -lpangocairo-1.0
          ld.lld: error: unable to find library -lcairo
          ld.lld: error: unable to find library -lpangoft2-1.0
          ld.lld: error: unable to find library -lpango-1.0
          ld.lld: error: unable to find library -lfontconfig
          ld.lld: error: unable to find library -lharfbuzz
          ld.lld: error: unable to find library -lfreetype
          ld.lld: error: unable to find library -lgobject-2.0
          ld.lld: error: unable to find library -lglib-2.0
          ld.lld: error: unable to find library -lpangocairo-1.0
          ld.lld: error: unable to find library -lpango-1.0
          ld.lld: error: unable to find library -lcairo
          ld.lld: error: unable to find library -lharfbuzz
          ld.lld: error: unable to find library -lgobject-2.0
          ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Expected Results:  
We expect rust ebuilds to link dynamically, unless we explicitly opt-in to static linking.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-02-25 19:28:04 UTC
*** Bug 950286 has been marked as a duplicate of this bug. ***
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-02-25 19:28:18 UTC
*** Bug 940722 has been marked as a duplicate of this bug. ***
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-02-25 19:28:24 UTC
*** Bug 950258 has been marked as a duplicate of this bug. ***
Comment 4 Larry the Git Cow gentoo-dev 2025-02-25 19:29:58 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0f68a2ec8ad3feb9a50d1db9b4ea1d7ed6f22bda

commit 0f68a2ec8ad3feb9a50d1db9b4ea1d7ed6f22bda
Author:     Michal Rostecki <vadorovsky@protonmail.com>
AuthorDate: 2025-02-25 15:34:12 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2025-02-25 19:29:09 +0000

    dev-lang/rust: Enable dynamic linking by default for musl targets
    
    We already have a similar patch for versions before 1.85.0.
    Change rust-lang/rust@9c37c14aa245, which got released in 1.85.0,  made
    us think that such a patch is not needed anymore, but that's not true.
    Upstream didn't fix the existing individual targets yet.
    
    Bug: https://bugs.gentoo.org/950275
    Signed-off-by: Michal Rostecki <vadorovsky@protonmail.com>
    Closes: https://github.com/gentoo/gentoo/pull/40752
    Signed-off-by: Sam James <sam@gentoo.org>

 .../rust/files/1.85.0-musl-dynamic-linking.patch   | 271 +++++++
 dev-lang/rust/rust-1.85.0-r1.ebuild                | 800 ++++++++++++++++++++
 dev-lang/rust/rust-1.86.0_beta20250218-r1.ebuild   | 807 +++++++++++++++++++++
 dev-lang/rust/rust-9999.ebuild                     |   1 +
 4 files changed, 1879 insertions(+)