nsd
                                
                                 nsd copied to clipboard
                                
                                    nsd copied to clipboard
                            
                            
                            
                        Build errors for 4.10.0rc1
Hi.
I wanted to build nsd 4.10.0rc1 for Debian experimental, to get better testing before the release. I got the build errors below that didn't happen for 4.9.1. Are these something you want to fix?
/Simon
make -C simdzone
make[3]: Entering directory '/build/nsd-4.10.0~rc1/simdzone'
gcc -MT src/zone.o -MMD -MP -MF src/zone.d -Wdate-time -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=600 -DNDEBUG -I./include -I./src -I. -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/nsd-4.10.0~rc1=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -o src/zone.o -c ./src/zone.c
./src/zone.c: In function 'select_kernel':
./src/zone.c:77:11: error: implicit declaration of function 'strcasecmp' [-Werror=implicit-function-declaration]
   77 |       if (strcasecmp(preferred, kernels[count].name) == 0)
      |           ^~~~~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [Makefile:65: src/zone.o] Error 1
gcc -MT src/fallback/parser.o -MMD -MP -MF src/fallback/parser.d -Wdate-time -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=600 -DNDEBUG -I./include -I./src -I. -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/nsd-4.10.0~rc1=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -o src/fallback/parser.o -c ./src/fallback/parser.c
In file included from ./src/fallback/parser.c:16:
./src/generic/number.h: In function 'parse_int16':
./src/generic/number.h:98:12: error: implicit declaration of function 'htobe16' [-Werror=implicit-function-declaration]
   98 |   number = htobe16(number);
      |            ^~~~~~~
./src/generic/number.h: In function 'parse_int32':
./src/generic/number.h:115:12: error: implicit declaration of function 'htobe32' [-Werror=implicit-function-declaration]
  115 |   number = htobe32(number);
      |            ^~~~~~~
In file included from ./src/fallback/parser.c:32:
./src/generic/wks.h: In function 'service_hash':
./src/generic/wks.h:190:11: error: implicit declaration of function 'le64toh' [-Werror=implicit-function-declaration]
  190 |   input = le64toh(input);
      |           ^~~~~~~
In file included from ./src/fallback/parser.c:36:
./src/generic/svcb.h: In function 'parse_mandatory':
./src/generic/svcb.h:571:23: error: implicit declaration of function 'be16toh' [-Werror=implicit-function-declaration]
  571 |         smaller_key = be16toh(smaller_key);
      |                       ^~~~~~~
In file included from ./src/fallback/parser.c:39:
./src/generic/types.h: In function 'check_ttl':
./src/generic/types.h:117:12: error: implicit declaration of function 'be32toh' [-Werror=implicit-function-declaration]
  117 |   number = be32toh(number);
      |            ^~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [Makefile:65: src/fallback/parser.o] Error 1
gcc -MT src/westmere/parser.o -MMD -MP -MF src/westmere/parser.d -Wdate-time -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=600 -DNDEBUG -I./include -I./src -I. -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/nsd-4.10.0~rc1=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -march=westmere -o src/westmere/parser.o -c ./src/westmere/parser.c
In file included from ./src/westmere/parser.c:17:
./src/generic/number.h: In function 'parse_int16':
./src/generic/number.h:98:12: error: implicit declaration of function 'htobe16' [-Werror=implicit-function-declaration]
   98 |   number = htobe16(number);
      |            ^~~~~~~
./src/generic/number.h: In function 'parse_int32':
./src/generic/number.h:115:12: error: implicit declaration of function 'htobe32' [-Werror=implicit-function-declaration]
  115 |   number = htobe32(number);
      |            ^~~~~~~
In file included from ./src/westmere/parser.c:33:
./src/generic/wks.h: In function 'service_hash':
./src/generic/wks.h:190:11: error: implicit declaration of function 'le64toh' [-Werror=implicit-function-declaration]
  190 |   input = le64toh(input);
      |           ^~~~~~~
In file included from ./src/westmere/parser.c:37:
./src/generic/svcb.h: In function 'parse_mandatory':
./src/generic/svcb.h:571:23: error: implicit declaration of function 'be16toh' [-Werror=implicit-function-declaration]
  571 |         smaller_key = be16toh(smaller_key);
      |                       ^~~~~~~
In file included from ./src/westmere/parser.c:40:
./src/generic/types.h: In function 'check_ttl':
./src/generic/types.h:117:12: error: implicit declaration of function 'be32toh' [-Werror=implicit-function-declaration]
  117 |   number = be32toh(number);
      |            ^~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [Makefile:57: src/westmere/parser.o] Error 1
gcc -MT src/haswell/parser.o -MMD -MP -MF src/haswell/parser.d -Wdate-time -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=600 -DNDEBUG -I./include -I./src -I. -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/nsd-4.10.0~rc1=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -march=haswell -o src/haswell/parser.o -c ./src/haswell/parser.c
In file included from ./src/haswell/parser.c:17:
./src/generic/number.h: In function 'parse_int16':
./src/generic/number.h:98:12: error: implicit declaration of function 'htobe16' [-Werror=implicit-function-declaration]
   98 |   number = htobe16(number);
      |            ^~~~~~~
