hyperic / sigar

System Information Gatherer And Reporter
http://sigar.hyperic.com/
Apache License 2.0
1.52k stars 504 forks source link

Sigar compilation error on Mac OS Big Sur #143

Open bill-transue opened 3 years ago

bill-transue commented 3 years ago

I'm having problems with gem install sigar on Mac OS 11.1 Big Sur, Ruby 2.6.5 with rvm. Here is my error output:

current directory: /Users/bill/.rvm/gems/ruby-2.6.5@enroll/gems/sigar-0.7.3/bindings/ruby
/Users/bill/.rvm/rubies/ruby-2.6.5/bin/ruby -I /Users/bill/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210113-52732-1v7sh8j.rb extconf.rb
Ruby platform=x86_64-darwin20
rbsigar_generated.rx needs update
generating rbsigar_generated.rx
fatal: not a git repository (or any of the parent directories): .git
../../src/sigar_fileinfo.c -> sigar_fileinfo.c
../../src/sigar_util.c -> sigar_util.c
../../src/sigar_signal.c -> sigar_signal.c
../../src/sigar_getline.c -> sigar_getline.c
../../src/sigar_ptql.c -> sigar_ptql.c
../../src/sigar_cache.c -> sigar_cache.c
../../src/sigar.c -> sigar.c
../../src/sigar_format.c -> sigar_format.c
../../src/os/darwin/darwin_sigar.c -> darwin_sigar.c
creating Makefile

current directory: /Users/bill/.rvm/gems/ruby-2.6.5@enroll/gems/sigar-0.7.3/bindings/ruby
make "DESTDIR=" clean

current directory: /Users/bill/.rvm/gems/ruby-2.6.5@enroll/gems/sigar-0.7.3/bindings/ruby
make "DESTDIR="
compiling darwin_sigar.c
darwin_sigar.c:272:23: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    (*sigar)->ticks = sysconf(_SC_CLK_TCK);
                    ~ ^~~~~~~~~~~~~~~~~~~~
darwin_sigar.c:299:16: warning: returning 'const char [37]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "Failed to open /dev/kmem for reading";
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
darwin_sigar.c:301:16: warning: returning 'const char [32]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "/proc filesystem is not mounted";
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
darwin_sigar.c:1009:14: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    num = len/sizeof(*proc);
        ~ ~~~^~~~~~~~~~~~~~
darwin_sigar.c:1399:19: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
static const char const thread_states[] = {
                  ^
darwin_sigar.c:1581:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    len = strlen(kargs->ptr);
        ~ ^~~~~~~~~~~~~~~~~~
darwin_sigar.c:1614:31: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
        int alen = strlen(ptr)+1;
            ~~~~   ~~~~~~~~~~~^~
darwin_sigar.c:1649:20: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
        int slen = strlen(ptr);
            ~~~~   ^~~~~~~~~~~
darwin_sigar.c:1780:20: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        klen = val - ptr;
             ~ ~~~~^~~~~
darwin_sigar.c:1785:16: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
        vlen = strlen(val);
             ~ ^~~~~~~~~~~
darwin_sigar.c:1932:23: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
            int len = strlen(ptr);
                ~~~   ^~~~~~~~~~~
darwin_sigar.c:1987:51: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                                    (char *)name, strlen(name));
                                                  ^~~~~~~~~~~~
darwin_sigar.c:2149:36: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
    if ((num = sigar_getfsstat(fs, len, MNT_NOWAIT)) < 0) {
               ~~~~~~~~~~~~~~~     ^~~
darwin_sigar.c:2364:13: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
    if (mhz != SIGAR_FIELD_NOTIMPL) {
        ~~~ ^  ~~~~~~~~~~~~~~~~~~~
darwin_sigar.c:2367:17: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
    if (mhz_max != SIGAR_FIELD_NOTIMPL) {
        ~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~
darwin_sigar.c:2370:17: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
    if (mhz_min != SIGAR_FIELD_NOTIMPL) {
        ~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~
darwin_sigar.c:2391:13: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
    if (mhz == SIGAR_FIELD_NOTIMPL) {
        ~~~ ^  ~~~~~~~~~~~~~~~~~~~
darwin_sigar.c:2396:17: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
    if (mhz_max == SIGAR_FIELD_NOTIMPL) {
        ~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~
darwin_sigar.c:2399:17: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
    if (mhz_min == SIGAR_FIELD_NOTIMPL) {
        ~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~
darwin_sigar.c:2445:16: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
    for (i=0; i<sigar->ncpu; i++) {
              ~^~~~~~~~~~~~
darwin_sigar.c:2462:31: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
        info->total_sockets = sigar_cpu_socket_count(sigar);
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../include/sigar_util.h:147:18: note: expanded from macro 'sigar_cpu_socket_count'
    (sigar->ncpu < sigar->lcpu) ? sigar->ncpu : \
     ~~~~~~~~~~~ ^ ~~~~~~~~~~~
darwin_sigar.c:2584:27: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
    if (sigar->ifconf_len < len) {
        ~~~~~~~~~~~~~~~~~ ^ ~~~
darwin_sigar.c:2586:29: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
        sigar->ifconf_len = len;
                          ~ ^~~
darwin_sigar.c:3309:42: warning: incompatible pointer types passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'rpc_cnt_t *' (aka 'int *') [-Wincompatible-pointer-types]
    map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.rpccnt[0]);
                                         ^~~~~~~~~~~~~~~~
darwin_sigar.c:3251:59: note: passing argument to parameter 'rpc' here
static void map_nfs_stats(sigar_nfs_v3_t *nfs, rpc_cnt_t *rpc)
                                                          ^
darwin_sigar.c:3335:42: warning: incompatible pointer types passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'rpc_cnt_t *' (aka 'int *') [-Wincompatible-pointer-types]
    map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.srvrpccnt[0]);
                                         ^~~~~~~~~~~~~~~~~~~
darwin_sigar.c:3251:59: note: passing argument to parameter 'rpc' here
static void map_nfs_stats(sigar_nfs_v3_t *nfs, rpc_cnt_t *rpc)
                                                          ^
darwin_sigar.c:3345:16: warning: returning 'const char [6]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "ether";
               ^~~~~~~
darwin_sigar.c:3347:16: warning: returning 'const char [3]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "tr";
               ^~~~
darwin_sigar.c:3349:16: warning: returning 'const char [5]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "fddi";
               ^~~~~~
darwin_sigar.c:3351:16: warning: returning 'const char [4]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "atm";
               ^~~~~
darwin_sigar.c:3353:16: warning: returning 'const char [5]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "vlan";
               ^~~~~~
darwin_sigar.c:3355:16: warning: returning 'const char [9]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "firewire";
               ^~~~~~~~~~
darwin_sigar.c:3358:16: warning: returning 'const char [7]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "bridge";
               ^~~~~~~~
darwin_sigar.c:3361:16: warning: returning 'const char [8]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return "unknown";
               ^~~~~~~~~
darwin_sigar.c:3625:9: warning: 'Gestalt' is deprecated: first deprecated in macOS 10.8 [-Wdeprecated-declarations]
    if (Gestalt(gestaltSystemVersion, &version) == noErr) {
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Gestalt.h:123:1: note: 'Gestalt' has been explicitly marked deprecated here
Gestalt(
^
darwin_sigar.c:3625:17: warning: 'gestaltSystemVersion' is deprecated: first deprecated in macOS 10.8 - Use NSProcessInfo's operatingSystemVersion property instead. [-Wdeprecated-declarations]
    if (Gestalt(gestaltSystemVersion, &version) == noErr) {
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Gestalt.h:2081:1: note: '' has been explicitly marked deprecated here
enum {
^
darwin_sigar.c:3627:13: warning: 'Gestalt' is deprecated: first deprecated in macOS 10.8 [-Wdeprecated-declarations]
            Gestalt('sys1' /*gestaltSystemVersionMajor*/, &version_major);
            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Gestalt.h:123:1: note: 'Gestalt' has been explicitly marked deprecated here
Gestalt(
^
darwin_sigar.c:3628:13: warning: 'Gestalt' is deprecated: first deprecated in macOS 10.8 [-Wdeprecated-declarations]
            Gestalt('sys2' /*gestaltSystemVersionMinor*/, &version_minor);
            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Gestalt.h:123:1: note: 'Gestalt' has been explicitly marked deprecated here
Gestalt(
^
darwin_sigar.c:3629:13: warning: 'Gestalt' is deprecated: first deprecated in macOS 10.8 [-Wdeprecated-declarations]
            Gestalt('sys3' /*gestaltSystemVersionBugFix*/, &version_fix);
            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Gestalt.h:123:1: note: 'Gestalt' has been explicitly marked deprecated here
Gestalt(
^
darwin_sigar.c:3656:22: warning: assigning to 'char *' from 'const char [7]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
            codename = "Jaguar";
                     ^ ~~~~~~~~
darwin_sigar.c:3659:22: warning: assigning to 'char *' from 'const char [8]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
            codename = "Panther";
                     ^ ~~~~~~~~~
darwin_sigar.c:3662:22: warning: assigning to 'char *' from 'const char [6]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
            codename = "Tiger";
                     ^ ~~~~~~~
darwin_sigar.c:3665:22: warning: assigning to 'char *' from 'const char [8]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
            codename = "Leopard";
                     ^ ~~~~~~~~~
darwin_sigar.c:3668:22: warning: assigning to 'char *' from 'const char [13]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
            codename = "Snow Leopard";
                     ^ ~~~~~~~~~~~~~~
darwin_sigar.c:3671:22: warning: assigning to 'char *' from 'const char [5]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
            codename = "Lion";
                     ^ ~~~~~~
darwin_sigar.c:3674:22: warning: assigning to 'char *' from 'const char [8]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
            codename = "Unknown";
                     ^ ~~~~~~~~~
45 warnings generated.
compiling rbsigar.c
rbsigar.c:107:13: error: implicitly declaring library function 'isdigit' with type 'int (int)' [-Werror,-Wimplicit-function-declaration]
        if (sigar_isdigit(*pid)) {
            ^
rbsigar.c:98:6: note: expanded from macro 'sigar_isdigit'
    (isdigit(((unsigned char)(c))))
     ^
rbsigar.c:107:13: note: include the header <ctype.h> or explicitly provide a declaration for 'isdigit'
rbsigar.c:98:6: note: expanded from macro 'sigar_isdigit'
    (isdigit(((unsigned char)(c))))
     ^
rbsigar.c:565:40: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                                  list.number);
                                  ~~~~~^~~~~~
1 warning and 1 error generated.
make: *** [rbsigar.o] Error 1

make failed, exit code 2

Can anyone help me out? Thanks for reading.

jorbs commented 3 years ago

@bill-transue did you have any success solving this error?

yuri-karpovich commented 3 years ago

How to fix it?

nidhindamodaran commented 3 years ago

Any update on this issue?

kostya commented 3 years ago

i suggest you need to add #include <ctype.h> to rbsigar.c or to darwin_sigar.c, can you check if it fixes.

kostya commented 3 years ago

you can try to use my fork: gem install kostya-sigar, with this fix.

markgoho commented 2 years ago

I got this to work by running bundle update eye -- this caused the kostya-sigar gem to be updated to 2.0.10 and then it worked

jporter-carecloud commented 1 year ago

I am having this issue trying to 'bundle install' on MAC Monterey. I have ruby 2.3.8

I installed kostya-sigar successfully but still no change. Are we supposed to use this version of sigar instead? How do i switch over to your version. Any help appreciated. thanks.

`jporter@cc webservices (dev) $ gem install sigar -v '0.7.3' Building native extensions. This could take a while... ERROR: Error installing sigar: ERROR: Failed to build gem native extension.

current directory: /Users/jporter/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/sigar-0.7.3/bindings/ruby

/Users/jporter/.rbenv/versions/2.3.8/bin/ruby -r ./siteconf20231012-39069-zk47pe.rb extconf.rb Ruby platform=x86_64-darwin21 rbsigar_generated.rx needs update generating rbsigar_generated.rx fatal: not a git repository (or any of the parent directories): .git ../../src/sigar_fileinfo.c -> sigar_fileinfo.c ../../src/sigar_util.c -> sigar_util.c ../../src/sigar_signal.c -> sigar_signal.c ../../src/sigar_getline.c -> sigar_getline.c ../../src/sigar_ptql.c -> sigar_ptql.c ../../src/sigar_cache.c -> sigar_cache.c ../../src/sigar.c -> sigar.c ../../src/sigar_format.c -> sigar_format.c ../../src/os/darwin/darwin_sigar.c -> darwin_sigar.c creating Makefile

current directory: /Users/jporter/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/sigar-0.7.3/bindings/ruby make "DESTDIR=" clean

current directory: /Users/jporter/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/sigar-0.7.3/bindings/ruby make "DESTDIR=" compiling darwin_sigar.c darwin_sigar.c:272:23: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] (*sigar)->ticks = sysconf(_SC_CLK_TCK); ~ ^~~~~~~~`