GCC ABI

https://wiki.gentoo.org/wiki/Upgrading_GCC/zh-cn#.E4.BB.8B.E7.BB.8D

本文档将指导用户完成GCC的升级。
Contents
[hide]
1 快速开始
1.1 介绍
1.2 Short version
2 GCC upgrading explained
2.1 介绍
2.2 libtool 和 fix_libtool_files.sh
2.3 ABI changes
2.3.1 The special case C++11 (and C++14)
2.4 Rebuilding everything
3 故障排除
3.1 libstdc++.so.6: version `GLIBCXX_3.4.15’ not found
3.2 那些包是已知的要重新构建的?
4 另请参阅
快速开始
介绍
这篇文章讲述 升级 GCC。GCC降级可能会有不愿看到的副作用。对于一些报告中常见的问题请查阅故障排除一节。
下一节将给出GCC升级的快速指南(这件事太容易了)。如果你想要阅读升级GCC背后冗长的材料,请继续阅读GCC升级详解。
Short version
如果你正在升级GCC,那么你需要做的事情只有改变编译器版本和重新构建libtool。
root #emerge -u sys-devel/gcc
root #gcc-config -l
[1] i686-pc-linux-gnu-4.4.5 *
[2] i686-pc-linux-gnu-4.5.3

root #gcc-config 2
root #env-update && source /etc/profile
root #emerge –oneshot libtool
If you upgrade GCC from a version earlier than 3.4.0 (for the 3.x series) or 4.1, you will need to run revdep-rebuild as well:
root #revdep-rebuild –library ‘libstdc++.so.5’
检查当前版本并卸载旧版本
root #gcc –version
root #emerge -C =sys-devel/gcc-4.4.5
这样就完成了!
GCC upgrading explained
介绍
GCC upgrading has always been mystified, with suggestions ranging from “You do not need to do anything” up to “You will need to rebuild your entire system twice”. Most of this FUD comes from the confusion surrounding ABI incompatibility. But first a quick pointer towards libtool.
libtool 和 fix_libtool_files.sh
早前在 Gentoo 上安装 GCC 需要你运行一个叫 fix_libtool_files.sh 的特定命令。一段时间之后,安装包(通过 toolchain eclass)集成了自动执行这个命令,因此用户不需要再手动执行。
The reason we need to rebuild libtool after the upgrade of gcc versions is because of its main purpose: libtool is a toolset that aggregates platform-specific code in a generic interface, allowing applications to build against shared libraries without needing to deal with the platform specific aspects of shared libraries. To fulfill its function properly, the libtool script uses various library locations that have hard-coded gcc version information in them.
ABI changes
ABI应用程序二进制接口是一个所有处理二进制的程序(包括编译器、汇编器、链接器和语言运行库支持)都会使用的接口(来源:GCC 二进制兼容性)。当二进制程序和库使用的 ABI 改变了之后,你将面临 链接错误或者程序错误的风险,除非你重新编译了所有的使用 C++ 代码的库。
Yes, C++, since most incompatibilities occur within the C++ ABI. If you are upgrading to GCC 4.1, or GCC 5.1, you would probably encounter ABI issues. This is also why we use the revdep-rebuild command against the libstdc++.so.5 (from GCC 3 to GCC 4.1), or libstdc++.so.6 (from GCC 4 to GCC 5.1).
root #revdep-rebuild –library ‘libstdc++.so.6’ – –exclude gcc
那么为什么只有升级到GCC 3.4.0/4.1/5.1版本才需要这么做?这是因为在这之前的版本,GCC采用向下兼容的ABI,这使得你不需要重新编译软件和系统库。当然,我们不能永远保证这种兼容性。如果发生不兼容的情况,libstdc++.so 库将很可能也会升级到更高的版本。
The special case C++11 (and C++14)
While GCC (or more specifically, libstdc++) goes to great lengths to guarantee stability of the ABI, this guarantee does not extend to all parts of C++ within libstdc++. Formally, with versions starting from 3.4, GCC/libstdc++ only guarantees C++98/C++03 ABI stability and not more. This is crucial for packages that depend on C++11. GCC only makes C++11 ABI stability guarantees beginning with version 5.1. This means that switching (even minor) versions of gcc (say from 4.7.3 -> 4.7.4) might cause ABI breakage for binaries built from C++11 code.
For more information and some examples, see:
https://bugs.gentoo.org/show_bug.cgi?id=513386
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61758
https://blogs.gentoo.org/blueness/2015/03/10/the-c11-abi-incompatibility-problem-in-gentoo/
http://stackoverflow.com/a/16196475
Rebuilding everything
一些人认为当新版本的GCC安装好之后,他们需要重新编译他们系统上的已经安装过的应用,当然,这被认为是没有意义的,因为这里有很多应用在编译和构建的时候并没有用到GCC,所以更新不会影响到它们.
That however doesn’t mean they are completely incorrect: newer GCC versions often include better support for the processors’ instruction set, which might influence the performance of some applications in a positive way. Although it is expected that this improvement is generally only marginal, in some cases (especially CPU intensive applications) this might yield notable improvements.
There are also known cases where packages need to be built with the same compiler. Although these packages are usually bumped by Gentoo simultaneously (so that they are always built with the same GCC version) cherry-picking re-installs on these packages might prove to be troublesome. The various qt-* packages are a nice example on this matter.
故障排除
libstdc++.so.6: version GLIBCXX_3.4.15' not found
在升级过程中,你或许会遇到以下面这些错误:
CODE GLIBCXX_x.y.z not found
cmake_bootstrap_28021_test: /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/libstdc++.so.6:
version
GLIBCXX_3.4.11’ not found

这意味着你正在用一个”较老版本”(新版本指的是那些已经构建好这些依赖库的版本)的GCC来构建这些包.请记住所谓的C++ABI 向前兼容指的是:假设你可以用某个版本的GCC成功构建程序和连接库文件,那么你可以用比这个版本更高版本GCC去构建这些程序,而不是用更低版本GCC来构建这些程序.
To rebuild all the packages depending on libstdc++, see the previous revdep-rebuild section.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值