Skip to content

How to find LLD with old versions of gcc? #97402

Closed
@petrochenkov

Description

@petrochenkov

This issue is related to stabilizing use of LLD from rustc and/or making it default - rust-lang/compiler-team#510, #39915.

GCC and Clang have several ways to specify linker.

  • -B directory, you specify a search directory, then the compiler finds a file named ld in it an uses it as a linker.
    This is the old way working on all versions of GCC and Clang that we want to support (?).
  • -fuse-ld=bfd|gold|lld|mold limited to 4 well-known linker names, you specify the name, then the compiler finds a file named ld.name in its search directories.
    This is a somewhat new way, the well-known name -fuse-ld=lld works in Clang, and in GCC since 2018 (which GCC version?).
  • -fuse-ld=/absolute/path/to/lld, where you specify the full linker path.
    This doesn't work with GCC, and worked with Clang since 2016, but is now deprecated in favor of --ld-path.
  • --ld-path=/absolute/path/to/lld, where you specify the full linker path.
    This doesn't work with GCC, and works with Clang since 2021.

rustc needs to tell C compiler to use LLD in two modes

  • "Self-contained" mode when we need to find the LLD shipped with rustc.
    This mode always uses -B directory right now (after Simplify implementation of -Z gcc-ld #97375) just because it's simple to do, but it also means that old compilers are supported.
  • Mode in which we should find system-provided LLD.
    QUESTIONS:
    • How should we do it?
    • Do we care about older GCC versions that don't support -fuse-ld=lld?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesT-compilerRelevant to the compiler team, 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

    Issue actions