Skip to content

Linking Time #50

Open
Open
@Lokathor

Description

@Lokathor

There was a reddit thread I just saw in the rust_gamedev group, and many people were reporting specifically that link times were killing the development flow.

I figured it needed a tracker/complaint issue here.


UPDATE:

@MaulingMonkey advised that lld-link.exe is already a working drop-in replacement on windows that will generally Just Work(tm) with the MSVC toolchain. It's not default but you can configure it to be used while we wait for the default compiler selection to catch up.

You can pass a compiler arg to use the linker:

-Clinker="C:\Program Files\LLVM\bin\lld-link.exe"

Or you can set a config setting in your cargo config file
(eg: C:\Users\<username>\.cargo\config):

[target.x86_64-pc-windows-msvc]
linker = "C:\\Program Files\\LLVM\\bin\\lld-link.exe"

It's a little less of a sure thing with the MingW toolchain, but you shouldn't be using that toolchain anyway, so whatever. This should probably work though:

[target.x86_64-pc-windows-gnu]
linker = "C:\\Program Files\\LLVM\\bin\\ld64.lld.exe"
rustflags = ["-Clink-args=-arch x86_64"]

Of course you'll need to install LLVM for this to work: http://releases.llvm.org/download.html

Naturally you already had LLVM on your dev machine because you need it for bindgen, right? ;3

and of course, edit the paths above to whatever folder you install LLVM to if you use a non-default directory.

  • Note: As with any other .cargo/config setting, you can also apply this on a per project basis by placing a config file into [project_folder]/.cargo/config, however I don't personally advise this because it makes the project less portable. While the target triple will change from machine to machine, if another windows dev without the LLVM linker tries to build it on their machine they'll suddenly get a build error.

  • Note: Using lld-link.exe seems to not work with miri,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Long Term GoalIssues where we expect progress to be slow

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions