getdnsapi / getdns

A modern asynchronous DNS API https://getdnsapi.net/
Other
468 stars 126 forks source link

musl build for openwrt: getentropy_linux.c:304:23: error: 'CTL_KERN' undeclared #399

Closed iamperson347 closed 6 years ago

iamperson347 commented 6 years ago

Hey everyone,

After trying to update the openwrt package to getdns1.4.2, I am receiving the following errors during compile. I've read that this is possibly an issue with musl?

(https://github.com/wahern/luaossl/issues/54)

Any suggestions as to how to fix this would be appreciated. I do have the ability to add "patches" to the openwrt builds if that makes sense for this particular issue (i.e. change something in one of the source files). Admittedly, I am not super knowledgeable when it comes to c.

../libtool --quiet --tag=CC --mode=compile ccache_cc -I. -I. -I./util/auxiliary -I./../stubby/src -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap/working/openwrt-sdk-ar71xx-generic_gcc-5.5.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/getdns-1.4.2:getdns-1.4.2 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  -Wall -Wextra -D_BSD_SOURCE -D_DEFAULT_SOURCE -I/working/openwrt-sdk-ar71xx-generic_gcc-5.5.0_musl.Linux-x86_64/staging_dir/target-mips_24kc_musl/usr/include -I/working/openwrt-sdk-ar71xx-generic_gcc-5.5.0_musl.Linux-x86_64/staging_dir/target-mips_24kc_musl/include -I/working/openwrt-sdk-ar71xx-generic_gcc-5.5.0_musl.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.5.0_musl/usr/include -I/working/openwrt-sdk-ar71xx-generic_gcc-5.5.0_musl.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.5.0_musl/include/fortify -I/working/openwrt-sdk-ar71xx-generic_gcc-5.5.0_musl.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.5.0_musl/include  -I/working/openwrt-sdk-ar71xx-generic_gcc-5.5.0_musl.Linux-x86_64/staging_dir/target-mips_24kc_musl/usr/include  -c ./compat/getentropy_linux.c -o getentropy_linux.lo
./compat/getentropy_linux.c: In function 'getentropy_sysctl':
./compat/getentropy_linux.c:304:23: error: 'CTL_KERN' undeclared (first use in this function)
  static int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID };
                       ^
./compat/getentropy_linux.c:304:23: note: each undeclared identifier is reported only once for each function it appears in
./compat/getentropy_linux.c:304:33: error: 'KERN_RANDOM' undeclared (first use in this function)
  static int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID };
                                 ^
./compat/getentropy_linux.c:304:46: error: 'RANDOM_UUID' undeclared (first use in this function)
  static int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID };
                                              ^
./compat/getentropy_linux.c:312:10: error: variable 'args' has initializer but incomplete type
   struct __sysctl_args args = {
          ^
./compat/getentropy_linux.c:313:4: error: unknown field 'name' specified in initializer
    .name = mib,
    ^
./compat/getentropy_linux.c:313:12: warning: excess elements in struct initializer
    .name = mib,
            ^
./compat/getentropy_linux.c:313:12: note: (near initialization for 'args')
./compat/getentropy_linux.c:314:4: error: unknown field 'nlen' specified in initializer
    .nlen = 3,
    ^
./compat/getentropy_linux.c:314:12: warning: excess elements in struct initializer
    .nlen = 3,
            ^
./compat/getentropy_linux.c:314:12: note: (near initialization for 'args')
./compat/getentropy_linux.c:315:4: error: unknown field 'oldval' specified in initializer
    .oldval = (char *)buf + i,
    ^
./compat/getentropy_linux.c:315:14: warning: excess elements in struct initializer
    .oldval = (char *)buf + i,
              ^
./compat/getentropy_linux.c:315:14: note: (near initialization for 'args')
./compat/getentropy_linux.c:316:4: error: unknown field 'oldlenp' specified in initializer
    .oldlenp = &chunk,
    ^
./compat/getentropy_linux.c:316:15: warning: excess elements in struct initializer
    .oldlenp = &chunk,
               ^
./compat/getentropy_linux.c:316:15: note: (near initialization for 'args')
./compat/getentropy_linux.c:312:24: error: storage size of 'args' isn't known
   struct __sysctl_args args = {
                        ^
./compat/getentropy_linux.c:312:24: warning: unused variable 'args' [-Wunused-variable]
make[4]: *** [getentropy_linux.lo] Error 1
hanvinke commented 6 years ago

Maybe it would be helpful when you can tell which configure options you used? Did you get the source from git? What I noticed while compiling it from git, sometimes it is useful to do an autoreconf twice:

$ git submodule update --init $ libtoolize -ci $ autoreconf -vfi $ ./configure $ autoreconf -vfim

[Edit: never heard of musl, I am sorry, you probably used CC=musl-gcc ./configure for building]

wtoorop commented 6 years ago

@iamperson347 Does attached patch help? 0001-Bugfix-399-Reinclude-linux-sysctl.h-in-getentropy_li.patch.gz

iamperson347 commented 6 years ago

@wtoorop Yes - that fixed the issue. Thank you.