From: "NARUSE, Yui" Date: 2010-01-05T23:34:45+09:00 Subject: [ruby-dev:39972] Re: Fedora12上でrubyがビルドできません 既出です。 http://redmine.ruby-lang.org/issues/show/2022 Evan Phoenix が openssl のメンテナになってくれるので、 そのうち取り込んでくれると思うんですが、 ssh 鍵を送る際の GPG を入れるあたりで止まっているので、 彼に応援のメッセージをかけてあげてください http://redmine.ruby-lang.org/issues/show/2454 (2010/01/05 23:29), KOSAKI Motohiro wrote: > kosaki と申します。 > > 本日はじめてrubyのコンパイルをトライしてみた初心者なのですが、手元の環境(Fedora12 上でrubyのtrunkをビルド)ではビルドできないようです。 > 具体的に言うと、ext/opensslがコンパイルとおりません。以下のエラーが出ます。 > > gcc -I. -I../../.ext/include/x86_64-linux -I../.././include > -I../.././ext/openssl -DRUBY_EXTCONF_H=\"extconf.h\" -fPIC -O3 > -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith > -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o > ossl_ssl.o -c ossl_ssl.c > ossl_ssl.c:107: 警告: initialization from incompatible pointer type > ossl_ssl.c:108: 警告: initialization from incompatible pointer type > ossl_ssl.c:109: 警告: initialization from incompatible pointer type > ossl_ssl.c:110: 警告: initialization from incompatible pointer type > ossl_ssl.c:111: 警告: initialization from incompatible pointer type > ossl_ssl.c:112: 警告: initialization from incompatible pointer type > ossl_ssl.c:113: 警告: initialization from incompatible pointer type > ossl_ssl.c:114: 警告: initialization from incompatible pointer type > ossl_ssl.c:115: 警告: initialization from incompatible pointer type > ossl_ssl.c:116: 警告: initialization from incompatible pointer type > ossl_ssl.c:117: 警告: initialization from incompatible pointer type > ossl_ssl.c:118: 警告: initialization from incompatible pointer type > ossl_ssl.c: In function ‘ossl_sslctx_set_ssl_version’: > ossl_ssl.c:162: 警告: 符合付きと符合無しの整数式同士の比較です > ossl_ssl.c: In function ‘ossl_sslctx_initialize’: > ossl_ssl.c:193: 警告: 符合付きと符合無しの整数式同士の比較です > ossl_ssl.c: In function ‘ossl_sslctx_get_ciphers’: > ossl_ssl.c:703: error: ‘STACK’ undeclared (first use in this function) > ossl_ssl.c:703: error: (Each undeclared identifier is reported only once > ossl_ssl.c:703: error: for each function it appears in.) > ossl_ssl.c:703: error: expected expression before ‘)’ token > ossl_ssl.c:706: error: expected expression before ‘)’ token > ossl_ssl.c:706: error: too few arguments to function ‘sk_value’ > ossl_ssl.c: In function ‘ossl_ssl_get_peer_cert_chain’: > ossl_ssl.c:1406: 警告: passing argument 1 of ‘sk_num’ from incompatible > pointer type > /usr/include/openssl/stack.h:79: note: expected ‘const struct _STACK > *’ but argument is of type ‘struct stack_st_X509 *’ > ossl_ssl.c:1409: 警告: passing argument 1 of ‘sk_value’ from > incompatible pointer type > /usr/include/openssl/stack.h:80: note: expected ‘const struct _STACK > *’ but argument is of type ‘struct stack_st_X509 *’ > ossl_ssl.c: In function ‘ossl_ssl_get_cipher’: > ossl_ssl.c:1431: 警告: assignment discards qualifiers from pointer target type > ossl_ssl.c: In function ‘Init_ossl_ssl’: > ossl_ssl.c:1577: 警告: 符合付きと符合無しの整数式同士の比較です > ossl_ssl.c:1606: 警告: 符合付きと符合無しの整数式同士の比較です > ossl_ssl.c:1621: 警告: 符合付きと符合無しの整数式同士の比較です > ossl_ssl.c:1623: 警告: 符合付きと符合無しの整数式同士の比較です > make[1]: *** [ossl_ssl.o] エラー 1 > > > で、理由なんですが、Fedora12ではopensslが1.0.0-beta4 が収録されており、stack_st がrenameされてしまっているようです。 > > openssl-1.0.0-beta4のstack.h の定義 > > typedef struct stack_st > { > int num; > char **data; > int sorted; > > int num_alloc; > int (*comp)(const void *, const void *); > } _STACK; /* Use STACK_OF(...) instead */ > > openssl-0.9.8l (安定版、たぶんdebianとかが使っているのはこちら) > > typedef struct stack_st > { > int num; > char **data; > int sorted; > > int num_alloc; > int (*comp)(const char * const *, const char * const *); > } STACK; > > > 解決案として 4案考えました > 1)ruby側でSTACKの代わりに struct stack_stを使うよう置換してまわる > 2)ruby側を、ただしくSTACK_OFを使うよう置換して回る > 3)openssl 側に勝手にrenameすんなと文句をいう > 4)もういっそのことrubyのビルドはあきらめて、yuguiさんにはごめんという ;-) > > ためしに2)の方針で作ったパッチが添付のものです。 > > 2つ汚い点があります。 > > 1) ossl.h に > > +/* for compatible ssl-0.9.x */ > +#ifndef lh_CONF_VALUE_doall_arg > +#define lh_CONF_VALUE_doall_arg(lh,fn,arg_type,arg) lh_doall_arg(lh,fn,arg) > +#endif > > なんていう行を足してしまっている > > 2)ossl_x509attr.c が以下の警告を出す > > ossl_x509attr.c: In function ‘ossl_x509attr_get_value’: > ossl_x509attr.c:221: 警告: passing argument 1 of ‘i2d_ASN1_SET’ from > incompatible pointer type > /usr/include/openssl/asn1.h:894: note: expected ‘struct > stack_st_OPENSSL_BLOCK *’ but argument is of type ‘struct \ > _STACK *’ > ossl_x509attr.c:225: 警告: passing argument 1 of ‘i2d_ASN1_SET’ from > incompatible pointer type > /usr/include/openssl/asn1.h:894: note: expected ‘struct > stack_st_OPENSSL_BLOCK *’ but argument is of type ‘struct \ > _STACK *’ > > これは、openssl-1.0.0-beta4 の SKM_ASN1_SET_OF_i2d 定義が間違っていて > > #define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ > i2d_ASN1_SET(CHECKED_PTR_OF(STACK_OF(type), st), pp, \ > CHECKED_I2D_OF(type, i2d_func), \ > ex_tag, ex_class, is_set) > > としなければいけないのに、 > > #define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ > i2d_ASN1_SET(CHECKED_STACK_OF(type, st), pp, \ > CHECKED_I2D_OF(type, i2d_func), \ > ex_tag, ex_class, is_set) > > としてしまっているからで、ruby側では直しようがないと判断して放置してあります。 > 手元で openssl-0.9.8l と openssl-1.0.0-beta4 でコンパイルテストだけしてありますが、実テストは0です。 > (そもそもどうやって使うクラスなんだろう状態なので) > > 誰か詳しい人が降臨して、直してくれないかなぁ。とか思いつつパッチを投稿してみます。 > > > > ps 細かいことですが、trunkのビルドをするのに、--with-baseruby=RUBY オプションが必須という情報がどこにもドキュメントがない気がします > ps2 さらに細かいことですが、ビルド用の前提ソフト一覧(ruby, autoconf, > bisonを新規インストールする必要がありました)もあるとうれしいような気がします -- NARUSE, Yui