Bug #9658

configure --with-opt-dir=dir と clang の組合せでビルドに失敗する

Added by Akinori MUSHA about 1 year ago. Updated 12 months ago.

[ruby-dev:48062]
Status:Closed
Priority:Normal
Assignee:Akinori MUSHA
ruby -v:2.1.0 and later Backport:2.0.0: UNKNOWN, 2.1: DONE

Description

ruby 2.1以降で configure に --with-opt-dir=/opt/local を指定すると、

  • checking for printf prefix for long long... が、 clang の吐く clang: warning: argument unused during compilation: '-I /opt/local/include' のせいで失敗し、 config.h に PRI_LL_PREFIX の定義が入らない

  • compiling .../ext/-test-/num2int/num2int.c がこけてビルド失敗

という流れです。

パッチを添付します。

cf.
https://twitter.com/knu/status/421181635455766529
https://gist.github.com/knu/8330662
https://github.com/ruby/ruby/pull/571

571.patch Magnifier - https://github.com/ruby/ruby/pull/571 (2.65 KB) Akinori MUSHA, 03/20/2014 03:25 PM

Associated revisions

Revision 45378
Added by Akinori MUSHA about 1 year ago

Fix a build problem with clang and --with-opt-dir.

  • configure.in: Fix a build problem with clang and --with-opt-dir. If ruby is configured with --with-opt-dir=dir when using clang as compiler, a warning clang: warning: argument unused during compilation: '-I dir' is emitted almost every time clang compiles a file. Unfortunately, RUBY_CHECK_PRINTF_PREFIX takes any output from the compiler as fatal error, and the check thus fails due to the warning. This is an attempt to fix the problem by adding a flag -Qunused-arguments to CFLAGS locally in the function to suppress the warning. [Bug #9658] [Fixes GH-571] https://github.com/ruby/ruby/pull/571

Revision 45378
Added by Akinori MUSHA about 1 year ago

Fix a build problem with clang and --with-opt-dir.

  • configure.in: Fix a build problem with clang and --with-opt-dir. If ruby is configured with --with-opt-dir=dir when using clang as compiler, a warning clang: warning: argument unused during compilation: '-I dir' is emitted almost every time clang compiles a file. Unfortunately, RUBY_CHECK_PRINTF_PREFIX takes any output from the compiler as fatal error, and the check thus fails due to the warning. This is an attempt to fix the problem by adding a flag -Qunused-arguments to CFLAGS locally in the function to suppress the warning. [Bug #9658] [Fixes GH-571] https://github.com/ruby/ruby/pull/571

Revision 46402
Added by Tomoyuki Chikanaga 12 months ago

merge revision(s) r45378: [Backport #9658] [Backport #9866]

* configure.in: Fix a build problem with clang and --with-opt-dir.
  If ruby is configured with --with-opt-dir=dir when using clang
  as compiler, a warning `clang: warning: argument unused during
  compilation: '-I dir'` is emitted almost every time clang
  compiles a file.  Unfortunately, RUBY_CHECK_PRINTF_PREFIX takes
  any output from the compiler as fatal error, and the check thus
  fails due to the warning.  This is an attempt to fix the problem
  by adding a flag -Qunused-arguments to CFLAGS locally in the
  function to suppress the warning.  [Bug #9658]
  [Fixes GH-571] https://github.com/ruby/ruby/pull/571

History

#1 Updated by Nobuyoshi Nakada about 1 year ago

  • Status changed from Open to Assigned
  • Assignee changed from Nobuyoshi Nakada to Akinori MUSHA

いいんじゃないでしょうか。
しかし、その警告は本当にただの余計なお世話ですよねぇ。

#2 Updated by Akinori MUSHA about 1 year ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Applied in changeset r45378.


Fix a build problem with clang and --with-opt-dir.

  • configure.in: Fix a build problem with clang and --with-opt-dir. If ruby is configured with --with-opt-dir=dir when using clang as compiler, a warning clang: warning: argument unused during compilation: '-I dir' is emitted almost every time clang compiles a file. Unfortunately, RUBY_CHECK_PRINTF_PREFIX takes any output from the compiler as fatal error, and the check thus fails due to the warning. This is an attempt to fix the problem by adding a flag -Qunused-arguments to CFLAGS locally in the function to suppress the warning. [Bug #9658] [Fixes GH-571] https://github.com/ruby/ruby/pull/571

#3 Updated by Akinori MUSHA about 1 year ago

Nobuyoshi Nakada wrote:

いいんじゃないでしょうか。

trunkに入れました。2.1にもそのまま当たり、同じように直ると思います。

しかし、その警告は本当にただの余計なお世話ですよねぇ。

  • コンパイラのフラグはソースファイル群に対してまとめて指定する
  • -Idirの先のヘッダファイルをincludeするかどうかは個々のソースファイル次第

なので、目障りなケースが多いのは事実ですね。
-Iについてだけ警告を抑制できるようなきめ細かい指定があればいいのですが。

#4 Updated by Tomoyuki Chikanaga 12 months ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: REQUIRED to 2.0.0: UNKNOWN, 2.1: DONE

Backported into ruby_2_1 branch at r46402.

Also available in: Atom PDF