rb-gsl
rb-gsl copied to clipboard
Build failure with Clang 16 (`-Wincompatible-function-pointer-types`)
Clang 16 makes -Wincompatible-function-pointer-types an error by default.
rb-gsl hits the following failure when building with Clang 16:
[...]
blas2.c:1084:3: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
rb_define_module_function(module, "dsyr2!", rb_gsl_blas_dsyr2, 4);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/ruby-2.7.0/ruby/ruby.h:2827:135: note: expanded from macro 'rb_define_module_function'
#define rb_define_module_function(klass, mid, func, arity) rb_define_module_function_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
^~~~~~
/usr/include/ruby-2.7.0/ruby/ruby.h:2804:1: note: passing argument to parameter 'func' here
RB_METHOD_DEFINITION_DECL(rb_define_module_function, (2,3), (VALUE klass, const char *name), (klass, name))
^
/usr/include/ruby-2.7.0/ruby/intern.h:1077:89: note: expanded from macro 'RB_METHOD_DEFINITION_DECL'
RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##3 ,3 ,decl,vars,(VALUE,VALUE,VALUE,VALUE)) \
^
/usr/include/ruby-2.7.0/ruby/intern.h:1069:5: note: expanded from macro '\
RB_METHOD_DEFINITION_DECL_1'
RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,funcargs) \
^
/usr/include/ruby-2.7.0/ruby/intern.h:1042:118: note: expanded from macro 'RB_METHOD_DEFINITION_DECL_C'
__attribute__((__unused__,__weakref__(#def),__nonnull__ nonnull))static void defname(RB_UNWRAP_MACRO decl,VALUE(*func)funcargs,int arity);
^
To reproduce this bug:
- with Clang 16, just build normally
- with Clang 15, pass
-Werror=incompatible-function-pointer-types - with GCC, pass
-Werror=incompatible-pointer-types(GCC lacks a more specific warning)
Reported downstream in Gentoo at https://bugs.gentoo.org/895684.
In order to get this installed did you successfully suppress warnings on clang 16? or did you find another solution?
Currently I cannot progress as it will not let me install the gsl gem
Reported downstream in Gentoo at bugs.gentoo.org/895684.
It seems that bug was closed with this commit:
- https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=568b8a8843c91c5b82b92e7c6dd15352c1bf3412
But from a quick skim, I'm not 100% what the actual fix was, and/or how to apply it back up at this level of things.
Here are all the bugs that were listed as fixed by that commit:
- https://bugs.gentoo.org/574742
-
2016-02-16 19:35:50 UTC This an incompatibility with gsl 2.1. I've updated the gsl dependency to <gsl-2.1.
Cc gsl maintainers since they might want to track this and possibly consider slotting.
-
- https://bugs.gentoo.org/723924
- https://bugs.gentoo.org/828838
- https://bugs.gentoo.org/884297
- https://bugs.gentoo.org/895684
-
2023-02-24 16:29:38 UTC Looks dead upstream: https://github.com/SciRuby/rb-gsl/issues/63
-
It seems it's only compatible with gsl 2.1 as well:
- https://github.com/SciRuby/rb-gsl#description
-
Ruby/GSL is compatible with GSL versions upto 2.1.
- https://github.com/SciRuby/rb-gsl#usage-with-gsl-21
-
⇒ clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: x86_64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
In the clang 15 docs it doesn't say it can be disabled:
- https://releases.llvm.org/15.0.0/tools/clang/docs/
- https://releases.llvm.org/15.0.0/tools/clang/docs/DiagnosticsReference.html
-
-Wincompatible-function-pointer-typesThis diagnostic is enabled by default.
-
But in clang 16 it does:
- https://releases.llvm.org/16.0.0/tools/clang/docs/DiagnosticsReference.html#wincompatible-function-pointer-types
-
-Wincompatible-function-pointer-typesThis diagnostic is an error by default, but the flag-Wno-incompatible-function-pointer-typescan be used to disable the error.
-
ChatGPT claims I should be able to pass that through like this:
CFLAGS="-Wno-incompatible-function-pointer-types" gem install gsl -v '2.1.0.3' --source 'https://rubygems.org/'
But when I tried I still got the same errors.
Not sure if that is because I'm passing it through wrong, the 'opt out' flag doesn't exist on clang 15, or if it just won't work as a solution at all.