mod_perl2.0.4のstaticビルドに失敗

今までyumで入るのをそのまま使うか、ビルドする時も.soにしてたんだけど、mod_perl専用で動かすならApacheに静的に組み込んでみようと思ってやってみました。うまく行かなかったんだけど、記録として。

このへんを見ながら、へこへこやるわけですが、mod_perl 2.0.4をApache 2.2.11に組み込んでビルドしようとしたらmakeでコケた。CentOS5.0(x86_64)とCentOS5.2(i386)で実行。

まず、

perl Makefile.PL MP_USE_STATIC=1 \
     MP_AP_PREFIX=$HOME/src/httpd-2.2.11 \
     MP_AP_CONFIGURE="--prefix=/var/sites/mod_perl2/httpd --enable-status --with-mpm=prefork

してmakeするとやたらめったらエラーが出る。どうもapr.hを読み込めていないのが原因っぽい。

/usr/include/apr-1/apr.h があって、C_INCLUDE_PATH に /usr/include が入ってるけど、それではダメらしい。/usr/include/apr-1 を C_INCLUDE_PATH に追加して再びmakeすると、

cd "src/modules/perl" && make
make[1]: ディレクトリ `/home/ryo/src/mod_perl-2.0.4/src/modules/perl' に入ります
gcc -I/home/ryo/src/mod_perl-2.0.4/src/modules/perl -I/home/ryo/src/mod_perl-2.0.4/xs -I/home/ryo/src/httpd-2.2.9/include -I/home/ryo/src/httpd-2.2.9/src
lib/apr/include -I/home/ryo/src/httpd-2.2.9/srclib/apr-util/include -I/home/ryo/src/httpd-2.2.9/os/unix -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -
pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm -I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE -DMOD_PERL -DMP_COMPAT_1X
 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwin
d-tables -c mod_perl.c
In file included from /home/ryo/src/httpd-2.2.9/srclib/apr/include/apr_file_io.h:29,
                 from /home/ryo/src/httpd-2.2.9/srclib/apr/include/apr_network_io.h:26,
                 from /home/ryo/src/httpd-2.2.9/include/httpd.h:53,
                 from modperl_apache_includes.h:27,
                 from mod_perl.h:20,
                 from mod_perl.c:17:
/home/ryo/src/httpd-2.2.9/srclib/apr/include/apr_file_info.h:192: error: expected specifier-qualifier-list before ‘apr_ino_t’
In file included from /home/ryo/src/httpd-2.2.9/srclib/apr/include/apr_file_io.h:34,
                 from /home/ryo/src/httpd-2.2.9/srclib/apr/include/apr_network_io.h:26,
                 from /home/ryo/src/httpd-2.2.9/include/httpd.h:53,
                 from modperl_apache_includes.h:27,
                 from mod_perl.h:20,
                 from mod_perl.c:17:
/home/ryo/src/httpd-2.2.9/srclib/apr/include/apr_want.h:93: error: redefinition of ‘struct iovec’
make[1]: *** [mod_perl.o] エラー 1
make[1]: ディレクトリ `/home/ryo/src/mod_perl-2.0.4/src/modules/perl' から出ます
make: *** [modperl_lib] エラー 2

とかいって止まる。出てるエラーは2つ。

/home/ryo/src/httpd-2.2.9/srclib/apr/include/apr_file_info.h:192: error: expected specifier-qualifier-list before ‘apr_ino_t’
/home/ryo/src/httpd-2.2.9/srclib/apr/include/apr_want.h:93: error: redefinition of ‘struct iovec’

このうち後者は、ApacheのFAQに出てた。1.3のドキュメントだけど。

3. Why do I get complaints about redefinition of "struct iovec" when compiling under Linux?

This is a conflict between your C library includes and your kernel includes. You need to make sure that the versions of both are matched properly. There
are two workarounds, either one will solve the problem:

* Remove the definition of struct iovec from your C library includes. It is located in /usr/include/sys/uio.h. Or,
* Add -DNO_WRITEV to the EXTRA_CFLAGS line in your Configuration and reconfigure/rebuild. This hurts performance and should only be used as a last resort.

ということらしい。手元の環境では /usr/include/bits/uio.h で iovec が定義されていたので、試しにこれをコメントアウトしたところ、このエラーは出なくなった。

ただ、前者が分からん。ググってもほとんど情報出てこないし、そもそもこのレイヤーの問題は自分の手に余る。

なお、APRyumでこういう状態。

apr.i386                                 1.2.7-11               installed
apr.x86_64                               1.2.7-11               installed
apr-devel.i386                           1.2.7-11               installed
apr-devel.x86_64                         1.2.7-11               installed
apr-util.x86_64                          1.2.7-7.el5            installed
apr-util.i386                            1.2.7-7.el5            installed
apr-util-devel.i386                      1.2.7-7.el5            installed
apr-util-devel.x86_64                    1.2.7-7.el5            installed

最初はx86_64しか入ってないのがあったりしたけど、最終的に全部入れてテストした。

あんまり時間かけてられないから、あきらめて.soを作って動的に組み込むことで逃げました。一度検証用にまっさらなサーバ立てて実験してみないと。あと、根本的にApacheに対する基礎知識がまるっきり欠けてるのが問題。