ref: 349cc97c6df60120c9fa5b92cdbac684e23ed956
parent: 3215bc0570aebff6068ee2b05cef9f540a81491a
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Sep 15 02:49:59 EDT 2021
build: Add fixes for NetBSD NetBSD needs the same hack for ARFLAGS that OpenBSD. Ideally we should submit a patch for NetBSD to solve this issue because it has a good support for .POSIX. This patch also adds a temporary hack to solve a problem in NetBSD when POSIX_C_SOURCE and _ANSI_SOURCE are defined at the same time. A patch was submited to NetBSD and this hack is expected to be removed in a future.
--- a/scripts/config
+++ b/scripts/config
@@ -4,6 +4,10 @@
OpenBSD)
echo TOOL=${TOOL:-clang} HOST=bsd ARFLAGS=${ARFLAGS:--rv}
;;
+NetBSD)
+ #TODO: send a patch to NetBSD to solve this problem
+ echo HOST=bsd ARFLAGS=${ARFLAGS:--rv}
+ ;;
*BSD)
echo HOST=bsd
;;
--- a/src/cmd/cc/posix/cc.c
+++ b/src/cmd/cc/posix/cc.c
@@ -1,4 +1,15 @@
-#define _POSIX_SOURCE 200809L
+/*
+ * FIXME: scc is a pure C99 source code, except this file that is
+ * intended for a POSIX.2008 environment. This situation creates
+ * a problem where some systems require the macro _ANSI_SOURCE to
+ * limit the namespace to a pure ISO namespace. NetBSD has a bug
+ * and using POSIX_C_SOURCE and _ANSI_SOURCE at the same time
+ * generates a syntax error in the system headers. A patch was
+ * sent to NetBSD, but this temporary fix is added here until the
+ * patch arrives to the stable release.
+ */
+#define _POSIX_C_SOURCE 200809L
+#undef _ANSI_SOURCE
#include <sys/types.h>
#include <sys/wait.h>