Bug 243387

Summary: dns/bind-tools: Fails to build with devel/jsoncpp installed: son/config.h:8:10: fatal error: 'cstddef' file not found
Product: Ports & Packages Reporter: Андрей <dron>
Component: Individual Port(s)Assignee: Mathieu Arnold <mat>
Status: Closed FIXED    
Severity: Affects Some People CC: rob215x
Priority: --- Keywords: needs-qa
Version: LatestFlags: bugzilla: maintainer-feedback? (mat)
Hardware: Any   
OS: Any   
URL: https://gitlab.isc.org/isc-projects/bind9/issues/1570
Attachments:
Description Flags
Patch for bind-9.14.9 configure
none
dns/bind914 patch none

Description Андрей 2020-01-16 11:11:05 UTC
Created attachment 210789 [details]
Patch for bind-9.14.9 configure

Build fail for dns/bind-tools (or another ports based on isc-bind9) if devel/jsoncpp installed.

root@FreeBSD-12:/usr/ports/dns/bind-tools # make
===>  Building for bind-tools-9.14.9
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/include
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/include/isc
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/include/pk11
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/include/pkcs11
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix/include
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix/include/isc
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix/include/pkcs11
cc  -I/usr/ports/dns/bind-tools/work/bind-9.14.9 -I../../.. -I./include  -I./../pthreads/include  -I../include  -I./../include  -I./.. -I/usr/include   -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -DDIG_SIGCHASE=1 -O2 -pipe  -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -pthread -I/usr/local/include/libxml2 -I/usr/include -I/usr/local/include  -fPIC   -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -fno-strict-aliasing -fno-delete-null-pointer-checks  -c pk11_api.c
In file included from pk11_api.c:21:
In file included from ../include/isc/mem.h:20:
In file included from ../include/isc/json.h:36:
In file included from /usr/local/include/json/json.h:9:
In file included from /usr/local/include/json/autolink.h:9:
/usr/local/include/json/config.h:8:10: fatal error: 'cstddef' file not found
#include <cstddef>
         ^~~~~~~~~
1 error generated.
*** Error code 1

Stop.
make[5]: stopped in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix
*** Error code 1

Stop.
make[4]: stopped in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/dns/bind-tools/work/bind-9.14.9
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/dns/bind-tools
*** Error code 1

Stop.
make: stopped in /usr/ports/dns/bind-tools
root@FreeBSD-12:/usr/ports/dns/bind-tools #
Comment 1 Mathieu Arnold freebsd_committer freebsd_triage 2020-01-17 10:08:12 UTC
Created attachment 210817 [details]
dns/bind914 patch

Can you try the attached patch instead?
Comment 2 Андрей 2020-01-17 11:33:33 UTC
Sorry, the attached patch doesn't work for me.

I can build a port with these changes:

root@FreeBSD-12:/usr/ports/dns/bind-tools# diff -u /usr/ports/dns/bind914/Makefile.orig /usr/ports/dns/bind914/Makefile
--- /usr/ports/dns/bind914/Makefile.orig        2020-01-17 13:47:07.252870000 +0300
+++ /usr/ports/dns/bind914/Makefile     2020-01-17 14:20:29.559705000 +0300
@@ -165,6 +165,7 @@
 IDN_USES=              iconv

 JSON_CONFIGURE_WITH=   libjson=${LOCALBASE}
+JSON_CFLAGS+=          -DHAVE_JSON_C=1
 JSON_LIB_DEPENDS=      libjson-c.so:devel/json-c

 LARGE_FILE_CONFIGURE_ENABLE=   largefile
Comment 3 Mathieu Arnold freebsd_committer freebsd_triage 2020-01-17 13:08:00 UTC
Sorry, maybe I misunderstood, is the build failing when the JSON option is enable, or when it is disabled?
Comment 4 Андрей 2020-01-17 15:23:55 UTC
Build fail when JSON option is enable. If JSON option is disable port build without error.

Steps to repeat the error:
1. Clean install FreeBSD 12.1 release.
# uname -a
FreeBSD FreeBSD-12.1 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC  amd64

2. Install and update ports tree via portsnap.
# portsnap fetch extract update

3. Install devel/jsoncpp
# cd /usr/ports/devel/jsoncpp
# make install

4. Building /usr/ports/dns/bind-tools with default options gives an error:
# cd /usr/ports/dns/bind-tools
# make
===>  Building for bind-tools-9.14.9

...skiped

making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix/include
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix/include/isc
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix/include/pkcs11
cc  -I/usr/ports/dns/bind-tools/work/bind-9.14.9 -I../../.. -I./include  -I./../pthreads/include  -I../include  -I./../include  -I./.. -I/usr/include   -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -DDIG_SIGCHASE=1 -O2 -pipe  -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -pthread -I/usr/local/include/libxml2 -I/usr/include -I/usr/local/include  -fPIC   -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -fno-strict-aliasing -fno-delete-null-pointer-checks  -c pk11_api.c
In file included from pk11_api.c:21:
In file included from ../include/isc/mem.h:20:
In file included from ../include/isc/json.h:36:
In file included from /usr/local/include/json/json.h:9:
In file included from /usr/local/include/json/autolink.h:9:
/usr/local/include/json/config.h:8:10: fatal error: 'cstddef' file not found
#include <cstddef>
         ^~~~~~~~~
