![]() |
LINUX |
glibcの設定 4 Xen
*xenを起動するとtlsをdisabledにするよう、警告がでる場合があります
*tlsをdisabledにすると他に影響を与える場合があります
*CentOSのglibc.specにはxen用のライブラリを特別に作成する仕組みがあります
*xen用のライブラリは"-mno-tls-direct-seg-refs"オプション付で作成されます
*xen用のライブラリは/lib/i686/nosegnegディレクトリに作られます
*xen用のライブラリをシステムに認識させるように設定します
*glibcを"-mno-tls-direct-seg-refs"オプション付でリビルドする方法も試します
*make はメンテナンスマシンで行っています
**以降はコメントです
*ソースの取得、削除は省略します
*エディタ、ファイラーの操作は省略します
*Enterキーを省略します
*ログイン端末で "#" はroot、"$" は一般ユーザのプロンプトの記号です
*設定ファイルで "#" で始まる行はコメントとして解釈されます
関連サイト| :glibc-2.5-49.el5_5.2.src.rpm (http://mirrors.kernel.org/centos/) |
参照ファイル
リビルド環境| :OS | CentOS 5.5 |
| :selinux | disabled |
| :kernel | kernel-2.6.18-194.3.1.el5 |
| :glibc | glibc-2.5-49.el5_5.2 |
| :インストール先 | |
| :作業 | /usr/src |
| :言語 | LANG=en_US.UTF-8 |
| :ユーザー | rootで実行 |
*メンテナンスは一般ユーザから行います
xen用のライブラリをシステムに認識させる*xen-kernelの起動時に出されるWARNING
*************************************************************** *************************************************************** ** WARNING: Currently emulating unsupported memory accesses ** ** in /lib/tls glibc libraries. The emulation is ** ** slow. To ensure full performance you should ** ** install a 'xen-friendly' (nosegneg) version of ** ** the library, or disable tls support by executing ** ** the following as root: ** ** mv /lib/tls /lib/tls.disabled ** ** Offending process: iconvconfig.i68 (pid=1256) ** *************************************************************** ***************************************************************
*CentOSのglibc.specにはxen用のライブラリを特別に作成する仕組みがあります
*xen用のライブラリは"-mno-tls-direct-seg-refs"オプション付で作成されます
*xen用のライブラリは/lib/i686/nosegnegディレクトリに作られます
*xenのkernelにはnosegnegを利用する仕組みがあります
:linux-2.6.18-xen.hg/arch/i386/kernel/vsyscall-note-xen.S
/*
* This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
* Here we can supply some information useful to userland.
* First we get the vanilla i386 note that supplies the kernel version info.
*/
#include "vsyscall-note.S"
/*
* Now we add a special note telling glibc's dynamic linker a fake hardware
* flavor that it will use to choose the search path for libraries in the
* same way it uses real hardware capabilities like "mmx".
* We supply "nosegneg" as the fake capability, to indicate that we
* do not like negative offsets in instructions using segment overrides,
* since we implement those inefficiently. This makes it possible to
* install libraries optimized to avoid those access patterns in someplace
* like /lib/i686/tls/nosegneg. Note that an /etc/ld.so.conf.d/file
* corresponding to the bits here is needed to make ldconfig work right.
* It should contain:
* hwcap 0 nosegneg
* to match the mapping of bit to name that we give here.
*/
#define NOTE_KERNELCAP_BEGIN(ncaps, mask) \
ASM_ELF_NOTE_BEGIN(".note.kernelcap", "a", "GNU", 2) \
.long ncaps, mask
#define NOTE_KERNELCAP(bit, name) \
.byte bit; .asciz name
#define NOTE_KERNELCAP_END ASM_ELF_NOTE_END
NOTE_KERNELCAP_BEGIN(1, 1)
NOTE_KERNELCAP(0, "nosegneg")
NOTE_KERNELCAP_END
*nosegnegの仕組みを取り込む
# echo 'hwcap 0 nosegneg' > /etc/ld.so.conf.d/xen-glibc.conf # ldconfig
*xen用のglibcライブラリを読み込む例
# ldd /usr/local/apache2/bin/httpd
linux-gate.so.1 => (0xb7f8d000)
libm.so.6 => /lib/i686/nosegneg/libm.so.6 (0xb7f5a000)
libpcre.so.0 => /lib/libpcre.so.0 (0x4c9c0000)
libaprutil-1.so.0 => /usr/local/apache2/lib/libaprutil-1.so.0 (0xb7f3e000)
libexpat.so.0 => /lib/libexpat.so.0 (0x4c970000)
libapr-1.so.0 => /usr/local/apache2/lib/libapr-1.so.0 (0xb7f17000)
libuuid.so.1 => /lib/libuuid.so.1 (0x4c4d6000)
librt.so.1 => /lib/i686/nosegneg/librt.so.1 (0xb7f0d000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0xb7edb000)
libpthread.so.0 => /lib/i686/nosegneg/libpthread.so.0 (0xb7ec1000)
libdl.so.2 => /lib/libdl.so.2 (0xb7ebc000)
libc.so.6 => /lib/i686/nosegneg/libc.so.6 (0xb7d60000)
/lib/ld-linux.so.2 (0xb7f8e000)
glibcのリビルド*redhat系ではxenのサポートをしない方向です
*xen用のライブラリが作られない場合や、nosegnegで上手くいかない場合など
*glibcを"-mno-tls-direct-seg-refs"オプション付で作成する方法も試します
System clockの設定*"system clock"で UTC を使うように設定します
*マシンの再起動
:/etc/sysconfig/clock
ZONE="Asia/Tokyo" UTC=true ARC=false
glibc-2.5-49.el5_5.2*/usr/srcでソースファイルを展開します
# useradd mockbuild # cd /usr/src # mkdir glibc # rpm -ivh glibc-2.5-49.el5_5.2.src.rpm # cd redhat/SPECS
*glibc.specファイルの修正 (下記)
# vi glibc.spec
# rpmbuild -bb --target i686 --clean --rmsource \ --define 'dist .el5_5' glibc.spec
*コンパイルが修了するまで1GHz-CPUで3時間程度かかります
*debuginfoパッケージはインストールしません
*適当なディレクトリに保存してアップデートします
# mv glibc.spec /usr/src/glibc # cd ../RPMS/i686
*作成されたパッケージ
glibc-2.5-49.el5_5.2.i686.rpm
# mv *.rpm /usr/src/glibc
*強制上書きアップデート
# cd /usr/src/glibc # rpm -Uvh --force glibc-2.5-49.el5_5.2.i686.rpm
# userdel -r mockbuild
*i386パッケージ(glibc-commonなど)もリビルドする場合は
*i686パッケージを作成する前に下記コマンドを実行します
# rpmbuild -bb --define 'dist .el5_5' glibc.spec
:glibc.specの修正
*ix86,i686に"no-tls-direct-seg-refs"オプションを与えてコンパイルします
*省略
%build
GCC=gcc
GXX=g++
%ifarch %{ix86}
BuildFlags="-march=%{_target_cpu} -mtune=generic -mno-tls-direct-seg-refs"
%endif
%ifarch i686
BuildFlags="-march=i686 -mtune=generic -mno-tls-direct-seg-refs"
%endif
%ifarch i386
BuildFlags="$BuildFlags -mno-tls-direct-seg-refs"
%endif
*省略
![]() |
Copyright(c) 528p.com All Rights Reserved. |

