CentOS 6.7でV8をコンパイル(失敗-glibcバージョンが古い)

個人で契約しているVPS(OSはCentOS 6.7)でV8をコンパイルした時のメモ。

参考にした記事

# for depot_tools
export PATH=$PATH:~/repos/git/depot_tools

depot_toolsのfetchで取得してたv8のソースファイルのディレクトリに移動して、gclient sync。

make x86.release でエラー発生。インストールされているpythonが2.6であるため。python2.7というファイル名でpython 2.7をインストール済みであるが、depot_toolsのスクリプトが/usr/bin/pythonを呼び出そうとしているため。

pyenvインストール(pythonのバージョンを指定してインストール、利用可能にするもの)

gitでclonする

git clone https://github.com/yyuu/pyenv.git ~/.pyenv

pyenvへのPATHの設定

参考にした記事

~/.zshrcに設定

# for pyenv
export PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
eval "$(pyenv init -)"

指定バージョンのpythonをインストール

> pyenv install -l
> pyenv install 2.7.11
> pyenv install 3.5.1

(v8のソースファイルのディレクトリで)ディレクトリに対してpythonのバージョンを指定する(永久に)

> pyenv local 2.7.11
> pyenv rehash
> python --version
Python 2.7.11

virtualenvインストール(同一バージョンのpythonに対し、異なる環境をつくる。たとえばインストールするモジュールを変えるなど。)(今回は必要なかった)

git cloneする

git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv

~/.zshrcに設定

eval "$(pyenv virtualenv-init -)"

使用法

pyenv virtualenv [version] <virtualenv-name>
  • 2.7.11を使って、新しい環境をつくる。
pyenv virtualenv 2.7.11 newenv-2.7.11
  • 2.7.11と、その環境も使って(参照して)、新しい環境をつくる。ここでシステムは、pyenvでインストールしたpythonを指す。
pyenv virtualenv --system-site-packages 2.7.11 co-2.7.11
  • 環境newenv-2.7.11を使って、新しい環境(co-newenv-2.7.11)をつくる。
pyenv virtualenv --system-site-packages newenv-2.7.11 co-newenv-2.7.11
  • ある環境のモジュールの情報を書き出す
pip freeze> pip_list.txt
  • 書き出した情報をもとにインストールする
pip install -r pip_list.txt
  • virtualenv環境の保存=必要なものをインストール
pyenv exec pip install wheel
  • wheelを使ってpipでインストールしたモジュールの情報を保存
pyenv exec pip freeze > pip_list.txt
pyenv exec pip --wheel-dir=~/tmp/wheelhouse -r pip_list.txt
  • 新しい環境で、wheelで同じものをインストール
pyenv virtualenv 2.7.11 test-2.7.11
pyenv global test-2.7.11
pip install -r pip_list.txt --use--wheel --no-index --find-links=~/tmp/wheelhouse
pip freeze

python2.6用gypのアンインストール

sudo yum remove gyp

コンパイル

 make native library=shared -j8
  • エラー発生
PYTHONPATH="/home/kominami/repos/git/v8-repo2/v8/tools/generate_shim_headers:/home/kominami/repos/git/v8-repo2/v8/build::/home/kominami/repos/git/v8-repo2/v8/tools/gyp/pylib:" \
        GYP_GENERATORS=make \
        tools/gyp/gyp --generator-output="out" gypfiles/all.gyp \
                      -Igypfiles/standalone.gypi --depth=. -S.native  -Dcomponent=shared_library -Dv8_enable_backtrace=1 -Darm_fpu=default -Darm_float_abi=default
gyp: Error importing pymod_do_mainmodule (detect_v8_host_arch): No module named detect_v8_host_arch
cd build
ln -s detect_host_arch.py detect_v8_host_arch.py
  • エラー発生
PYTHONPATH="/home/kominami/repos/git/v8-repo2/v8/tools/generate_shim_headers:/home/kominami/repos/git/v8-repo2/v8/build::/home/kominami/repos/git/v8-repo2/v8/tools/gyp/pylib:" \
        GYP_GENERATORS=make \
        tools/gyp/gyp --generator-output="out" gypfiles/all.gyp \
                      -Igypfiles/standalone.gypi --depth=. -S.native  -Dcomponent=shared_library -Dv8_enable_backtrace=1 -Darm_fpu=default -Darm_float_abi=default
gyp: Error importing pymod_do_mainmodule (has_valgrind): No module named has_valgrind
cd build
ln -s ../gypfiles/has_valgrind.py .
  • エラー発生
PYTHONPATH="/home/kominami/repos/git/v8-repo2/v8/tools/generate_shim_headers:/home/kominami/repos/git/v8-repo2/v8/build::/home/kominami/repos/git/v8-repo2/v8/tools/gyp/pylib:" \
        GYP_GENERATORS=make \
        tools/gyp/gyp --generator-output="out" gypfiles/all.gyp \
                      -Igypfiles/standalone.gypi --depth=. -S.native  -Dcomponent=shared_library -Dv8_enable_backtrace=1 -Darm_fpu=default -Darm_float_abi=default
make[1]: Entering directory `/home/kominami/repos/git/v8-repo2/v8/out'
  CC(target) /home/kominami/repos/git/v8-repo2/v8/out/native/obj.target/icudata/third_party/icu/linux/icudtl_dat.o
  ACTION src_v8_gyp_js2c_target_js2c /home/kominami/repos/git/v8-repo2/v8/out/native/obj/gen/libraries.cc
  ACTION src_v8_gyp_js2c_target_js2c_bin /home/kominami/repos/git/v8-repo2/v8/out/native/obj/gen/libraries.bin
  ACTION src_v8_gyp_js2c_target_js2c_experimental /home/kominami/repos/git/v8-repo2/v8/out/native/obj/gen/experimental-libraries.cc
  ACTION src_v8_gyp_js2c_target_js2c_experimental_bin /home/kominami/repos/git/v8-repo2/v8/out/native/obj/gen/libraries-experimental.bin
  ACTION src_v8_gyp_js2c_target_js2c_extras /home/kominami/repos/git/v8-repo2/v8/out/native/obj/gen/extras-libraries.cc
  ACTION src_v8_gyp_js2c_target_js2c_extras_bin /home/kominami/repos/git/v8-repo2/v8/out/native/obj/gen/libraries-extras.bin
  ACTION src_v8_gyp_js2c_target_js2c_experimental_extras /home/kominami/repos/git/v8-repo2/v8/out/native/obj/gen/experimental-extras-libraries.cc
/home/kominami/repos/git/v8-repo2/v8/third_party/llvm-build/Release+Asserts/bin/clang: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by /home/kominami/repos/git/v8-repo2/v8/third_party/llvm-build/Release+Asserts/bin/clang)
/home/kominami/repos/git/v8-repo2/v8/third_party/llvm-build/Release+Asserts/bin/clang: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/kominami/repos/git/v8-repo2/v8/third_party/llvm-build/Release+Asserts/bin/clang)
/home/kominami/repos/git/v8-repo2/v8/third_party/llvm-build/Release+Asserts/bin/clang: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/kominami/repos/git/v8-repo2/v8/third_party/llvm-build/Release+Asserts/bin/../lib/libstdc++.so.6)
make[1]: *** [/home/kominami/repos/git/v8-repo2/v8/out/native/obj.target/icudata/third_party/icu/linux/icudtl_dat.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/home/kominami/repos/git/v8-repo2/v8/out'
make: *** [native] Error 2