oVirt / ovirt-engine-sdk-ruby

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

error when trying to install ovirt-engine-sdk 4.6.0 in vagrant #11

Open xXkoshmarikXx opened 7 months ago

xXkoshmarikXx commented 7 months ago

following error occurred when trying to install plugin into vagrant command: 'vagrant plugin install ovirt-engine-sdk' error:

ERROR: Failed to build gem native extension.

    current directory: ~/.vagrant.d/gems/3.1.4/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
/opt/vagrant/embedded/bin/ruby -I /opt/vagrant/embedded/lib/ruby/3.1.0 extconf.rb
checking for xml2-config... yes
checking for curl-config... yes
creating Makefile

current directory: ~/.vagrant.d/gems/3.1.4/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
make DESTDIR\= sitearchdir\=./.gem.20240207-27538-g8lk8z sitelibdir\=./.gem.20240207-27538-g8lk8z clean

current directory: ~/.vagrant.d/gems/3.1.4/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
make DESTDIR\= sitearchdir\=./.gem.20240207-27538-g8lk8z sitelibdir\=./.gem.20240207-27538-g8lk8z
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);
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
/opt/vagrant/embedded/include/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
jrafanie commented 4 months ago

According to https://github.com/llvm/llvm-project/blob/release/16.x/clang/docs/ReleaseNotes.rst

The -Wimplicit-function-declaration and -Wimplicit-int warnings now default to an error in C99, C11, and C17. As of C2x, support for implicit function declarations and implicit int has been removed, and the warning options will have no effect. Specifying -Wimplicit-int in C89 mode will now issue warnings instead of being a noop.

NOTE: We recommend that projects using configure scripts verify that the results do not change before/after setting -Werror=implicit-function-declarations or -Wimplicit-int to avoid incompatibility with Clang 16.

Looks like it was a warning in clang 15: https://github.com/llvm/llvm-project/blob/release/15.x/clang/docs/ReleaseNotes.rst

jrafanie commented 4 months ago

I had to do this to get it build 4.6.0 on mac arm:

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

If you're only seeing this problem, you can probably get by with:

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

I was seeing the issue in #14, so I needed to also add -Wno-error=incompatible-function-pointer-types

shihabsnt commented 3 months ago

I had to do this to get it build 4.6.0 on mac arm:

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

If you're only seeing this problem, you can probably get by with:

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

I was seeing the issue in #14, so I needed to also add -Wno-error=incompatible-function-pointer-types

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

Worked for me. mysql2 errors also solved when using this flag. You saved my day.

jrafanie commented 3 months ago

@shihabsnt thanks for confirming it worked for you... it's a reasonable workaround until they can change the code to avoid these errors with newer clang versions.

micwoj92 commented 3 months ago

FYI if anyone is using gcc14 (which produces similar errors) you can use -- --with-cflags="-Wno-int-conversion -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types"

I don't know if I should open new issue, it's technically different, but this one already has been reported 3 times.