🤩

Erlang/OTP ソースコードインストールのススメ

2020/11/23に公開

この資料は定期的に更新される

概要

Erlang/OTP を GitHub にあるソースコードからビルドして利用する方法についてまとめている。

前提

  • 株式会社時雨堂 の商用製品向けのビルド設定
  • パッケージングに利用する Erlang/OTP は OpenSSL を dynamic link しない
  • OpenSSL 最新版を自前ビルドする
  • 利用していないモジュールはビルドしない
  • GitHub から clone してきてビルドする

Linux

古いカーネルは利用しないほうがいい

  • Ubuntu 24.04 x86_64 | arm64
    • apt install build-essential libncurses5-dev autoconf
  • Ubuntu 22.04 x86_64 | arm64
    • apt install build-essential libncurses5-dev autoconf
  • Ubuntu 20.04 x86_64 | arm64
    • apt install build-essential libncurses5-dev autoconf
  • Red Hat Enterprise Linux 9 x86_64
    • dnf install autoconf gcc glibc-devel make ncurses-devel perl
  • Red Hat Enterprise Linux 8 x86_64
    • dnf install autoconf gcc glibc-devel make ncurses-devel perl
    • RHEL8 で JIT 版をビルドするには GCC Toolset 11 Toolchain が必要になる。

OpenSSL

curl -LO https://www.openssl.org/source/openssl-3.3.1.tar.gz
tar xvfz openssl-3.3.1.tar.gz
cd openssl-3.3.1
./Configure --prefix=/opt/openssl/3.3.1 no-shared no-module
make -j
make install_sw

Erlang/OTP

git clone した otp は pull 専用にしてビルドするのは別リポジトリにする

git clone https://github.com/erlang/otp
git clone otp otp-27.0 -b OTP-27.0
cd otp-27.0
./configure --prefix=/opt/erlang/27.0 \
            --enable-kernel-poll \
            --enable-dirty-schedulers \
            --enable-jit \
            --disable-sctp \
            --disable-dynamic-ssl-lib \
            --disable-sharing-preserving \
            --with-ssl=/opt/openssl/3.3.1 \
            --without-javac \
            --without-odbc \
            --without-wx \
            --without-debugger \
            --without-observer \
            --without-crashdump_viewer \
            --without-et \
            --without-tftp \
            --without-ftp \
            --without-megaco \
            --without-eldap \
            --without-diameter \
            --without-jinterface \
            --without-mnesia \
            --without-snmp \
            --without-erl_docgen \
            --without-edoc \
            --without-xmerl \
            --without-ssh
make -j
make install

開発環境用 Erlang/OTP

  • Erlang/OTP 最新版を積極的に利用
  • OpenSSL 開発版を積極的に利用
  • microstate-accounting を有効化
curl -LO https://www.openssl.org/source/openssl-3.3.1.tar.gz
tar xvfz openssl-3.3.1.tar.gz
cd openssl-3.3.1
./Configure --prefix=/opt/openssl/3.3.1 no-shared no-module
make -j
make install_sw
git clone https://github.com/erlang/otp
git clone otp otp-27.0 -b OTP-27.0
cd otp-27.0
./configure --prefix=/opt/erlang/27.0 \
            --enable-kernel-poll \
            --enable-dirty-schedulers \
            --enable-jit \
            --disable-sctp \
            --disable-dynamic-ssl-lib \
            --disable-sharing-preserving \
            --with-ssl=/opt/openssl/3.3.1 \
            --with-microstate-accounting=extra \
            --without-javac \
            --without-odbc \
            --without-wx \
            --without-debugger \
            --without-observer \
            --without-crashdump_viewer \
            --without-et \
            --without-tftp \
            --without-ftp \
            --without-megaco \
            --without-eldap \
            --without-diameter \
            --without-jinterface \
            --without-mnesia \
            --without-snmp \
            --without-erl_docgen \
            --without-edoc \
            --without-xmerl \
            --without-ssh
make -j
make install

maybe 構文

  • rebar の設定に maybe_expr 利用する設定を入れる
  • Erlang/OTP 27.0 からは rebar の設定は不要

rebar.config

{erl_opts, [{feature, maybe_expr, enable}]}.

docker images

https://hub.docker.com/r/shiguredo/erlang/tags

Discussion