ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
From: ngotogenome@gmail•com
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:50679] [Ruby trunk Bug#14200] addr2line.c compile error with C89 compilers on Solaris 10
Date: Thu, 29 Nov 2018 15:12:53 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-75288.20181129151252.b229031807edb8aa@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-14200.20171218154035@ruby-lang.org

Issue #14200 has been updated by ngoto (Naohisa Goto).


> Soraris 11や10、あるいは9以前に関してそれぞれについて具体的にどのような懸念や副作用があるか

Solaris 9 およびそれ以前はもう考慮する必要はないと思います。

Solaris 10/11 の公式コンパイラである Oracle Developer Studio (旧名称 Oracle Solaris Studio、旧旧名称 Sun Studio)では、遅くともバージョン12以降ではC99をサポートしています。

デフォルトは、12.3 以前は `-xc99=all,no_lib` (標準ライブラリはC90以前のまま、それ以外はC99準拠)。12.4 以降では、C11をサポートした影響で、デフォルトが `-std=c11` (C11準拠)と前述の `-xc99=all,no_lib` がその他のオプションの付与状況により選ばれる状況のようです。

Fujitsu C Compiler (fcc) では、私が使っていたバージョン5.6ではデフォルトC90で、`c99` という別コマンドを使うとC99が使えますが、製品自体が2016年3月に販売終了していますし、あまり考えなくてよいとは思います。

`_XOPEN_SOURCE` については、既に、Rubyの ./configure で最適なものを付与するようにしたつもりです。私の手元の環境では、Oracle Solaris Studio 12.4 では `-D_XOPEN_SOURCE=500` が、Oracle Developer Studio 12.5 以降では `-D_XOPEN_SOURCE=600` が./configureにより付与されています。

`-D_XOPEN_SOURCE=600` (SUSv3)では C99 が必須、`-D_XOPEN_SOURCE=500` (SUSv2) では C90 が必須だったと記憶しています。

問題が生じる可能性があるとすれば、Ruby本体またはユーザーがインストールした拡張ライブラリ等が使っているCのヘッダファイルの内部で `_XOPEN_SOURCE` をdefineしていたり、特定の値を想定している場合でしょうか?標準ヘッダを正しく使う限りは問題は発生しないはずですが、利用者が追加でインストールしたライブラリ等ではあり得るかもしれません。

とはいえ、真っ当に書かれたコードなら、本来、問題は発生しないはずです。つまり、問題が発生する環境の方がおかしいと言えるとは思います。

----------------------------------------
Bug #14200: addr2line.c compile error with C89 compilers on Solaris 10
https://bugs.ruby-lang.org/issues/14200#change-75288

* Author: ngoto (Naohisa Goto)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
r60841 にて、 addr2line.c では stdbool.h を使用するようになりましたが、
stdbool.h は C99 にて追加された仕様のため、
デフォルトが C89 になっている Solaris 10 上の古めのコンパイラの多くでは、
Solarisの標準ヘッダファイルに含まれるC標準バージョンチェックを通過できず、
以下のようなエラーになり、コンパイルに失敗します。

~~~
cc -errtags=yes  -xO4 -xtarget=sparc64xplus -m64 -DRUBY_DEVEL=1 -DRUBY_EXPORT -I/usr/local/64/lib/libffi-3.0.10/include -I/usr/local/64/include  -D_XOPEN_SOURCE=500   -I. -I.ext/include/sparc64-solaris2.10 -I./include -I. -I./enc/unicode/10.0.0 -o addr2line.o -c addr2line.c
"/usr/include/stdbool.h", line 42: #error: "Use of <stdbool.h> is valid only in a c99 compilation environment."
cc: acomp failed for addr2line.c
make: *** [addr2line.o] Error 2
~~~

これは Solaris 10 上の Oracle Solaris Studio 12.4 でのエラーです。
他に、古い gcc や Fujitsu C Compiler などでも同様のエラーとなります。

なお、Solaris10上の多少古めのコンパイラでも、C99は概ねサポートしており、
オプションでC99準拠を指定したり、それ相当の _XOPEN_SOURCE を定義すると、
コンパイルは通るはずではありますが、それに伴う副作用もあるので、
現時点では、容易に可能なら、それを指定しなくても通るようにしたいと思っています。




-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2018-11-29 15:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-14200.20171218154035@ruby-lang.org>
2017-12-18 15:40 ` [ruby-dev:50366] [Ruby trunk Bug#14200] addr2line.c compile error with C89 compilers on Solaris 10 ngotogenome
2018-11-28 12:36 ` [ruby-dev:50678] " takashikkbn
2018-11-29 15:12 ` ngotogenome [this message]
2018-11-29 15:50 ` [ruby-dev:50680] " ngotogenome
2018-11-29 15:58 ` [ruby-dev:50681] " takashikkbn
2019-01-06 13:38 ` [ruby-dev:50744] " takashikkbn
2019-01-06 14:17 ` [ruby-dev:50745] " takashikkbn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-75288.20181129151252.b229031807edb8aa@ruby-lang.org \
    --to=ruby-dev@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).