./src/generic/number.h: In function 'parse_int32':
./src/generic/number.h:115:12: error: implicit declaration of function 'htobe32' [-Werror=implicit-function-declaration]
  115 |   number = htobe32(number);
      |            ^~~~~~~
In file included from ./src/haswell/parser.c:33:
./src/generic/wks.h: In function 'service_hash':
./src/generic/wks.h:190:11: error: implicit declaration of function 'le64toh' [-Werror=implicit-function-declaration]
  190 |   input = le64toh(input);
      |           ^~~~~~~
In file included from ./src/haswell/parser.c:37:
./src/generic/svcb.h: In function 'parse_mandatory':
./src/generic/svcb.h:571:23: error: implicit declaration of function 'be16toh' [-Werror=implicit-function-declaration]
  571 |         smaller_key = be16toh(smaller_key);
      |                       ^~~~~~~
In file included from ./src/haswell/parser.c:40:
./src/generic/types.h: In function 'check_ttl':
./src/generic/types.h:117:12: error: implicit declaration of function 'be32toh' [-Werror=implicit-function-declaration]
  117 |   number = be32toh(number);
      |            ^~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [Makefile:61: src/haswell/parser.o] Error 1
make[3]: Target 'all' not remade because of errors.
make[3]: Leaving directory '/build/nsd-4.10.0~rc1/simdzone'
make[2]: *** [Makefile:159: simdzone/libzone.a] Error 2
Hi @jas4711. Thanks for the report! We're actually doing a longer rc period because we were hoping people would report issues. I'll get a Debian Experimental VM and sort this out.
To clarify, no need to build this on experimental specifically, it should happen if you build nsd 4.10.0rc1 via the nsd Debian package infrastructure for unstable or testing (and likely stable) too. The reference to experimental was only that if I manage to get nsd 4.10.0rc1 to build, as a Debian Developer I can upload it to Debian experimental so that others can test it.
The crucial gcc parameter is -Werror=implicit-function-declaration, if you add that you should be able to trigger this on any gcc system.  It is now the default when building Debian packages.  You may want to add this flag to your own CI/CD checking to avoid regressions.
@jas4711, the problem is the -D_XOPEN_SOURCE=600 compiler flag. If you remove that from the package it builds fine on my Debian VM.
@jas4711, can you confirm the problem is solved? We're gearing up for release 4.10.1 and I like to confirm everything works for you now.
NSD sets feature macros in the config.h if not defined. I'm running into this trying to get things to work for another compiler.  I'll have to read up a bit on feature_test_macros. I think setting it to a new standard is the way to go, I'll report which standard once I know more about the details.
In can reproduce this using gcc -D_XOPEN_SOURCE=600 endian.c. The problem is indeed that the right feature macro isn't set. I believe the compiler's default behavior is just being very liberal. endian.h has been around for quite a while, but will only be standardized in POSIX 2024 apparently(?) See: https://www.austingroupbugs.net/view.php?id=162.
As mentioned, NSD defines a bunch of macros in config.h to make this sort of thing work. That is not yet the case for simdzone. In the upcoming release I'll update the simdzone config header (or build files appropriately).
For now, if someone really wants to get 4.10 to compile using the package, _DEFAULT_SOURCE needs to be defined. Adding -D_DEFAULT_SOURCE is the obvious way to do it. (at least on my Fedora system, I'm assuming it's the same for Debian).
endian.c:
#include <stdint.h>
#include <endian.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
  uint32_t x = 0;
  uint32_t y = htobe32(x);
  printf("x: %u, y: %u\n", x, y);
  return 0;
}
Hi @jas4711, we released 4.10.1rc2 a couple of days ago. Can you confirm the package is build ok? If there's still build issues it'd be good to tackle them before the final release of 4.10.1.
Thanks for ping @k0ekk0ek -- I have tried building 4.10.1rc2 using the Debian build framework, and it builds fine now, even with  -D_XOPEN_SOURCE=600  that the Debian build framework add for some reason unknown to me.   Is that flag something you recommend for or recommend against?  It has been like that since the beginning in Debian.  I just tried building without the flag, and the build went fine, so I'm inclined to drop it unless we understand why it is needed.
That's good to hear. To my knowledge we never actively advised setting it but it might have been required at some point. It is a flag that we always set in config.h (configure.ac:1196) if not defined, at this point in time the two match. I think it's better to not set it, but there's currently no downside either. I'll close this issue, but be sure to let us know if issues pop-up again.
FWIW, I've uploaded 4.10.1rc2 to Debian experimental and builds are looking good:
https://buildd.debian.org/status/package.php?p=nsd&suite=experimental
I dropped the manual -D_XOPEN_SOURCE=600 specifier, letting the defaults come into play.
Thanks @jas4711 :+1: