Linking on Windows without WHOLEARCHIVE

My project doesn't build since Rust 1.46.0, it builds fine with Rust 1.45.0 (and 1.44.0).

I've found that the linker (which is link.exe on Windows) is invoked with /WHOLEARCHIVE:somelib.lib where somelib.lib is the external static library linked with the project (via cargo:rustc-link-lib=static=somelib.lib). That means, before the linker is called with:

link.exe ... "somelib.lib" ...

now it is called with:

link.exe ... "somelib.lib" "/WHOLEARCHIVE:somelib.lib" ...

How can I disable the linker option /WHOLEARCHIVE:...?

I've tracked it down to this issue by @petrochenkov:

1 Like

Hmm... it's weird that the default linking behaviour was changed before static-nobundle is stabilized.

A workaround would be to drop the static= and go with the default (which is dylib). On a MSVC linker this should currently amount to the same as the old static behaviour.

1 Like

Thanks you @kornel and @chrisd,
I've dropped the static= (as said @chrisd and from a PR of rust-skia); and it builds now.

Which version of MSVC do you have? What error does it report?

Compilateur d'optimisation Microsoft (R) C/C++ version 19.26.28806 pour x64
Copyright (C) Microsoft Corporation. Tous droits réservés.

Microsoft (R) Incremental Linker Version 14.26.28806.0
Copyright (C) Microsoft Corporation.  All rights reserved.

So cl is of 19.26.28806 and link is of 14.26.28806.0.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.