LLVM 和 Visual Studio .obj 二进制不兼容
有谁知道 LLVM 二进制兼容性是否计划用于 Visual Studio 组合的 .obj 和静态 .lib 文件? 现在我只能将 LLVM 制作的 .obj 文件与在运行时加载 DLL 的动态库(从 Visual Studio 编译)链接。
虽然两个编译器之间发生二进制兼容性的可能性很小,但有人知道为什么一个平台的编译器之间实现这一点如此困难吗?
Does anyone know if LLVM binary compatibility is planned for visual studio combiled .obj and static .lib files?
Right now I can only link LLVM made .obj files with dynamic libs that loads a DLL at runtime (compiled from visual studio).
While there probably is very small chances that binary compatibility will happen between the two compilers, does anybody know why it is so difficult achieving this between compilers for one platform?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如尼尔已经说过的,兼容性包括调用约定、名称修改等内容。尽管这两个问题是可能出现的最小问题。 LLVM 已经了解所有特定于 Windows 的调用约定(stdcall、fastcall、thiscall),这就是为什么您可以从 .dll 调用内容。
如果我们谈论 C++ 代码,那么主要问题是 C++ ABI:vtable 布局、rtti 实现等。clang 遵循 Itanium C++ ABI(例如,gcc 使用的),VCPP - 没有,所有这些都没有文档记录,很遗憾。在这个方向上正在进行一些工作,所以事情可能会开始明显地发挥作用。请注意,很可能某些部分永远不会被涵盖,例如 win32 上基于 seh 的异常处理,因为它已获得专利。
与纯 C 代码的链接已经工作了很长时间,因此,您可以通过 C 存根/包装器解决这些与 C++ ABI 相关的问题。
As Neil already said, the compatibility includes stuff like calling convention, name mangling, etc. Though these two are the smallest possible problems. LLVM already knows about all windows-specific calling conventions (stdcall, fastcall, thiscall), this is why you can call stuff from .dll's.
If we speak about C++ code then the main problem is C++ ABI: vtable layout, rtti implementation, etc. clang follows Itanium C++ ABI (which gcc use, for example, among others), VCPP - doesn't and all these are undocumented, unfortunately. There is some work going in clang in this direction, so stuff might start to work apparently. Note that most probably some parts will never be covered, e.g. seh-based exception handling on win32, because it's patented.
Linking with pure C code worked for ages, so, you might workaround these C++ ABI-related issues via C stubs / wrappers.
除了其他任何事情(例如调用约定、寄存器使用等)之外,为了使 C++ 代码二进制兼容,两个编译器必须使用相同的名称修饰方案。这些方案是专有的(因此 MS 不会公布其方案的详细信息),并且在任何情况下都处于不断变化的状态。
Apart from anything else, such as calling conventions, register usage etc, for C++ code to binary compatible the two compilers must use the same name-mangling scheme. These schemes are proprietory (so MS does not release the details if its scheme) and are in any case in a constant state of flux.