oVirt / ovirt-engine-sdk-ruby

Ruby gem that simplyfies access to the oVirt Engine API
20 stars 12 forks source link

error: incompatible function pointer types in ov_http_client.c:1009 gem install ovirt-engine-sdk on mac arm64 #14

Open jrafanie opened 5 months ago

jrafanie commented 5 months ago
% gem install ovirt-engine-sdk -v4.6.0
Building native extensions. This could take a while...
ERROR:  Error installing ovirt-engine-sdk:
        ERROR: Failed to build gem native extension.

    current directory: /Users/joerafaniello/.gem/ruby/3.1.4/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
/Users/joerafaniello/.rubies/ruby-3.1.4/bin/ruby -I /Users/joerafaniello/.rubies/ruby-3.1.4/lib/ruby/3.1.0 extconf.rb
checking for xml2-config... yes
checking for curl-config... yes
creating Makefile

current directory: /Users/joerafaniello/.gem/ruby/3.1.4/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
make DESTDIR\= sitearchdir\=./.gem.20240507-31785-3ohqdr sitelibdir\=./.gem.20240507-31785-3ohqdr clean

current directory: /Users/joerafaniello/.gem/ruby/3.1.4/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
make DESTDIR\= sitearchdir\=./.gem.20240507-31785-3ohqdr sitelibdir\=./.gem.20240507-31785-3ohqdr
compiling ov_error.c
compiling ov_http_client.c
ov_http_client.c:216:29: warning: excess elements in array initializer [-Wexcess-initializers]
        .reserved = { NULL, NULL }
                            ^~~~
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/stddef.h:89:16: note: expanded from macro 'NULL'
#  define NULL ((void*)0)
               ^~~~~~~~~~
ov_http_client.c:272:39: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    count = INT2NUM(context_ptr->size * context_ptr->nmemb);
            ~~~~~~~ ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
ov_http_client.c:392:33: warning: comparison of integers of different signs: 'long' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
        while (pointer - buffer < length && isspace(*pointer)) {
               ~~~~~~~~~~~~~~~~ ^ ~~~~~~
ov_http_client.c:501:9: error: call to undeclared function 'ruby_thread_has_gvl_p'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    if (ruby_thread_has_gvl_p()) {
        ^
ov_http_client.c:659:18: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    ptr->limit = connections;
               ~ ^~~~~~~~~~~
ov_http_client.c:853:25: warning: implicit conversion from enumeration type 'CURLMcode' to different enumeration type 'CURLcode' [-Wenum-conversion]
    context_ptr->code = curl_multi_wait(context_ptr->handle, NULL, 0, timeout, NULL);
                      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ov_http_client.c:874:25: warning: implicit conversion from enumeration type 'CURLMcode' to different enumeration type 'CURLcode' [-Wenum-conversion]
    context_ptr->code = curl_multi_perform(context_ptr->handle, &pending);
                      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ov_http_client.c:853:71: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    context_ptr->code = curl_multi_wait(context_ptr->handle, NULL, 0, timeout, NULL);
                        ~~~~~~~~~~~~~~~                               ^~~~~~~
ov_http_client.c:1009:47: error: incompatible function pointer types passing 'int (VALUE, VALUE, struct curl_slist **)' (aka 'int (unsigned long, unsigned long, struct curl_slist **)') to parameter of type 'int (*)(VALUE, VALUE, VALUE)' (aka 'int (*)(unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
        rb_hash_foreach(request_ptr->headers, ov_http_client_add_header, (VALUE) headers);
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/joerafaniello/.rubies/ruby-3.1.4/include/ruby-3.1.0/ruby/internal/intern/hash.h:83:40: note: passing argument to parameter 'func' here
void rb_hash_foreach(VALUE hash, int (*func)(VALUE key, VALUE val, VALUE arg), VALUE arg);
                                       ^
ov_http_client.c:1100:34: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
    if (RHASH_SIZE(ptr->pending) < ptr->limit) {
        ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
ov_http_client.c:1126:71: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
        while (RARRAY_LEN(ptr->queue) > 0 && RHASH_SIZE(ptr->pending) < ptr->limit) {
                                             ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
9 warnings and 2 errors generated.
make: *** [ov_http_client.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/joerafaniello/.gem/ruby/3.1.4/gems/ovirt-engine-sdk-4.6.0 for inspection.
Results logged to /Users/joerafaniello/.gem/ruby/3.1.4/extensions/arm64-darwin-23/3.1.0-static/ovirt-engine-sdk-4.6.0/gem_make.out
jrafanie commented 5 months ago

If I disable the error on incompatible function pointer types, I can get further:

% gem install ovirt-engine-sdk -v4.6.0 -- --with-cflags="-Wno-error=incompatible-function-pointer-types"
Building native extensions with: '--with-cflags=-Wno-error=incompatible-function-pointer-types'
This could take a while...
ERROR:  Error installing ovirt-engine-sdk:
        ERROR: Failed to build gem native extension.

    current directory: /Users/joerafaniello/.gem/ruby/3.1.4/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
/Users/joerafaniello/.rubies/ruby-3.1.4/bin/ruby -I /Users/joerafaniello/.rubies/ruby-3.1.4/lib/ruby/3.1.0 extconf.rb --with-cflags\=-Wno-error\=incompatible-function-pointer-types
checking for xml2-config... yes
checking for curl-config... yes
creating Makefile

current directory: /Users/joerafaniello/.gem/ruby/3.1.4/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
make DESTDIR\= sitearchdir\=./.gem.20240507-32780-ykp917 sitelibdir\=./.gem.20240507-32780-ykp917 clean

current directory: /Users/joerafaniello/.gem/ruby/3.1.4/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
make DESTDIR\= sitearchdir\=./.gem.20240507-32780-ykp917 sitelibdir\=./.gem.20240507-32780-ykp917
compiling ov_error.c
compiling ov_http_client.c
ov_http_client.c:216:29: warning: excess elements in array initializer [-Wexcess-initializers]
        .reserved = { NULL, NULL }
                            ^~~~
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/stddef.h:89:16: note: expanded from macro 'NULL'
#  define NULL ((void*)0)
               ^~~~~~~~~~
ov_http_client.c:501:9: error: call to undeclared function 'ruby_thread_has_gvl_p'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    if (ruby_thread_has_gvl_p()) {
        ^
ov_http_client.c:853:25: warning: implicit conversion from enumeration type 'CURLMcode' to different enumeration type 'CURLcode' [-Wenum-conversion]
    context_ptr->code = curl_multi_wait(context_ptr->handle, NULL, 0, timeout, NULL);
                      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ov_http_client.c:874:25: warning: implicit conversion from enumeration type 'CURLMcode' to different enumeration type 'CURLcode' [-Wenum-conversion]
    context_ptr->code = curl_multi_perform(context_ptr->handle, &pending);
                      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ov_http_client.c:1009:47: warning: incompatible function pointer types passing 'int (VALUE, VALUE, struct curl_slist **)' (aka 'int (unsigned long, unsigned long, struct curl_slist **)') to parameter of type 'int (*)(VALUE, VALUE, VALUE)' (aka 'int (*)(unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
        rb_hash_foreach(request_ptr->headers, ov_http_client_add_header, (VALUE) headers);
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/joerafaniello/.rubies/ruby-3.1.4/include/ruby-3.1.0/ruby/internal/intern/hash.h:83:40: note: passing argument to parameter 'func' here
void rb_hash_foreach(VALUE hash, int (*func)(VALUE key, VALUE val, VALUE arg), VALUE arg);
                                       ^
4 warnings and 1 error generated.
make: *** [ov_http_client.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/joerafaniello/.gem/ruby/3.1.4/gems/ovirt-engine-sdk-4.6.0 for inspection.
Results logged to /Users/joerafaniello/.gem/ruby/3.1.4/extensions/arm64-darwin-23/3.1.0-static/ovirt-engine-sdk-4.6.0/gem_make.out

This is then gets me to issue https://github.com/oVirt/ovirt-engine-sdk-ruby/issues/11

jrafanie commented 5 months ago

Note, freebsd has a patch to resolve this issue against newer clang 16: https://cgit.freebsd.org/ports/commit/?id=463e93ce059522a1f1a93474bb41f90561b77d4f

jrafanie commented 5 months ago

See: https://github.com/oVirt/ovirt-engine-sdk-ruby/issues/11#issuecomment-2098807108

I had to use

gem install ovirt-engine-sdk -v4.6.0 -- --with-cflags="-Wno-error=incompatible-function-pointer-types -Wno-error=implicit-function-declaration"

I ran into #11 so I had to ignore both types of errors.

Fryguy commented 5 months ago

@mwperina Can you help out here or know who could help us?

kbrock commented 3 weeks ago

These warnings are no longer ignorable in ruby 3.3. So I am not able to build on my dev machine (mac)

micwoj92 commented 3 weeks ago

These warnings are no longer ignorable in ruby 3.3. So I am not able to build on my dev machine (mac)

This is not true. You are 99% likely running into other issue.

I can't find anything that changed in ruby 3.3 release notes that indicates this.

jrafanie commented 3 weeks ago

These warnings are no longer ignorable in ruby 3.3. So I am not able to build on my dev machine (mac)

@kbrock what clang is it attempting to build against? Some warnings can become errors in different versions.

See: https://github.com/oVirt/ovirt-engine-sdk-ruby/issues/11#issuecomment-2098801258

Check the release notes for the different branch/tag for the version you have.

kbrock commented 3 weeks ago

@micwoj92 thank you for all your help