With latest (Mon Feb 29 17:18:06 PST 2016) code, building tools to reflect latest regexp work to libnbcompat:
# compile compat/regsub.lo cc -O -I. -I./include -I/usr/src/tools/compat -I/usr/src/tools/compat/sys -DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D__DBINTERFACE_PRIVATE -c -o regsub.lo.o /usr/src/tools/compat/../../lib/libc/regex/regsub.c In file included from ./nbtool_config.h:720:0, from /usr/src/tools/compat/regex.h:3, from /usr/src/tools/compat/../../lib/libc/regex/regsub.c:40: /usr/src/tools/compat/compat_defs.h:72:2: error: #error _NETBSD_SOURCE is *not* to be defined. #error _NETBSD_SOURCE is *not* to be defined. ^ In file included from ./nbtool_config.h:720:0, from /usr/src/tools/compat/regex.h:3, from /usr/src/tools/compat/../../lib/libc/regex/regsub.c:40: /usr/src/tools/compat/compat_defs.h:257:8: error: redefinition of 'struct _dirdesc' struct _dirdesc { ^ In file included from /usr/src/tools/compat/compat_defs.h:169:0, from ./nbtool_config.h:720, from /usr/src/tools/compat/regex.h:3, from /usr/src/tools/compat/../../lib/libc/regex/regsub.c:40: /usr/include/dirent.h:50:16: note: originally defined here typedef struct _dirdesc DIR; ^ In file included from ./nbtool_config.h:720:0, from /usr/src/tools/compat/regex.h:3, from /usr/src/tools/compat/../../lib/libc/regex/regsub.c:40: /usr/src/tools/compat/compat_defs.h:268:0: warning: "dirfd" redefined [enabled by default] #define dirfd(dirp) (((struct _dirdesc *)dirp)->dd_fd) ^ In file included from /usr/src/tools/compat/compat_defs.h:169:0, from ./nbtool_config.h:720, from /usr/src/tools/compat/regex.h:3, from /usr/src/tools/compat/../../lib/libc/regex/regsub.c:40: /usr/include/dirent.h:76:0: note: this is the location of the previous definition #define dirfd(dirp) ((dirp)->dd_fd) ^ [...]