Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure with Clang 16 (-Wincompatible-function-pointer-types) #68

Open
thesamesam opened this issue Feb 24, 2023 · 3 comments
Open

Comments

@thesamesam
Copy link

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.

@bubbaspaarx
Copy link

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

@0xdevalias
Copy link

0xdevalias commented Jun 20, 2024

Reported downstream in Gentoo at bugs.gentoo.org/895684.

It seems that bug was closed with this commit:

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:

It seems it's only compatible with gsl 2.1 as well:

@0xdevalias
Copy link

⇒ 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:

But in clang 16 it does:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants