目次

,

gentoo の gcc をアップデートする

これも恐ろしい作業ですよね。今回は 4.x.x から 5.x.x にアップデートします。GCC のアップグレードとか Upgrading from gcc-4.x to gcc-5.x あたりを参考にやっていこうと思います。

まずは emerge しないとね

とりあえず、最悪しんじゃっても被害の少ない完全に自宅使用のファイルサーバーでやってみます。

# emerge -uavDN world

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U  ] sys-libs/libseccomp-2.3.2::gentoo [2.3.0::gentoo] USE="-static-libs" ABI_X86="(64) -32 (-x32)" 547 KiB
[ebuild  NS    ] sys-devel/gcc-5.4.0-r3:5.4.0::gentoo [4.9.4:4.9.4::gentoo] USE="cxx fortran (multilib) nls nptl openmp sanitize vtv (-altivec) (-awt) -cilk -debug -doc (-fixed-point) -gcj -go -graphite (-hardened) (-jit) (-libssp) -mpx -nopie -nossp -objc -objc++ -objc-gc -regression-test -vanilla" 0 KiB
[ebuild     U  ] sys-apps/portage-2.3.5::gentoo [2.3.3::gentoo] USE="(ipc) native-extensions xattr -build -doc -epydoc (-selinux)" LINGUAS="-ru" PYTHON_TARGETS="python2_7 python3_4 (-pypy) (-python3_5) (-python3_6)" 912 KiB
[ebuild     U  ] sys-devel/automake-1.15-r2:1.15::gentoo [1.15:1.15::gentoo] 1462 KiB
[ebuild     U  ] dev-python/certifi-2017.1.23::gentoo [2016.9.26::gentoo] PYTHON_TARGETS="python2_7 python3_4 (-pypy) (-pypy3) (-python3_5) (-python3_6)" 372 KiB
[ebuild     U  ] sys-apps/hwids-20170328::gentoo [20150717-r1::gentoo] USE="net pci udev usb" 2002 KiB
[ebuild   R    ] sys-apps/util-linux-2.28.2::gentoo  USE="cramfs ncurses nls pam readline suid systemd udev unicode -build -caps -fdformat -kill -python (-selinux) -slang -static-libs {-test} -tty-helpers" ABI_X86="(64) -32 (-x32)" PYTHON_SINGLE_TARGET="python3_4* -python2_7* (-python3_5) (-python3_6)" PYTHON_TARGETS="python2_7 python3_4 (-python3_5) (-python3_6)" 0 KiB
[ebuild     U  ] sys-apps/systemd-233-r1:0/2::gentoo [226-r2:0/2::gentoo] USE="acl gcrypt* kmod lz4 pam seccomp ssl (-apparmor) -audit -build -cryptsetup -curl -doc% -elfutils -gnuefi -http -idn -importd -lzma -nat -policykit -qrcode (-selinux) -sysv-utils {-test} -vanilla -xkb (-kdbus%*)" ABI_X86="(64) -32 (-x32)" 4583 KiB

Total: 8 packages (6 upgrades, 1 in new slot, 1 reinstall), Size of downloads: 9874 KiB

Would you like to merge these packages? [Yes/No] y

うどんワールドすんなよ……ってハナシもありますが、まぁw gcc のアップデートしたからって emerge -e system とかするほど狂信者でもないので。完了までうちの環境では1時間ってとこですね……ファイルサーバーは、まぁ「ファイルサーバーなのでそんなにリソース食わないだろう」ってメモリ 1GB しか割り当ててないんですが、可能ならもうちょっと盛って置いた方がいいと思います。 ……swap がヤヴァいことになりました。

さて後処理ですが

こんな感じに POST メッセージが出てます。

 * Messages for package sys-devel/gcc-5.4.0-r3:

 * If you have issues with packages unable to locate libstdc++.la,
 * then try running 'fix_libtool_files.sh' on the old gcc versions.
 * You might want to review the GCC upgrade guide when moving between
 * major versions (like 4.2 to 4.3):
 * https://wiki.gentoo.org/wiki/Upgrading_GCC

 * Messages for package sys-apps/util-linux-2.28.2:

 * The mesg/wall/write tools have been disabled due to USE=-tty-helpers.
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * Regenerating GNU info directory index...
 * Processed 102 info files.

 * IMPORTANT: config file '/etc/logrotate.d/elog-save-summary' needs updating.
 * See the CONFIGURATION FILES and CONFIGURATION FILES UPDATE TOOLS
 * sections of the emerge man page to learn how to update config files.

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.

 * After world updates, it is important to remove obsolete packages with
 * emerge --depclean. Refer to `man emerge` for more information.

まず * IMPORTANT: config file '/etc/logrotate.d/elog-save-summary' needs updating.dispatch-conf で適宜さっさと対応してしまいます。

次は wiki に書いてあるとおりに gcc-config します。

# gcc-config -l
 [1] x86_64-pc-linux-gnu-4.9.4 *
 [2] x86_64-pc-linux-gnu-5.4.0
# gcc-config 2
 * Switching native-compiler to x86_64-pc-linux-gnu-5.4.0 ...
>>> Regenerating /etc/ld.so.cache...                                      [ ok ]

 * If you intend to use the gcc from the new profile in an already
 * running shell, please remember to do:

 *   . /etc/profile

# env-update && . /etc/profile
>>> Regenerating /etc/ld.so.cache...
# gcc-config -l
 [1] x86_64-pc-linux-gnu-4.9.4
 [2] x86_64-pc-linux-gnu-5.4.0 *

ちゃんと 5.x.x に * が付いてます。それでは wiki に従って libtool を emerge します。

# emerge -av --oneshot libtool

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-devel/libtool-2.4.6-r3:2::gentoo  USE="-vanilla" 951 KiB

Total: 1 package (1 reinstall), Size of downloads: 951 KiB

Would you like to merge these packages? [Yes/No] y

ここはまぁ、特に問題もなくサックリと。

それから * IMPORTANT: 1 news items need reading for repository 'gentoo'. に対応しましょうか。 eselect news read で読んでみます。

# eselect news read
2015-10-22-gcc-5-new-c++11-abi
  Title                     GCC 5 Defaults to the New C++11 ABI
  Author                    Mike Frysinger <vapier@gentoo.org>
  Posted                    2015-10-22
  Revision                  2

GCC 5 uses the new C++ ABI by default.  When building new code, you might run
into link time errors that include lines similar to:
...: undefined reference to '_ZNSt6chrono12steady_clock3nowEv@GLIBCXX_3.4.17'

Or you might see linkage failures with "std::__cxx11::string" in the output.

These are signs that you need to rebuild packages using the new C++ ABI.
You can quickly do so by using revdep-rebuild (from gentoolkit).

For gentoolkit-0.3.1 or higher:
# revdep-rebuild --library 'libstdc++.so.6' -- --exclude gcc

For previous versions of gentoolkit:
# revdep-rebuild --library 'libstdc\+\+\.so\.6' -- --exclude gcc

For more details, feel free to peruse:
https://developerblog.redhat.com/2015/02/05/gcc5-and-the-c11-abi/
https://blogs.gentoo.org/blueness/2015/03/10/the-c11-abi-incompatibility-problem-in-gentoo/

ふむ……

# emerge -pv gentoolkit

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] app-portage/gentoolkit-0.3.3::gentoo  PYTHON_TARGETS="python2_7 python3_4 (-pypy) (-python3_5)" 3123 KiB

Total: 1 package (1 reinstall), Size of downloads: 3123 KiB

うちの gentoolkit は 0.3.3 なので、上のヤツを叩けば良いみたいですね。とりあえず -pv 付けて叩いてみます。

# revdep-rebuild -pv --library 'libstdc++.so.6' -- --exclude gcc
 * This is the new python coded version
 * Please report any bugs found using it.
 * The original revdep-rebuild script is installed as revdep-rebuild.sh
 * Please file bugs at: https://bugs.gentoo.org/
 * Collecting system binaries and libraries
 * Collecting dynamic linking informations
 * Scanning files
 * Checking dynamic linking consistency
 * Files that depend on: libstdc++.so.6 (32 bits)
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/32/libasan.so.1.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/32/libubsan.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/32/libasan.so.2.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/32/libubsan.so.0.0.0
 * Files that depend on: libstdc++.so.6 (64 bits)
        * /sbin/pdata_tools
        * /usr/bin/DllPlugInTester
        * /usr/bin/addftinfo
        * /usr/bin/ccmake
        * /usr/bin/cmake
        * /usr/bin/cpack
        * /usr/bin/ctest
        * /usr/bin/eqn
        * /usr/bin/gperf
        * /usr/bin/grn
~(略)~
 !!! Dependant orphaned files: No installed package was found for the following:
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/libasan.so.1.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/32/libubsan.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/liblsan.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/libtsan.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/libcc1.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/liblsan.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/libubsan.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/32/libubsan.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/32/libasan.so.2.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/libubsan.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/32/libasan.so.1.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/libtsan.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/plugin/libcc1plugin.so.0.0.0
        * /usr/lib64/gcc/x86_64-pc-linux-gnu/5.4.0/libasan.so.2.0.0

emerge --exclude gcc --pretend --verbose --oneshot --complete-graph=y sys-block/
thin-provisioning-tools:0 sys-apps/groff:0 dev-util/gperf:0 dev-python/subunit:0
 net-libs/gnutls:0 sys-apps/gptfdisk:0 dev-util/cppunit:0 sys-libs/ncurses:0/6 d
ev-util/cmake:0 dev-libs/boost:0/1.62.0 sys-libs/db:5.3 dev-libs/gmp:0/10.4 app-
text/openjade:0 dev-libs/libpcre:3 sys-devel/gettext:0 app-text/opensp:0

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-libs/ncurses-6.0-r1:0/6::gentoo  USE="cxx unicode -ada -deb
ug -doc -gpm -minimal -profile -static-libs {-test} -threads -tinfo -trace" ABI_
X86="(64) -32 (-x32)" 0 KiB
[ebuild   R    ] dev-util/gperf-3.0.4::gentoo  0 KiB
[ebuild   R    ] dev-util/cppunit-1.13.2-r2::gentoo  USE="-doc -examples -static
-libs" ABI_X86="(64) -32 (-x32)" 0 KiB
[ebuild   R    ] dev-libs/boost-1.62.0-r1:0/1.62.0::gentoo  USE="nls threads -context -debug -doc -icu -mpi -python -static-libs -tools" ABI_X86="(64) -32 (-x32)" PYTHON_TARGETS="python2_7 python3_4 (-python3_5)" 0 KiB
[ebuild   R    ] dev-libs/gmp-6.1.0:0/10.4::gentoo  USE="asm cxx -doc -pgo -static-libs" ABI_X86="(64) -32 (-x32)" 0 KiB
[ebuild   R    ] sys-devel/gettext-0.19.8.1::gentoo  USE="acl cxx ncurses nls openmp -cvs -doc -emacs -git -java -static-libs" ABI_X86="(64) -32 (-x32)" 0 KiB
[ebuild   R    ] app-text/opensp-1.5.2-r3::gentoo  USE="nls -doc -static-libs {-test}" 0 KiB
[ebuild   R    ] dev-libs/libpcre-8.40-r1:3::gentoo  USE="bzip2 cxx jit readline recursion-limit (unicode) zlib -libedit -pcre16 -pcre32 -static-libs" ABI_X86="(64) -32 (-x32)" 0 KiB
[ebuild   R    ] sys-apps/gptfdisk-1.0.1::gentoo  USE="ncurses -static" 191 KiB
[ebuild   R    ] dev-util/cmake-3.7.2::gentoo  USE="ncurses -doc -emacs -qt5 -system-jsoncpp {-test}" 0 KiB
[ebuild   R    ] sys-libs/db-5.3.28-r2:5.3::gentoo  USE="cxx -doc -examples -java -tcl {-test}" ABI_X86="(64) -32 (-x32)" 0 KiB
[ebuild   R    ] sys-block/thin-provisioning-tools-0.4.1::gentoo  USE="{-test}" 0 KiB
[ebuild   R    ] sys-apps/groff-1.22.2::gentoo  USE="-X -examples" L10N="ja" 0 KiB
[ebuild   R    ] net-libs/gnutls-3.3.26::gentoo  USE="crywrap cxx nls openssl zlib -dane -doc -examples -guile -pkcs11 -static-libs {-test}" ABI_X86="(64) -32 (-x32)" LINGUAS="-cs -de -en -fi -fr -it -ms -nl -pl -sv -uk -vi -zh_CN" 0 KiB
[ebuild   R    ] app-text/openjade-1.3.2-r6::gentoo  USE="-static-libs" 0 KiB
[ebuild   R    ] dev-python/subunit-1.2.0-r1::gentoo  USE="-static-libs {-test}" ABI_X86="(64) -32 (-x32)" PYTHON_TARGETS="python2_7 python3_4 (-pypy) (-pypy3) (-python3_5) (-python3_6)" 0 KiB

Total: 16 packages (16 reinstalls), Size of downloads: 191 KiB

……よくわからないですけど、wiki にも条件付きで実行する必要がある1)と書いてありますし、やっといた方がよさそうですね。-pv 外して実行します。

# revdep-rebuild --library 'libstdc++.so.6' -- --exclude gcc

環境次第ですが、この vm では dev-libs/boost が結構大物なのでこれも時間がかかりました……

お掃除します

古い gcc を消してしまいましょう。

# emerge -pv --depclean
~(略)~
>>> These are the packages that would be unmerged:


!!! 'app-editors/nano' (virtual/editor) is part of your system profile.
!!! Unmerging it may be damaging to your system.


 app-editors/nano
    selected: 2.6.3
   protected: none
     omitted: none

 sys-devel/gcc
    selected: 4.9.4
   protected: none
     omitted: 5.4.0-r3

 sys-kernel/gentoo-sources
    selected: 4.9.6-r1
   protected: none
     omitted: 4.9.16

All selected packages: =sys-devel/gcc-4.9.4 =app-editors/nano-2.6.3 =sys-kernel/gentoo-sources-4.9.6-r1

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

Packages installed:   270
Packages in world:    22
Packages in system:   44
Required packages:    267
Number to remove:     3

5.x.x 系の gcc が omitted になっているのを確認して……

# emerge -av --depclean gcc

Calculating dependencies... done!
  sys-devel/gcc-5.4.0-r3 pulled in by:
    @system requires sys-devel/gcc
    sys-libs/glibc-2.23-r3 requires >=sys-devel/gcc-4.7

>>> Calculating removal order...

>>> These are the packages that would be unmerged:

 sys-devel/gcc
    selected: 4.9.4
   protected: none
     omitted: 5.4.0-r3

All selected packages: =sys-devel/gcc-4.9.4

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

Would you like to unmerge these packages? [Yes/No] y

こんな感じかな。2時間ぐらいかかるからチマチマ他の vm にも適用していこう……

1)
今回は対象外のはずなんですけどね……