はじめに
さくらのVPSを借りて make 祭りな今日この頃.
その一環として,perlbrew 経由ででインストールした 5.12.1 な Perl を mod_perl として組み込んでみたので,そのメモです.
環境
- OS
- CentOS release 5.5 (Final),64bit
- Apache
- 2.2.16
- mod_perl
- 2.0.4
- Perl
-
5.12.1
(perlbrew install perl-5.12.1
) - perlbrew
- 0.09
Apache は,次のような感じでインストールされているものとします.
% ./configure --prefix=$HOME/local/apache2 ... % make % make install |
mod_perlをmakeしてみる
% cd ~/src % wget http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz % tar zxvf mod_perl-2.0-current.tar.gz % mv mod_perl-2.0.4 mod_perl-2.0.4-5.12.1 % cd mod_perl-2.0.4-5.12.1 % perl Makefile.PL PREFIX=$HOME/local MP_AP_PREFIX=$HOME/local/apache2 |
続けて make します.
% make ... rm -f mod_perl.so cc -shared -O2 -L/usr/local/lib \ \ mod_perl.lo modperl_interp.lo modperl_tipool.lo modperl_log.lo modperl_config.lo modperl_cmd.lo modperl_options.lo modperl_callback.lo modperl_handler.lo modperl_gtop.lo modperl_util.lo modperl_io.lo modperl_io_apache.lo modperl_filter.lo modperl_bucket.lo modperl_mgv.lo modperl_pcw.lo modperl_global.lo modperl_env.lo modperl_cgi.lo modperl_perl.lo modperl_perl_global.lo modperl_perl_pp.lo modperl_sys.lo modperl_module.lo modperl_svptr_table.lo modperl_const.lo modperl_constants.lo modperl_apache_compat.lo modperl_error.lo modperl_debug.lo modperl_common_util.lo modperl_common_log.lo modperl_hooks.lo modperl_directives.lo modperl_flags.lo modperl_xsinit.lo modperl_exports.lo -Wl,-E -L/usr/local/lib -L/home/www/perl5/perlbrew/perls/perl-5.12.1/lib/5.12.1/x86_64-linux/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lc \ -o mod_perl.so /usr/bin/ld: /home/www/perl5/perlbrew/perls/perl-5.12.1/lib/5.12.1/x86_64-linux/CORE/libperl.a(gv.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /home/www/perl5/perlbrew/perls/perl-5.12.1/lib/5.12.1/x86_64-linux/CORE/libperl.a: could not read symbols: Bad value collect2: ld はステータス 1 で終了しました make[1]: *** [mod_perl.so] エラー 1 make[1]: ディレクトリ `/home/www/src/mod_perl-2.0.4-5.12.1/src/modules/perl' から出ます make: *** [modperl_lib] エラー 2 % |
失敗しましたよorz
先人の知恵を探してみる
エラーメッセージを基にググってみたところ,次のエントリにたどり着きました.
このエントリによると,
sh ./Configure -de -Accflags='-fPIC' -Dloclibpth="/usr/lib64"
CentOS5 64bit版でmod_perlのmakeでエラー – perl勉強メモ
と同じような感じで perlbrew にオプションを渡せるといいのだけれど,perlbrew だとそれができない(-A
オプションが渡せない)みたいです.(ので,ご自身でソースを書き換えて解決されています.)
perlbrew-0.10 を入れてみる
先のエントリでは,perlbrewのバージョンは 0.07,この時点で私の環境に入っているのが 0.09.
念のため,CPAN を見てみると,0.10 が出ているじゃありませんか!ということで,さっそくこれをインストールします.
perlbrew -h
してみると,
OPTIONS -h│ --help prints this help. -f│ --force Force installation of a perl. -n│ --notest Skip the test suite -q│ --quiet Log output to a log file rather than STDOUT. This is the default. The log file is saved in $ROOT/build.log -v│ --verbose Log output to STDOUT rather than a logfile. --as Install a given perl under an alias. perlbrew install perl-5.6.2 --as legacy-perl -D, -U, -A pass through switches to the perl Configure script.perlbrew -h
どうやら -A
オプションも渡せるようになっているみたいですね.
オプションを指定して Perl-5.12.1 を入れ直してみる
先のエントリのような感じでオプションを指定した上で,Perl-5.12.1 を入れ直してみます.
% perlbrew -v install perl-5.12.1 -A ccflags=-fPIC -D loclibpth=/usr/lib64 --- A: - ccflags=-fPIC D: - loclibpth=/usr/lib64 U: [] args: - install - perl-5.12.1 force: 0 quiet: 1 verbose: 1 Attempting to load conf from /home/www/perl5/perlbrew/Conf.pm ... |
(perlbrew-0.10 になってから,オプションの指定状況が表示されるようになったみたいです.)
「Configure」を見てみます.
% perl -MConfig -le 'print $Config{config_args}' -de -Dprefix=/home/www/perl5/perlbrew/perls/perl-5.12.1 -Dloclibpth=/usr/lib64 |
% perl -V ... Compiler: cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', ... |
うーん,ccflags
ってヤツに -fPIC
ってのが入っていないみたいですねぇ...案の定,このPerlでも,同じところで mod_perl の make に失敗してしまいました.
オプションを指定して Perl-5.12.1 を入れ直してみる 〜解決編〜
あまり考えなしに,-A
を -D
と置き換えて入れ直してみます.
% perlbrew -v install perl-5.12.1 -D ccflags=-fPIC -D loclibpth=/usr/lib64 --- A: [] D: - ccflags=-fPIC - loclibpth=/usr/lib64 U: [] args: - install - perl-5.12.1 force: 0 quiet: 1 verbose: 1 Attempting to load conf from /home/www/perl5/perlbrew/Conf.pm ... |
Configure はどうでしょう.
% perl -MConfig -le 'print $Config{config_args}' -de -Dprefix=/home/www/perl5/perlbrew/perls/perl-5.12.1 -Dccflags=-fPIC -Dloclibpth=/usr/lib64 |
% perl -V ... Compiler: cc='cc', ccflags ='-fPIC -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', ... |
あれ,今度は ccflags=fPIC
が入ってますね.mod_perl の make もできてしまいましたw
ちなみに...
% make test ... Test Summary Report ------------------- t/apache/util.t (Wstat: 0 Tests: 8 Failed: 4) Failed tests: 1-4 t/hooks/authen_basic.t (Wstat: 0 Tests: 4 Failed: 1) Failed test: 4 t/hooks/authz.t (Wstat: 0 Tests: 4 Failed: 1) Failed test: 4 t/modules/apache_status.t (Wstat: 0 Tests: 15 Failed: 2) Failed tests: 14-15 Files=238, Tests=2715, 111 wallclock secs ( 1.80 usr 0.73 sys + 79.50 cusr 11.24 csys = 93.27 CPU) Result: FAIL Failed 4/238 test programs. 8/2715 subtests failed. [warning] server localhost.localdomain:8529 shutdown [ error] error running tests (please examine t/logs/error_log) +--------------------------------------------------------+ | Please file a bug report: http://perl.apache.org/bugs/ | +--------------------------------------------------------+ make: *** [run_tests] エラー 1 |
テストはいくつか失敗してしまいましたが,まぁ実験なので,そのまま make install.
2010-09-06T14:15 追記
テスト
t/apache/util.t
における失敗個所は,時刻のフォーマットによるもののようです.ロケール設定を変更すればパスできますね.
% LANG=C make test ... Test Summary Report ------------------- t/hooks/authen_basic.t (Wstat: 0 Tests: 4 Failed: 1) Failed test: 4 t/hooks/authz.t (Wstat: 0 Tests: 4 Failed: 1) Failed test: 4 t/modules/apache_status.t (Wstat: 0 Tests: 15 Failed: 2) Failed tests: 14-15 Files=238, Tests=2715, 116 wallclock secs ( 1.86 usr 0.73 sys + 83.73 cusr 11.76 csys = 98.08 CPU) Result: FAIL Failed 3/238 test programs. 4/2715 subtests failed. [warning] server localhost.localdomain:8529 shutdown [ error] error running tests (please examine t/logs/error_log) +--------------------------------------------------------+ | Please file a bug report: http://perl.apache.org/bugs/ | +--------------------------------------------------------+ make: *** [run_tests] Error 1 |
まとめ
perlbrew な Perl で mod_perl を make するには,次の 2点に注意!ですかね.
- perlbrew は 0.10 にしておくとよさげ
-D ccflags=-fPIC
なオプションをつけた上で perlbrew install すべし
ちなみに,この -D ccflags=-fPIC
ってオプションには,どのような意味があるのでしょうか.さっぱりわからなかったりします ><
参考
make 時のエラーメッセージで検索したら,現状がドンピシャでした.
インストールされた Perl の「Configure」の見方について.
おわりに
以上,perlbrew 経由でインストールした Perl で mod_perl を make した際のメモでした.
今後は,この上でアプリがまともに動くかどうか,テストの失敗は影響ないのか,など見ていくことにします.
こちらもあわせてどうぞ
最近の閲覧数
- None Found