YAMAGUCHI::weblog

海水パンツとゴーグルで、巨万の富を築きました。カリブの怪物、フリーアルバイター瞳です。

Erlang R14Bのビルド

はじめに

こんにちは、エビオス飲んでますか?最近 id:kuenishi とか id:VoluntasSkypeチャットでErlangでヒャッハーしてる話を横目に見てて、さらに @shibukawa までもがProject EularをErlangで解きまくってるという状況で「俺もヒャッハーしたい!」と思ったのでした。

R14Bをインストール

執筆時はR14Bが最新だったのでインストールします。公式からtarball引っ張ってこようとおもったらメチャ重かったのでid:Voluntasのミラー使いましたよ。ありがとうございます!

    • 公式の
    • Vの兄貴のミラー

とりあえずINSTALL.mdに書いてある通りにビルドしてみる

$ export LANG=C
$ export PATH=/usr/bin:$PATH
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5659~1/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5659)
$ ./configure --prefix=/opt/erlang/R14B --enable-darwin-64bit --without-javac --enable-smp-support --enable-kernel-poll
$ make
$ make install

おし、これで準備ができたのでErlangでHTTP並列アクセスとかしてみようか!

追記

GCCのバージョンが違ってビルドに失敗

「よーし、パパビルドしちゃうぞ」って思ったらこけた

$ make
...
gcc: unrecognized option '-no-cpp-precomp'
cc1: error: unrecognized command line option "-mdynamic-no-pic"
make[2]: *** [obj/i386-apple-darwin10.4.0/opt/plain/hipe_mkliterals.o] Error 1
make[1]: *** [generate] Error 2
make: *** [depend] Error 2

あれ、おかしいなと思ったので見てみたらMacPortsでビルドしたgcc使ってたので、上のようにalias使って回避した。

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin10/4.5.0/lto-wrapper
Target: x86_64-apple-darwin10
Configured with: ../gcc-4.5.0/configure --prefix=/opt/local --build=x86_64-apple-darwin10 --enable-languages=c,c++,objc,obj-c++,fortran,java --libdir=/opt/local/lib/gcc45 --includedir=/opt/local/include/gcc45 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.5 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.5 --with-gxx-include-dir=/opt/local/include/gcc45/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --enable-stage1-checking --disable-multilib --enable-fully-dynamic-string
Thread model: posix
gcc version 4.5.0 (GCC)