bar_1

contents_map

2024年7月4日木曜日

Numo::GSL (numo-gsl)をgemインストールしようとするとincompatible function pointer typesでエラーで止まることの解法

gem install するときのオプション --with-cflags=... で解決できる.


環境

  • OS macOS Sonoma 14.5
  • clang Apple clang version 15.0.0 (clang-1500.3.9.4)
    • clang -v
  • Ruby ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22]
    • ruby -v
  • Command Line Tools version: 15.3.0.0.1.1708646388
    • pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

現象

gem install numo-gsl しようとすると エラーincompatible function pointer types で, ビルドが止まる:

../gen/tmpl/init_module.c:47:5: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]

分析

https://clang.llvm.org/docs/DiagnosticsReference.html

-Wincompatible-function-pointer-types

This diagnostic is an error by default, but the flag -Wno-incompatible-function-pointer-types can be used to disable the error.

https://www.dts-insight.co.jp/support/support_arm/?m=ARMFaqInfo&item=&id=1460

この動作は変更され、代わりにエラーをレポートするようになりました。
エラーをワーニングにダウングレードするには -Wno-error=incompatible-function-pointer-types を使用してコンパイルしてください。
エラーおよびワーニングを無効にするには -Wno-incompatible-function-pointer-types を使用してコンパイルしてください。

ただ -Wno-error=... を使っても状況は変わらず.

解法

👉オプションの指定方法が間違っていた. 正しくは

gem install numo-gsl -- --with-cflags="-Wno-incompatible-function-pointer-types"

--with-cflags= で指定するものであった.

ちなみに github にある最新のNumo::GSLを使いたい場合は

$ git clone https://github.com/ruby-numo/numo-gsl
$ rake build
$ gem install pkg/numo-gsl-*.gem -- --with-cflags="-Wno-incompatible-function-pointer-types"

とすればよい.

なんかビルド環境が変わるたびに毎度GSL周りでつまずくことが多いので, 書いておく.

0 件のコメント:

コメントを投稿

何かありましたら、どうぞ: