【Ruby】MacでRuby2.4.0をコンパイルしてみる
こんにちは、しきゆらです
今回は、(この記事を書いている時点での)Ruby最新バージョンである2.4.0をコンパイル&インストールしていきます
詳しい変更点などは、Rubyの公式サイトからどうぞ
いつも通り高速化とかがメインなのかしら
大きく変わりそうなところは「Unify Fixnum and Bignum into Integer」とか
「Introduce hash table improvement (by Vladimir Makarov)」あたりかしら
それではれっつこんぱいる!
DLやら解凍やらは省略
(最近は解凍って言わないとか聞いて震える)
コンパイルの手順もいつもどおり
コンパイルオプション確認
なお、普段からコンパイルしている場合
$ ruby -r rbconfig -e 'puts RbConfig::CONFIG["configure_args"]' '--prefix=/usr/local/Ruby' '--with-openssl-dir=/usr/local/opt/openssl'
とするとコンパイル時につけていたオプションを表示してくれます
とても便利ね
OpenSSLの設定
私の環境では、Macにデフォルトで入っているRubyとは別の場所にコンパイルしてあるのと
OpenSSLをbrewのものを使うようにしますよ
さて、まずはこんふぃぐれ
$ ./configure --prefix=/usr/local/Ruby --with-openssl-dir=/usr/local/opt/openssl
% あれやら
% これやら
---
Configuration summary for ruby version 2.4.0
   * Installation prefix: /usr/local/Ruby
   * exec prefix:         ${prefix}
   * arch:                x86_64-darwin16
   * site arch:           ${arch}
   * RUBY_BASE_NAME:      ruby
   * ruby lib prefix:     ${libdir}/${RUBY_BASE_NAME}
   * site libraries path: ${rubylibprefix}/${sitearch}
   * vendor path:         ${rubylibprefix}/vendor_ruby
   * target OS:           darwin16
   * compiler:            clang
   * with pthread:        yes
   * enable shared libs:  no
   * dynamic library ext: bundle
   * CFLAGS:              ${optflags} ${debugflags} ${warnflags}
   * LDFLAGS:             -L. -fstack-protector -L/usr/local/lib
   * optflags:            -O3 -fno-fast-math
   * debugflags:          -ggdb3
   * warnflags:           -Wall -Wextra -Wno-unused-parameter \
                          -Wno-parentheses -Wno-long-long \
                          -Wno-missing-field-initializers \
                          -Wno-tautological-compare \
                          -Wno-parentheses-equality \
                          -Wno-constant-logical-operand -Wno-self-assign \
                          -Wunused-variable -Wimplicit-int -Wpointer-arith \
                          -Wwrite-strings -Wdeclaration-after-statement \
                          -Wshorten-64-to-32 \
                          -Wimplicit-function-declaration \
                          -Wdivision-by-zero -Wdeprecated-declarations \
                          -Wextra-tokens
   * strip command:       strip -A -n
   * install doc:         yes
   * man page type:       doc
---いつのまにか、configureの実行の最後にこんなのが出るようになっていた
prefixの場所とか環境とか確認できるようになったのね
コンパイル & インストール
あとは、make & make install
$ make % あれこれ $ make install % ↑インストール位置などによってはsudoとか必要
普段通り
難しいことはない
Rubyのパスを通す
次に、コマンドを使えるようにパスを通します
私の環境では「/usr/local/Ruby」にインストールしていて
コンパイルしたものは「/usr/local/bin」にまとめている
そこで、「/usr/local/Ruby」から「/usr/local/bin」にシンボリックリンクを貼ります
$ ln -s /usr/local/Ruby/bin/ruby /usr/local/bin % その他、必要なもののリンクを貼る $ ruby -v ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
これでインストール完了ですよ
簡単ですね
ということで、さらっとこんぱいるして使えるようにしました
コンパイルオプションを確認できる方法とか覚えておくと便利ですね
今回はここまで
おわり


 にほんブログ村
にほんブログ村

ディスカッション
コメント一覧
まだ、コメントがありません