[英]Do DLLs built with Rust require libgcc.dll on run time?
If I build a DLL with Rust language , does it require libgcc*.dll
to be present on run time? 如果我使用Rust语言构建DLL,它是否需要在运行时出现
libgcc*.dll
?
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; rustc.exe
在其目录中有libgcc_s_dw2-1.dll
,当从http://crates.io网站下载时, cargo.exe
将无法在没有dll的情况下运行; 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
. Rust为Windows提供了两个主要的工具链:
x86_64-pc-windows-gnu
和x86_64-pc-windows-msvc
。
The -gnu
toolchain includes an msys
environment and uses GCC's ld.exe
to link object files. -gnu
工具链包括一个msys
环境,并使用GCC的ld.exe
链接目标文件。 This toolchain requires libgcc*.dll
to be present at runtime. 此工具链要求
libgcc*.dll
在运行时出现。 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. 此工具链的主要优点是,它允许您链接到其他
msys
提供的库,这可以更容易链接到在正常Windows环境下难以处理的某些C \\ C ++库。
The -msvc
toolchain uses the standard, native Windows development tools (either a Windows SDK
install or a Visual Studio
install). -msvc
工具链使用标准的本机Windows开发工具( Windows SDK
安装或Visual Studio
安装)。 This toolchain does not use libgcc*.dll
at either compile or runtime. 此工具链在编译或运行时不使用
libgcc*.dll
。 Since this toolchain uses the normal windows linker, you are free to link against any normal Windows native libraries. 由于此工具链使用普通的Windows链接器,因此您可以自由链接任何普通的Windows本机库。
If you need to target 32-bit Windows, i686-
variants of both of these toolchains are available. 如果您需要针对32位Windows,则可以使用这两种工具链的
i686-
变体。
NOTE: below answer summarizes situation as of Sep'2014 ; 注:以下答案总结了截至2014年9月的情况 ; 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.
但我强烈怀疑事情发生了变化,因为从那时起已经过了2年。 It would be cool if somebody tried to ask steveklabnik about it again, then update below info, or write a new, fresher answer!
如果有人试图再次询问steveklabnik,然后更新以下信息,或写一个新的,更新鲜的答案,那将是很酷的!
Quick & raw transcript of a Rust IRC chat with steveklabnik, who gave me a kind of answer: Rust IRC与steveklabnik聊天的快速和原始记录,他给了我一个答案:
Hi;
你好; I have a question: if I build a DLL with Rust, does it require libgcc*.dll to be present on run time?
我有一个问题:如果我用Rust构建一个DLL,它是否需要在运行时出现libgcc * .dll? (on Windows)
(在Windows上)
I believe that if you use the standard library, then it does require it;
我相信如果你使用标准库,它确实需要它; IIRC we depend on one symbol from it;
IIRC我们依赖于它的一个符号; 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;
它涉及你的箱子根#[no_std]; I think the unsafe guide has more.
我认为不安全的指南有更多。
Running
nm -D | grep gcc
运行
nm -D | grep gcc
nm -D | grep gcc
shows me__gc_personality_v0
, and then there is this: What is __gxx_personality_v0 for?nm -D | grep gcc
给我看__gc_personality_v0
,然后有这个: __gxx_personality_v0是什么? , 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;
我似乎记得我已经看到了一些分裂标准库的RFC; are there parts I can use without pulling libgcc in?
有没有拉libgcc可以使用的部分?
Yes, libcore doesn't require any of that.
是的, libcore不需要任何这些。 You give up libstd .
你放弃了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.
核心库(libcore)具有非常少的依赖性,并且比标准库(libstd)本身更便携。 Additionally, the core library has most of the necessary functionality for writing idiomatic and effective Rust code.
此外,核心库具有编写惯用和有效Rust代码所需的大部分必要功能。 (...) 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.
(...)其他库(如liballoc)为libcore添加了其他特定于平台的假设,但仍然比标准库本身更具可移植性。
And fragment of the current docs for unwind module : 以及用于展开模块的当前文档的片段:
Currently Rust uses unwind runtime provided by libgcc.
目前Rust使用libgcc提供的展开运行时。
(The transcript was edited slightly for readability. Still, I'll happily delete this answer if anyone provides something better formatted and more thorough!) (为了便于阅读,略微编辑了成绩单。但是,如果有人提供更好的格式化和更彻底的东西,我会很乐意删除这个答案!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.