Mac OS XでPlackインストール時に出るエラーの回避
Mac OS X(SnowLeopard)でcpanm Task::Plackすると、EVのインストールで止まってしまう、という状況に陥りました。
調べてみると、「Lion で Plack をインストールすると EV のテストでエラーがでる。 」この記事まんまの状況で、たしかにXcode4を入れる前は問題なくPlackをインストールできてました。
さて、対応策はというとpatchを当てるだけでいいらしいですが、初体験なので詳細に書き残します。
ソースコード入手
これは普通に。
mkdir /tmp/EV curl -L http://search.cpan.org/CPAN/authors/id/M/ML/MLEHMANN/EV-4.03.tar.gz -o /tpm/EV/EV-4.03.tar.gz tar xzvf /tpm/EV/EV-4.03.tar.gz cd /tpm/EV/EV-4.03
patch適用
EV.xsを調べてみると、http://llvm.org/bugs/show_bug.cgi?id=9891に書いてある行番号と食い違ってるので、vimで開いて直接修正した。diffは以下の通り。
kotaro@mac:/tmp/EV/EV-4.03-patch> diff -c EV.xs EV.xs.orig
*** EV.xs 2011-10-22 22:02:58.000000000 +0900 --- EV.xs.orig 2011-10-22 22:21:33.000000000 +0900 *************** *** 424,434 **** #endif }; ! /* To work around MacOS llvm-gcc bug: ! http://llvm.org/bugs/show_bug.cgi?id=9891 */ ! const void* civ_start = const_iv; ! for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > civ_start; ) ! //for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); stash_loop = gv_stashpv ("EV::Loop" , 1); --- 424,430 ---- #endif }; ! for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); stash_loop = gv_stashpv ("EV::Loop" , 1);
patch適用済EVのインストール
cpanmはローカルからインストールすることもできるので、この機能を使えばOK。
cd /tpm/EV/EV-4.03 cpanm -v .
Successfully installed EV-4.03
1 distribution installed
できた!!