LLVM and visual studio .obj binary incompatibility

天涯浪子 提交于 2019-12-07 04:24:54

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/6329688/llvm-and-visual-studio-obj-binary-incompatibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!