Skip to content

MSVC-like targets ignore target spec's linker field #48506

Closed

Description

@hanna-kruppe

Normally if -C linker is not specified, the target spec is consulted. However, is is_like_msvc is set, rustc uses "link.exe" unconditionally. This seems like an oversight. For example, it prevents setting up link.exe-flavored LLD in a target spec (which works fine with -C linker, at least as far as invoking the right executable goes).

cc @retep998

Activity

  1. hanna-kruppe commented on Feb 24, 2018

    @hanna-kruppe
    ContributorAuthor

    Correction: Since it looks only at is_like_msvc, not at linker_flavor, it's still possible to use link.exe-flavored LLD by just not setting the former. Still seems odd to hard code that name and yet let -C linker override it.

  2. retep998 commented on Feb 24, 2018

    @retep998
    Contributor

    Unlike all other targets, for the msvc targets rustc ends up going through some very complex logic to figure out where link.exe is, as well as library paths. At the time LLD was not a viable option and there were never any msvc linkers other than link.exe, so it was easier to hardcode link.exe into all the complex search logic, instead of plumbing through the target spec configuration.

    If we do choose to respect the target spec in this case, then there are some unresolved questions. For example, should we still do all that complex search logic? It's extremely unlikely LLD will be found the same way as link.exe. If we do end up just blindly shelling out to the linker when it isn't link.exe, do we still want to find the Windows SDK library paths ourselves? Currently for -C linker we don't do any special logic and just expect the user to go through all the hard work of ensuring the linker is in PATH and all the library paths are configured correctly.

  3. hanna-kruppe commented on Feb 24, 2018

    @hanna-kruppe
    ContributorAuthor

    I think it's reasonable for target.options.linker to behave exactly like -C linker.

  4. added
    A-linkageArea: linking into static, shared libraries and binaries
    O-windows-msvcToolchain: MSVC, Operating system: Windows
    on Feb 25, 2018
  5. alexcrichton commented on Mar 6, 2018

    @alexcrichton
    Member

    This was fixed in #48125

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

    A-linkageArea: linking into static, shared libraries and binariesO-windows-msvcToolchain: MSVC, Operating system: Windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions