Skip to content

rustc should attempt to use the gold linker by default, but this breaks Debian Wheezy because of obsolete gcc #30783

Not planned
@brson

Description

@brson
Contributor

Original report.

Rust nightly uses the gold linker where it can by passing -fuse-ld=gold to gcc when it sees that ld.gold exists. Unfortunately, even if ld.gold exists gcc may not understand -fuse-ld=gold.

This distro came out in May 2013, so it's not that old.

Activity

brson

brson commented on Jan 11, 2016

@brson
ContributorAuthor

If this can't be fixed in the next week it should probably be reverted to rethink the migration strategy.

alexcrichton

alexcrichton commented on Jan 12, 2016

@alexcrichton
Member

Aw man this is unfortunate. Agree on reverting if we can't figure anything else out.

I guess an "ideal solution" would be if gcc/clang read an environment variable as well as an argument, but I unfortunately don't see such an environment variable in clang at least. We can maybe try to parse something like /etc/issue but that seems pretty sketchy.

I wonder, how is one supposed to tell gcc on wheezy to use gold?

brson

brson commented on Jan 12, 2016

@brson
ContributorAuthor

@xitep suggested how to detect gcc's support for this. Unfortunately it involves running gcc an extra time. I can't think of anything better.

alexcrichton

alexcrichton commented on Jan 12, 2016

@alexcrichton
Member

It's true that's a possibility, I would likely prefer to see that as the compiler attempts to run the entire linker and then parses the error message if one shows up, and only then is gold removed if the entire linker fails. That way we'd only run gcc once if possible, and twice in the worst case.

That being said that's still a pretty big hit for distros because it's 2 times on all compiles, which is pretty unfortunate :(

xitep

xitep commented on Jan 12, 2016

@xitep

I actually like the idea of environment variables from a user perspective. If I'd be able to set RUSTC_DISABLE_GOLD=1 (or similar) in one of my login scripts to the system I'd be totally happy (right now my solution is quite ugly with wrapping rustc with custom scripts). So far, I think, rustc itself doesn't interpret any envs, does it? So it'd be new territory with its own set of problems I guess.

alexcrichton

alexcrichton commented on Jan 12, 2016

@alexcrichton
Member

Oh sorry I meant moreso the compiler sets an environment variable which gcc then interprets rather than the other way around. I'd personally prefer to avoid too many environment variables for the rustc compiler.

xitep

xitep commented on Jan 12, 2016

@xitep

"I wonder, how is one supposed to tell gcc on wheezy to use gold?": it seems just by installing binutils-gold. /usr/bin/ld becomes a symlink to /usr/bin/ld.gold.

xitep

xitep commented on Jan 12, 2016

@xitep

An alternative to /etc/issue might also be /etc/debian_version. But using these files seems very fragile to me :/ And adding dependencies on such external files will probably make the code in rustc unmaintainable in some future.

alexcrichton

alexcrichton commented on Jan 12, 2016

@alexcrichton
Member

Hm detecting whether ld is a symlink and whether it points to ld.gold seems reasonable, but there's still a possibility that the symlink isn't there, ld.gold exists, and -fuse-ld=gold isn't accepted unfortunately

pnkfelix

pnkfelix commented on Jan 12, 2016

@pnkfelix
Member

@alexcrichton

That being said that's still a pretty big hit for distros because it's 2 times on all compiles, which is pretty unfortunate

Assuming we add some way for the user to specify "disable gold", we could issue a warning when we run gcc twice, recommending that the user change their rustc invocation (or host configuration) accordingly

pnkfelix

pnkfelix commented on Jan 12, 2016

@pnkfelix
Member

(that way it's only "2 times until user changes host configuration to disable gold usage on rustc " Which is better than 2 times always

alexcrichton

alexcrichton commented on Jan 12, 2016

@alexcrichton
Member

@pnkfelix perhaps yeah, but at that point I'd probably be more in favor of just disabling by default.

19 remaining items

added
T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.
and removed on May 24, 2017
sanmai-NL

sanmai-NL commented on Jun 1, 2017

@sanmai-NL

@bstrie: small update, the release date for Debian Stretch has been set at 17 June 2017.

SimonSapin

SimonSapin commented on Nov 27, 2017

@SimonSapin
Contributor

Stretch is now (and has been for a few months) stable, Jessie is oldstable, and Wheesy is in "LTS" until May 2018.

Can we enable ld.gold by default yet?

CC @rust-lang/compiler

SimonSapin

SimonSapin commented on Nov 27, 2017

@SimonSapin
Contributor

Or is it @rust-lang/dev-tools ?

glandium

glandium commented on Apr 3, 2018

@glandium
Contributor

Note that Wheezy is going to have some extra support time. https://raphaelhertzog.com/2018/02/20/time-to-join-extended-long-term-support-for-debian-7-wheezy/

But... why does rust invoke ld through gcc anyways?

SimonSapin

SimonSapin commented on Apr 3, 2018

@SimonSapin
Contributor

Even if some people and companies want to keep supporting Wheezy, does that mean that recent rustc versions need to do the same?

glandium

glandium commented on Apr 3, 2018

@glandium
Contributor

Well, Firefox builds are done on Debian Wheezy at the moment...

workingjubilee

workingjubilee commented on Sep 5, 2020

@workingjubilee
Member

It's 2020.
It's time for
the_gold_experience

Mark-Simulacrum

Mark-Simulacrum commented on Jan 7, 2024

@Mark-Simulacrum
Member

I'm going to close in favor of #39915, which is tracking a move to LLD by default. I don't think investing in a move to gold first makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@alexcrichton@birkenfeld@brson@pnkfelix

        Issue actions

          rustc should attempt to use the gold linker by default, but this breaks Debian Wheezy because of obsolete gcc · Issue #30783 · rust-lang/rust