1 error generated.
*** Error code 1

Stop.
make[5]: stopped in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix
*** Error code 1

5. If I define CFLAGS="-DHAVE_JSON_C=1" in make.conf or /usr/ports/dns/bind-9.14.9/Makefile, port will be build correctly.

PS: Location of includes files in jsoncpp changed for version 1.9.2:
 # pkg-config jsoncpp --modversion
 1.9.2
 # pkg-config jsoncpp --cflags
 -I/usr/local/include

 In preverios version:
 # pkg-config jsoncpp --modversion
 1.8.1
 # pkg-config jsoncpp --cflags
 -I/usr/local/include/jsoncpp

and now configure/configure.in script of isc-bind ports incorrect detect json-c in section:

case "$use_libjson" in
        no)
                libjson_libs=""
                ;;
        auto|yes)
                for d in /usr /usr/local /opt/local
                do
                        if test -f "${d}/include/json/json.h"
                        then
                                if test ${d} != /usr
                                then
                                        libjson_cflags="-I ${d}/include"
                                        LIBS="$LIBS -L${d}/lib"
                                fi
                                have_libjson="yes"
                        elif test -f "${d}/include/json-c/json.h"
                        then
                                if test ${d} != /usr
                                then
                                        libjson_cflags="-I ${d}/include"
                                        LIBS="$LIBS -L${d}/lib"
                                fi
                                have_libjson="yes"
                                have_libjson_c="yes"
                        fi
                done
                ;;
        *)
                if test -f "${use_libjson}/include/json/json.h"
                then
                        libjson_cflags="-I${use_libjson}/include"
                        LIBS="$LIBS -L${use_libjson}/lib"
                        have_libjson="yes"
                elif test -f "${use_libjson}/include/json-c/json.h"
                then
                        libjson_cflags="-I${use_libjson}/include"
                        LIBS="$LIBS -L${use_libjson}/lib"
                        have_libjson="yes"
                        have_libjson_c="yes"
                else
                        AC_MSG_ERROR([$use_libjson/include/json{,-c}/json.h not found.])
                fi
                ;;
esac

because exist /usr/local/include/json/json.h file, but it c++ header from jsoncpp and it can not be use in c project.
Comment 5 Rob215x 2020-01-18 05:11:03 UTC
I just tried the following:

# cd /usr/ports/dns/bind-tools
# make config

Unchecked JSON option

# make test
===>  Building for bind-tools-9.14.9
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/include
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/include/isc
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/include/pk11
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/include/pkcs11
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix/include
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix/include/isc
making all in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix/include/pkcs11
cc  -I/usr/ports/dns/bind-tools/work/bind-9.14.9 -I../../.. -I./include  -I./../pthreads/include  -I../include  -I./../include  -I./.. -I/usr/include   -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -DDIG_SIGCHASE=1 -O2 -pipe  -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -pthread -I/usr/local/include/libxml2 -I/usr/include -I/usr/local/include  -fPIC   -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -fno-strict-aliasing -fno-delete-null-pointer-checks  -c pk11_api.c
In file included from pk11_api.c:21:
In file included from ../include/isc/mem.h:20:
In file included from ../include/isc/json.h:36:
In file included from /usr/local/include/json/json.h:9:
In file included from /usr/local/include/json/autolink.h:9:
/usr/local/include/json/config.h:8:10: fatal error: 'cstddef' file not found
#include <cstddef>
         ^~~~~~~~~
1 error generated.
*** Error code 1

Stop.
make[5]: stopped in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc/unix
*** Error code 1

Stop.
make[4]: stopped in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib/isc
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/dns/bind-tools/work/bind-9.14.9/lib
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/dns/bind-tools/work/bind-9.14.9
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/dns/bind-tools
*** Error code 1

Stop.
make: stopped in /usr/ports/dns/bind-tools
Comment 6 Rob215x 2020-01-18 05:57:49 UTC
Okay, I just rebooted the server and bind-tools DOES install with the JSON option unchecked. 

Also, my server info:

FreeBSD 11.3-RELEASE-p5 FreeBSD 11.3-RELEASE-p5 #0: Tue Nov 12 08:59:04 UTC 2019      amd64
Comment 7 Mathieu Arnold freebsd_committer freebsd_triage 2020-01-20 12:41:20 UTC
So, rummaging through all this, the answer to my question is "it fails when the JSON option is enabled", right ?
Comment 8 commit-hook freebsd_committer freebsd_triage 2020-01-20 14:48:20 UTC
A commit references this bug:

Author: mat
Date: Mon Jan 20 14:48:04 UTC 2020
New revision: 523626
URL: https://svnweb.freebsd.org/changeset/ports/523626

Log:
  Fix build when devel/jsoncpp is installed.

  PR:		243387
  Submitted by:	dron kubstu ru

Changes:
  head/dns/bind911/files/patch-configure
  head/dns/bind914/files/patch-configure