kostya / sigar

Fork of hyperic/sigar with some fixes. Support only ruby binding. Part of Eye gem.
Apache License 2.0
5 stars 4 forks source link

Build failure in alpine linux. #3

Closed jcoyne closed 6 years ago

jcoyne commented 6 years ago

Dockerfile:

FROM ruby:2.5-alpine3.8
RUN apk add --update build-base sqlite-dev tzdata
RUN gem install kostya-sigar -v2.0.4

Output:

docker build .
Sending build context to Docker daemon  450.4MB
Step 1/3 : FROM ruby:2.5-alpine3.8
 ---> 2b1694a122af
Step 2/3 : RUN apk add --update build-base sqlite-dev tzdata
 ---> Using cache
 ---> ff7d58d16b23
Step 3/3 : RUN gem install kostya-sigar -v2.0.4
 ---> Running in 7045da7344bc
Building native extensions. This could take a while...
ERROR:  Error installing kostya-sigar:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/kostya-sigar-2.0.4/bindings/ruby
/usr/local/bin/ruby -r ./siteconf20181130-1-z75ujc.rb extconf.rb
Ruby platform=x86_64-linux-musl
checking for sys/sysmacros.h... yes
../../src/sigar_format.c -> sigar_format.c
../../src/sigar_signal.c -> sigar_signal.c
../../src/sigar_cache.c -> sigar_cache.c
../../src/sigar.c -> sigar.c
../../src/sigar_getline.c -> sigar_getline.c
../../src/sigar_util.c -> sigar_util.c
../../src/sigar_ptql.c -> sigar_ptql.c
../../src/sigar_fileinfo.c -> sigar_fileinfo.c
../../src/os/linux/linux_sigar.c -> linux_sigar.c
creating Makefile

current directory: /usr/local/bundle/gems/kostya-sigar-2.0.4/bindings/ruby
make "DESTDIR=" clean

current directory: /usr/local/bundle/gems/kostya-sigar-2.0.4/bindings/ruby
make "DESTDIR="
compiling linux_sigar.c
linux_sigar.c: In function 'sigar_mem_get':
linux_sigar.c:318:55: warning: passing argument 2 of 'sigar_meminfo' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     mem->total  = sigar_meminfo(buffer, MEMINFO_PARAM("MemTotal"));
                                                       ^
linux_sigar.c:281:26: note: in definition of macro 'MEMINFO_PARAM'
 #define MEMINFO_PARAM(a) a ":", SSTRLEN(a ":")
                          ^
linux_sigar.c:283:36: note: expected 'char *' but argument is of type 'const char *'
 static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer,
                                    ^~~~~~~~~~~~~
linux_sigar.c:319:55: warning: passing argument 2 of 'sigar_meminfo' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     mem->free   = sigar_meminfo(buffer, MEMINFO_PARAM("MemFree"));
                                                       ^
linux_sigar.c:281:26: note: in definition of macro 'MEMINFO_PARAM'
 #define MEMINFO_PARAM(a) a ":", SSTRLEN(a ":")
                          ^
linux_sigar.c:283:36: note: expected 'char *' but argument is of type 'const char *'
 static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer,
                                    ^~~~~~~~~~~~~
linux_sigar.c:322:51: warning: passing argument 2 of 'sigar_meminfo' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     buffers = sigar_meminfo(buffer, MEMINFO_PARAM("Buffers"));
                                                   ^
linux_sigar.c:281:26: note: in definition of macro 'MEMINFO_PARAM'
 #define MEMINFO_PARAM(a) a ":", SSTRLEN(a ":")
                          ^
linux_sigar.c:283:36: note: expected 'char *' but argument is of type 'const char *'
 static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer,
                                    ^~~~~~~~~~~~~
linux_sigar.c:323:51: warning: passing argument 2 of 'sigar_meminfo' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     cached  = sigar_meminfo(buffer, MEMINFO_PARAM("Cached"));
                                                   ^
linux_sigar.c:281:26: note: in definition of macro 'MEMINFO_PARAM'
 #define MEMINFO_PARAM(a) a ":", SSTRLEN(a ":")
                          ^
linux_sigar.c:283:36: note: expected 'char *' but argument is of type 'const char *'
 static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer,
                                    ^~~~~~~~~~~~~
linux_sigar.c: In function 'sigar_swap_get':
linux_sigar.c:350:56: warning: passing argument 2 of 'sigar_meminfo' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     swap->total  = sigar_meminfo(buffer, MEMINFO_PARAM("SwapTotal"));
                                                        ^
linux_sigar.c:281:26: note: in definition of macro 'MEMINFO_PARAM'
 #define MEMINFO_PARAM(a) a ":", SSTRLEN(a ":")
                          ^
linux_sigar.c:283:36: note: expected 'char *' but argument is of type 'const char *'
 static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer,
                                    ^~~~~~~~~~~~~
linux_sigar.c:351:56: warning: passing argument 2 of 'sigar_meminfo' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     swap->free   = sigar_meminfo(buffer, MEMINFO_PARAM("SwapFree"));
                                                        ^
linux_sigar.c:281:26: note: in definition of macro 'MEMINFO_PARAM'
 #define MEMINFO_PARAM(a) a ":", SSTRLEN(a ":")
                          ^
linux_sigar.c:283:36: note: expected 'char *' but argument is of type 'const char *'
 static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer,
                                    ^~~~~~~~~~~~~
linux_sigar.c: In function 'sigar_proc_cumulative_disk_io_get':
linux_sigar.c:775:72: warning: passing argument 2 of 'get_named_proc_token' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     proc_cumulative_disk_io->bytes_read = get_named_proc_token(buffer, "\nread_bytes");
                                                                        ^~~~~~~~~~~~~~
linux_sigar.c:754:29: note: expected 'char *' but argument is of type 'const char *'
 SIGAR_INLINE sigar_uint64_t get_named_proc_token(char *buffer,
                             ^~~~~~~~~~~~~~~~~~~~
linux_sigar.c:776:75: warning: passing argument 2 of 'get_named_proc_token' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     proc_cumulative_disk_io->bytes_written = get_named_proc_token(buffer, "\nwrite_bytes");
                                                                           ^~~~~~~~~~~~~~~
linux_sigar.c:754:29: note: expected 'char *' but argument is of type 'const char *'
 SIGAR_INLINE sigar_uint64_t get_named_proc_token(char *buffer,
                             ^~~~~~~~~~~~~~~~~~~~
linux_sigar.c: In function 'sigar_disk_usage_get':
linux_sigar.c:1445:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (disk->time == SIGAR_FIELD_NOTIMPL) {
                        ^~
linux_sigar.c:1449:36: error: 'HZ' undeclared (first use in this function)
             tput = ((double)ios) * HZ / interval;
                                    ^~
linux_sigar.c:1449:36: note: each undeclared identifier is reported only once for each function it appears in
linux_sigar.c:1453:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (disk->qtime == SIGAR_FIELD_NOTIMPL) {
                         ^~
In file included from linux_sigar.c:30:0:
linux_sigar.c: In function 'sigar_cpu_info_list_get':
../../include/sigar_util.h:147:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     (sigar->ncpu < sigar->lcpu) ? sigar->ncpu : \
                  ^
linux_sigar.c:1658:31: note: in expansion of macro 'sigar_cpu_socket_count'
         info->total_sockets = sigar_cpu_socket_count(sigar);
                               ^~~~~~~~~~~~~~~~~~~~~~
linux_sigar.c: In function 'sigar_nfs_v2_get':
linux_sigar.c:2234:29: warning: passing argument 2 of 'sigar_proc_nfs_gets' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
                             "proc2", buffer, sizeof(buffer));
                             ^~~~~~~
linux_sigar.c:2206:12: note: expected 'char *' but argument is of type 'const char *'
 static int sigar_proc_nfs_gets(char *file, char *tok,
            ^~~~~~~~~~~~~~~~~~~
In file included from linux_sigar.c:30:0:
linux_sigar.c: In function 'sigar_nfs_client_v2_get':
../../include/sigar_util.h:60:22: warning: passing argument 1 of 'sigar_nfs_v2_get' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 #define PROC_FS_ROOT "/proc/"
                      ^
linux_sigar.c:2267:29: note: in expansion of macro 'PROC_FS_ROOT'
     return sigar_nfs_v2_get(PROC_FS_ROOT "net/rpc/nfs",
                             ^~~~~~~~~~~~
linux_sigar.c:2229:12: note: expected 'char *' but argument is of type 'const char *'
 static int sigar_nfs_v2_get(char *file, sigar_nfs_v2_t *nfs)
            ^~~~~~~~~~~~~~~~
In file included from linux_sigar.c:30:0:
linux_sigar.c: In function 'sigar_nfs_server_v2_get':
../../include/sigar_util.h:60:22: warning: passing argument 1 of 'sigar_nfs_v2_get' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 #define PROC_FS_ROOT "/proc/"
                      ^
linux_sigar.c:2274:29: note: in expansion of macro 'PROC_FS_ROOT'
     return sigar_nfs_v2_get(PROC_FS_ROOT "net/rpc/nfsd",
                             ^~~~~~~~~~~~
linux_sigar.c:2229:12: note: expected 'char *' but argument is of type 'const char *'
 static int sigar_nfs_v2_get(char *file, sigar_nfs_v2_t *nfs)
            ^~~~~~~~~~~~~~~~
linux_sigar.c: In function 'sigar_nfs_v3_get':
linux_sigar.c:2283:29: warning: passing argument 2 of 'sigar_proc_nfs_gets' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
                             "proc3", buffer, sizeof(buffer));
                             ^~~~~~~
linux_sigar.c:2206:12: note: expected 'char *' but argument is of type 'const char *'
 static int sigar_proc_nfs_gets(char *file, char *tok,
            ^~~~~~~~~~~~~~~~~~~
In file included from linux_sigar.c:30:0:
linux_sigar.c: In function 'sigar_nfs_client_v3_get':
../../include/sigar_util.h:60:22: warning: passing argument 1 of 'sigar_nfs_v3_get' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 #define PROC_FS_ROOT "/proc/"
                      ^
linux_sigar.c:2320:29: note: in expansion of macro 'PROC_FS_ROOT'
     return sigar_nfs_v3_get(PROC_FS_ROOT "net/rpc/nfs",
                             ^~~~~~~~~~~~
linux_sigar.c:2278:12: note: expected 'char *' but argument is of type 'const char *'
 static int sigar_nfs_v3_get(char *file, sigar_nfs_v3_t *nfs)
            ^~~~~~~~~~~~~~~~
In file included from linux_sigar.c:30:0:
linux_sigar.c: In function 'sigar_nfs_server_v3_get':
../../include/sigar_util.h:60:22: warning: passing argument 1 of 'sigar_nfs_v3_get' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 #define PROC_FS_ROOT "/proc/"
                      ^
linux_sigar.c:2327:29: note: in expansion of macro 'PROC_FS_ROOT'
     return sigar_nfs_v3_get(PROC_FS_ROOT "net/rpc/nfsd",
                             ^~~~~~~~~~~~
linux_sigar.c:2278:12: note: expected 'char *' but argument is of type 'const char *'
 static int sigar_nfs_v3_get(char *file, sigar_nfs_v3_t *nfs)
            ^~~~~~~~~~~~~~~~
linux_sigar.c: In function 'get_hw_type':
linux_sigar.c:2337:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "ax25";
                ^~~~~~
linux_sigar.c:2339:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "ec";
                ^~~~
linux_sigar.c:2341:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "ether";
                ^~~~~~~
linux_sigar.c:2343:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "fddi";
                ^~~~~~
linux_sigar.c:2345:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "dlci";
                ^~~~~~
linux_sigar.c:2347:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "frad";
                ^~~~~~
linux_sigar.c:2349:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "hdlc";
                ^~~~~~
linux_sigar.c:2351:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "lapb";
                ^~~~~~
linux_sigar.c:2353:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "hippi";
                ^~~~~~~
linux_sigar.c:2355:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "irda";
                ^~~~~~
linux_sigar.c:2357:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "loop";
                ^~~~~~
linux_sigar.c:2359:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "netrom";
                ^~~~~~~~
linux_sigar.c:2361:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "ppp";
                ^~~~~
linux_sigar.c:2363:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "rose";
                ^~~~~~
linux_sigar.c:2365:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "sit";
                ^~~~~
linux_sigar.c:2367:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "slip";
                ^~~~~~
linux_sigar.c:2369:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "cslip";
                ^~~~~~~
linux_sigar.c:2371:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "slip6";
                ^~~~~~~
linux_sigar.c:2373:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "cslip6";
                ^~~~~~~~
linux_sigar.c:2375:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "adaptive";
                ^~~~~~~~~~
linux_sigar.c:2377:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "tr";
                ^~~~
linux_sigar.c:2379:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "tr";
                ^~~~
linux_sigar.c:2381:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "tunnel";
                ^~~~~~~~
linux_sigar.c:2383:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "x25";
                ^~~~~
linux_sigar.c:2385:16: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         return "unknown";
                ^~~~~~~~~
linux_sigar.c: In function 'generic_vendor_parse':
linux_sigar.c:2588:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (len > sizeof(info->vendor_version)) {
                     ^
linux_sigar.c: At top level:
cc1: warning: unrecognized command line option '-Wno-self-assign'
cc1: warning: unrecognized command line option '-Wno-constant-logical-operand'
cc1: warning: unrecognized command line option '-Wno-parentheses-equality'
make: *** [Makefile:243: linux_sigar.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/bundle/gems/kostya-sigar-2.0.4 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux/2.5.0/kostya-sigar-2.0.4/gem_make.out
The command '/bin/sh -c gem install kostya-sigar -v2.0.4' returned a non-zero code: 1

it works great on stretch:

FROM ruby:2.5-stretch

RUN apt-get update -qq && \
    apt-get install -y nano build-essential

RUN gem install kostya-sigar -v2.0.4
kostya commented 6 years ago

i see one compile error:

linux_sigar.c:1449:36: error: 'HZ' undeclared (first use in this function)
             tput = ((double)ios) * HZ / interval;

i have no time to test it, you can compile project:

git clone https://github.com/kostya/sigar.git
cd sigar
rake build

here i see similar bug https://github.com/zfsonlinux/zfs/issues/6357 they say thy change HZ, to hz, or try

#ifndef HZ
#define HZ 1000
#endif

if it fixed, we can add this changes here.