If I build a DLL with Rust language, does it require libgcc*.dll
to be present on run time?
On one hand:
- I've seen a post somewhere on the Internet, claiming that yes it does;
rustc.exe
haslibgcc_s_dw2-1.dll
in its directory, andcargo.exe
won't run without the dll when downloaded from the http://crates.io website;
On the other hand:
- I've seen articles about building toy OS kernels in Rust, so they most certainly don't require libgcc dynamic library to be present.
So, I'm confused. What's the definite answer?
Rust provides two main toolchains for Windows:
x86_64-pc-windows-gnu
andx86_64-pc-windows-msvc
.The
-gnu
toolchain includes anmsys
environment and uses GCC'sld.exe
to link object files. This toolchain requireslibgcc*.dll
to be present at runtime. The main advantage of this toolchain is that it allows you to link against othermsys
provided libraries which can make it easier to link with certain C\C++ libraries that are difficult to under the normal Windows environment.The
-msvc
toolchain uses the standard, native Windows development tools (either aWindows SDK
install or aVisual Studio
install). This toolchain does not uselibgcc*.dll
at either compile or runtime. Since this toolchain uses the normal windows linker, you are free to link against any normal Windows native libraries.If you need to target 32-bit Windows,
i686-
variants of both of these toolchains are available.NOTE: below answer summarizes situation as of Sep'2014; I'm not aware if it's still current, or if things have changed to better or worse since then. But I strongly suspect things have changed, given that 2 years have already passed since then. It would be cool if somebody tried to ask steveklabnik about it again, then update below info, or write a new, fresher answer!
Quick & raw transcript of a Rust IRC chat with steveklabnik, who gave me a kind of answer:
Also, quoting parts of the unsafe guide:
And fragment of the current docs for unwind module:
(The transcript was edited slightly for readability. Still, I'll happily delete this answer if anyone provides something better formatted and more thorough!)