If I build a DLL with Rust language, does it require libgcc*.dll
to be present on run time?
On one hand:
rustc.exe
has libgcc_s_dw2-1.dll
in its directory, and cargo.exe
won't run without the dll when downloaded from the http://crates.io website;On the other hand:
So, I'm confused. What's the definite answer?
Rust provides two main toolchains for Windows: x86_64-pc-windows-gnu
and x86_64-pc-windows-msvc
.
The -gnu
toolchain includes an msys
environment and uses GCC's ld.exe
to link object files. This toolchain requires libgcc*.dll
to be present at runtime. The main advantage of this toolchain is that it allows you to link against other msys
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 a Windows SDK
install or a Visual Studio
install). This toolchain does not use libgcc*.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:
Hi; I have a question: if I build a DLL with Rust, does it require libgcc*.dll to be present on run time? (on Windows)
I believe that if you use the standard library, then it does require it; IIRC we depend on one symbol from it; but I am unsure.
How can I avoid using the standard library, or those parts of it that do? (and/or do you know which symbol exactly?)
It involves #[no_std] at your crate root; I think the unsafe guide has more.
Running
nm -D | grep gcc
shows me__gc_personality_v0
, and then there is this: What is __gxx_personality_v0 for?, so it looks like our stack unwinding implementation depends on that.I seem to recall I've seen some RFCs to the effect of splitting standard library, too; are there parts I can use without pulling libgcc in?
Yes, libcore doesn't require any of that. You give up libstd.
Also, quoting parts of the unsafe guide:
The core library (libcore) has very few dependencies and is much more portable than the standard library (libstd) itself. Additionally, the core library has most of the necessary functionality for writing idiomatic and effective Rust code. (...) Further libraries, such as liballoc, add functionality to libcore which make other platform-specific assumptions, but continue to be more portable than the standard library itself.
And fragment of the current docs for unwind module:
Currently Rust uses unwind runtime provided by libgcc.
(The transcript was edited slightly for readability. Still, I'll happily delete this answer if anyone provides something better formatted and more thorough!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With