LoginSignup
0
1

More than 5 years have passed since last update.

Solaris10上のRuby 2.0.0(というか、OpenCSWのgcc-4.8.0)でmsgpackがインストールに失敗する件

Posted at

2.x系は、CFLAGSに-ansi -std=iso9899:199409が入るようになり、Rubyのコンパイルは成功するものの、inlineや//コメントを使っている拡張ライブラリがコンパイルできない問題があるようです。

これによりgemを使ったmsgpackyajl-rubyのインストール時にコンパイルが失敗し、fluentdのインストールができません。

※この記事は d.hatena.ne.jp/fujisan3776 から持ってきています

OpenCSWで必要なパッケージをインストールする

pkgutilのインストール方法は割愛 (http://www.opencsw.org/manual/for-administrators/getting-started.html を見てください)

# pkgutil -i -y gcc4g++ bison libreadline_dev libssl_dev libncurses_dev libgdbm_dev pkgconfig sudo

※たぶんこれで足りると思う

Ruby 2.0.0 or higher install via rbenv

論よりコード

$ curl 'http://pastebin.com/raw.php?i=saYYa8X6' > configure.in-cflags.patch
$ CONFIGURE_OPTS="--with-opt-dir=/opt/csw" rbenv install -p 2.0.0-p353 < configure.in-cflags.patch

※ pastebin.comに上がっているdiffは、私がuploadしたファイルです

環境について

Solaris10のgccは以下の通り

$ which gcc
/opt/csw/bin/gcc
$ gcc -v
Reading specs from /opt/csw/lib/gcc/i386-pc-solaris2.10/4.8.0/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/csw/libexec/gcc/i386-pc-solaris2.10/4.8.0/lto-wrapper
Target: i386-pc-solaris2.10
Configured with: /home/maciej/src/opencsw/pkg/gcc4/trunk/work/solaris10-i386/build-isa-pentium_pro/gcc-4.8.0/configure --prefix=/opt/csw --exec_prefix=/opt/csw --bindir=/opt/csw/bin --sbindir=/opt/csw/sbin --libexecdir=/opt/csw/libexec --datadir=/opt/csw/share --sysconfdir=/etc/opt/csw --sharedstatedir=/opt/csw/share --localstatedir=/var/opt/csw --libdir=/opt/csw/lib --infodir=/opt/csw/share/info --includedir=/opt/csw/include --mandir=/opt/csw/share/man --enable-cloog-backend=isl --enable-java-awt=xlib --enable-languages=ada,c,c++,fortran,go,java,objc --enable-libada --enable-libssp --enable-nls --enable-objc-gc --enable-threads=posix --program-suffix=-4.8 --with-cloog=/opt/csw --with-gmp=/opt/csw --with-included-gettext --with-ld=/usr/ccs/bin/ld --without-gnu-ld --with-libiconv-prefix=/opt/csw --with-mpfr=/opt/csw --with-ppl=/opt/csw --with-system-zlib=/opt/csw --with-gnu-as --with-as=/opt/csw/bin/gas
Thread model: posix
gcc version 4.8.0 (GCC) 

gem install msgpack エラーメッセージ

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /export/home/ma2shita/.rbenv/versions/2.0.0-p353/bin/ruby extconf.rb
checking for ruby/st.h... yes
checking for st.h... yes
checking for rb_str_replace() in ruby.h... yes
creating Makefile

make "DESTDIR="
compiling core_ext.c
In file included from /opt/csw/lib/gcc/i386-pc-solaris2.10/4.8.0/include-fixed/math.h:27:0,
                 from /export/home/ma2shita/.rbenv/versions/2.0.0-p353/include/ruby-2.0.0/ruby/missing.h:23,
                 from /export/home/ma2shita/.rbenv/versions/2.0.0-p353/include/ruby-2.0.0/ruby/ruby.h:1567,
                 from /export/home/ma2shita/.rbenv/versions/2.0.0-p353/include/ruby-2.0.0/ruby.h:33,
                 from compat.h:21,
                 from core_ext.h:21,
                 from core_ext.c:19:
/export/home/ma2shita/.rbenv/versions/2.0.0-p353/include/ruby-2.0.0/ruby/missing.h:212:17: error: expected identifier or '(' before '__extension__'
 RUBY_EXTERN int signbit(double x);
                     ^
/export/home/ma2shita/.rbenv/versions/2.0.0-p353/include/ruby-2.0.0/ruby/missing.h:212:17: error: expected identifier or '(' before ')' token
 RUBY_EXTERN int signbit(double x);
                     ^
make: *** [core_ext.o] Error 1


Gem files will remain installed in /export/home/ma2shita/app/vendor/bundle/ruby/2.0.0/gems/msgpack-0.5.8 for inspection.
Results logged to /export/home/ma2shita/app/vendor/bundle/ruby/2.0.0/gems/msgpack-0.5.8/ext/msgpack/gem_make.out

configure.in-cflags.patch について

使い方

  • rbenv installの場合 => rbenv install -p 2.0.0-p353 < configure.in-cflags.patch
  • tarballの場合 => patch -p0 < configure.in-cflags.patch ; autoconf ; ./configure ; make

概要

configure.in-cflags.patch は、Solaris上でコンパイルする際のCFLAGSを-std=gnu90にするパッチです。

(ただし、本問題がSolaris10+OpenCSW gcc(4.8.0)の固有の問題か否か調査不足のため不明)

--- configure.in.orig   2014-01-25 18:01:50.492004734 +0900
+++ configure.in    2014-01-25 18:32:17.810251545 +0900
@@ -725,6 +725,12 @@
       # with ANSI standard flags. Anonumous union is required to compile
       # socket extension where <net/if.h> uses anonymous union.
     ],
+    [solaris*], [
+      RUBY_TRY_CFLAGS(-std=gnu90, [
+        RUBY_APPEND_OPTION(warnflags, -std=gnu90)
+        RUBY_APPEND_OPTION(strict_warnflags, -std=gnu90)
+      ])
+    ],
     [
       # ANSI (no XCFLAGS because this is C only)
       RUBY_TRY_CFLAGS(-ansi -std=iso9899:199409, [

あとがき

ちなみに rubyの make testも、msgpackの rake specも PASSしてますので、実用上については問題なさそうです。

しかしいろいろ難しい。こんな環境で使ってるんじゃねぇよ、って声が聞こえてきそうです。ごめんなさい^2

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1