如果clang ++和g ++不兼容ABI,则二进制共享库使用什么? [英] If clang++ and g++ are ABI incompatible, what is used for shared libraries in binary?

查看:150
本文介绍了如果clang ++和g ++不兼容ABI,则二进制共享库使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

clang ++和g ++与ABI不兼容,即使是作为标准容器的核心,例如clang ++网站。

clang++ and g++ are ABI incompatible, even for things as core as standard containers, according to, e.g., the clang++ website.

Debian附带了C ++共享库,即libboost等。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。安装clang时,debian不会删除系统中安装的每个C ++库的重复版本。

Debian ships with C++ shared libraries, i.e. libboost, etc... that are compiled with ~something and user programs using both compiler generally work, and the library names aren't mangled with the compiler that was used for them. When you install clang, debian doesn't go and pull in duplicate versions of every C++ library installed on your system.

这是怎么回事? clang与发行版提供的C ++库链接的能力是否比(非常谨慎的)编译器开发人员所描述的强大?

What's the deal? Is the ability of clang to link against distro-provided C++ libraries just way stronger than the (thankfully cautious) compiler devs describe it to be?

推荐答案


即使对于作为标准容器为核心的东西

even for things as core as standard containers

标准容器并不是所有的核心。 (对于典型的实现),它们完全用有效的C ++标头实现,并且如果您使用G ++和Clang ++编译相同的标头,则会获得与ABI兼容的输出。如果您使用不同版本的容器标头,而不仅仅是使用Clang而不是GCC,则应该只获得即使对于作为标准容器来说是核心的东西也不兼容。

Standard containers are not all that "core". (For typical implementations) they are implemented entirely in valid C++ in headers, and if you compile the same headers with G++ and Clang++ you'll get ABI compatible output. You should only get incompatibilities "even for things as core as standard containers" if you use different versions of the container headers, not just by using Clang instead of GCC.

两者GCC和Clang符合跨供应商,跨平台 C ++ ABI (最初是为Itanium架构开发的,但也用于x86,x86_64,SPARC等。)真正核心内容(例如类布局,名称处理,异常处理,vtable等)由该ABI指定Clang和GCC都遵循它。

Both GCC and Clang conform to a cross-vendor, cross-platform C++ ABI (originally developed for the Itanium architecture, but also used for x86, x86_64, SPARC etc.) The really core things such as class layout, name mangling, exception handling, vtables etc. are specified by that ABI and Clang and GCC both follow it.

换句话说,如果您用GCC和Clang编译相同的源代码,则将获得与ABI兼容的二进制文件。

So in other words, if you compile the same source with GCC and Clang you'll get ABI-compatible binaries.

如果您想更好地理解这些内容,请参阅我的什么是ABI,为什么这么复杂?幻灯片。

If you want to understand this stuff better see my What's an ABI and why is it so complicated? slides.

这篇关于如果clang ++和g ++不兼容ABI,则二进制共享库使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