きりかノート 3冊め

おあそびプログラミング

MacPortsのport:ruby23を登録

例によってクリスマスに新しいバージョンがリリースされていたので対応しました。従来通り、MacPorts版は

  • ruby2.3, rake2.3, gem2.3などバージョンのsuffixがつく
  • port select ruby ruby23などselectを使うと、suffixなしのバージョンで使える

となっています。

Yosemite環境でのコンパイルエラー調査

portへのコミットはわりとすぐやってたんだけど、OS X 10.10 Yosemite環境のbuildbotがエラーはいてて、手元で再現できなかったりと調べてるうちに年が明けてしまった。。

buildbotのエラー

エラー箇所の抜粋。

   compiling regerror.c
   compiling regexec.c
   Stack dump:
   0.	Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -cc1 -triple x86_64-apple-macosx10.10.0 -emit-obj -disable-free -disable-llvm-verifier -main-file-name regexec.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 242.2 -dwarf-column-info -coverage-file /opt/local/var/macports/build/_opt_mports_dports_lang_ruby23/ruby23/work/ruby-2.3.0/regexec.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0 -D _FORTIFY_SOURCE=2 -D RUBY_EXPORT -D _XOPEN_SOURCE -D _DARWIN_C_SOURCE -D _DARWIN_UNLIMITED_SELECT -D _REENTRANT -I /opt/local/include -I /opt/local/include -I . -I .ext/include/x86_64-darwin14 -I ./include -I . -I/opt/local/include -Os -fdebug-compilation-dir /opt/local/var/macports/build/_opt_mports_dports_lang_ruby23/ruby23/work/ruby-2.3.0 -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -fwrapv -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fmax-type-align=16 -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o regexec.o -x c regexec.c
   1.	<eof> parser at end of file
   2.	Per-module optimization passes
   3.	Running pass 'CallGraph Pass Manager' on module 'regexec.c'.
   4.	Running pass 'Loop Pass Manager' on function '@match_at'
   5.	Running pass 'Loop Invariant Code Motion' on basic block '%4037'
   clang: error: unable to execute command: Segmentation fault: 11
   clang: error: clang frontend command failed due to signal (use -v to see invocation)
   Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
   Target: x86_64-apple-darwin14.5.0
   Thread model: posix
   clang: note: diagnostic msg: PLEASE submit a bug report to http://developer.apple.com/bugreporter/ and include the crash backtrace, preprocessed source, and associated run script.
   clang: note: diagnostic msg:

regexec.cのコンパイルでエラーでて失敗してる。あんま見たことないケースだなあ。手元の環境で確認したときは問題なかったし、rubyciもgreenだし。

あれこれ試して、以下の場合で再現することがわかった。

  • Xcode 6.4 (自分は7.0で確認してた)
  • コンパイラの最適化フラグが "-Os" (MacPortsのデフォルト値。前は-O3だったような…?)

のときがアウトっぽい。なんかすごくコンパイラのバグっぽいのですけど。。。

とりあえずPortfileで上記に該当する場合は、最適化フラグを-Osから-O3に書き換えすることで対応することにした。