On Tue, Jan 17, 2017 at 12:36:08PM +1300, Evan Hanson wrote:
> > Attached is a modified version of the patch which sets _XOPEN_SOURCE
> > to 700, which unlocks SUSv4 / POSIX.1-2008 support.  I've tested this
> > and an added benefit is that setting it to 700 also makes a warning
> > about "implicit declaration of function nanosleep()" go away on GNU
> > Hurd.
> 
> Looks good to me. That seems to be what's expected anyway, a value
> rather than just the definition.
> 
> > I've tested it on MingW, Cygwin, Hurd and Linux.
> 
> Linux, OpenBSD, MinGW-w64, Cygwin, MSYS2.
> 

Looks like FreeBSD doesn't like this one bit.  The Salmonella builds
have started to fail completely:
http://salmonella-freebsd-x86-64.call-cc.org/master/clang/freebsd/x86-64/2017/01/16/

Attached patch introduces a new knob to tune: C_USE_STD_FEATURE_MACROS,
which is currently unconditionally defined in all platform Makefiles,
except for BSD, where it's enabled for all but FreeBSD.  Apparently
they believe feature macros should not behave like they do on Linux,
whereas on NetBSD and OpenBSD it behaves the same.

I haven't tested a lot of platforms, but this shouldn't really change
anything except on FreeBSD anyway... (haha, famous last words)

Cheers,
Peter
From be22cc22e4c9416667eb6cc297456c793845c238 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Tue, 17 Jan 2017 21:47:11 +0100
Subject: [PATCH] Do not use feature macros on FreeBSD.

According to this post on the "freebsd-standards" mailing list, FreeBSD
discourages using feature macros to enable features.  It takes a very
strict approach and disables all other features, including "native"
standard BSD functions when you enable a specific standard.  There is
no way to re-enable the BSD functions (not even via _BSD_SOURCE).

https://lists.freebsd.org/pipermail/freebsd-standards/2004-March/000474.html

Conflicts:
	Makefile.aix
	Makefile.android
	Makefile.bsd
	Makefile.cross-linux-mingw
	Makefile.cygwin
	Makefile.haiku
	Makefile.hurd
	Makefile.ios
	Makefile.linux
	Makefile.macosx
	Makefile.mingw
	Makefile.mingw-msys
---
 Makefile.aix               |  1 +
 Makefile.android           |  1 +
 Makefile.bsd               |  4 ++++
 Makefile.cross-linux-mingw |  1 +
 Makefile.cygwin            |  1 +
 Makefile.haiku             |  1 +
 Makefile.hurd              |  1 +
 Makefile.ios               |  1 +
 Makefile.linux             |  1 +
 Makefile.macosx            |  1 +
 Makefile.mingw             |  1 +
 Makefile.mingw-msys        |  1 +
 chicken.h                  | 29 +++++++++++++++++------------
 13 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/Makefile.aix b/Makefile.aix
index 2d203ed..5d0b73e 100644
--- a/Makefile.aix
+++ b/Makefile.aix
@@ -97,6 +97,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.android b/Makefile.android
index d0c677e..792fe6c 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -91,6 +91,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.bsd b/Makefile.bsd
index b4a47d0..6fbc207 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -97,6 +97,10 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+# Of the BSDs, only FreeBSD hates composable feature macros...
+	echo "#ifndef __FreeBSD__" >> $@
+	echo "# define C_USE_STD_FEATURE_MACROS" >> $@
+	echo "#endif" >> $@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.cross-linux-mingw b/Makefile.cross-linux-mingw
index 488d41b..ba7dd4b 100644
--- a/Makefile.cross-linux-mingw
+++ b/Makefile.cross-linux-mingw
@@ -114,6 +114,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)rules.make
diff --git a/Makefile.cygwin b/Makefile.cygwin
index 161a31f..7e8781b 100644
--- a/Makefile.cygwin
+++ b/Makefile.cygwin
@@ -111,6 +111,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.haiku b/Makefile.haiku
index 7fe7576..154ef43 100644
--- a/Makefile.haiku
+++ b/Makefile.haiku
@@ -91,6 +91,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.hurd b/Makefile.hurd
index a0ebff4..dadfc00 100644
--- a/Makefile.hurd
+++ b/Makefile.hurd
@@ -92,6 +92,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.ios b/Makefile.ios
index 9f46064..fb35ac3 100644
--- a/Makefile.ios
+++ b/Makefile.ios
@@ -95,6 +95,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.linux b/Makefile.linux
index 7c0bc2a..864dc42 100644
--- a/Makefile.linux
+++ b/Makefile.linux
@@ -99,6 +99,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.macosx b/Makefile.macosx
index f89669b..062335b 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -120,6 +120,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.mingw b/Makefile.mingw
index 87143b7..329386d 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -101,6 +101,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo #define C_GC_HOOKS >>$@
 endif
+	echo #define C_USE_STD_FEATURE_MACROS >>$@
 	type chicken-defaults.h >>$@
 
 include $(SRCDIR)rules.make
diff --git a/Makefile.mingw-msys b/Makefile.mingw-msys
index e6aa403..4c3fbb7 100644
--- a/Makefile.mingw-msys
+++ b/Makefile.mingw-msys
@@ -106,6 +106,7 @@ chicken-config.h: chicken-defaults.h
 ifdef GCHOOKS
 	echo "#define C_GC_HOOKS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/chicken.h b/chicken.h
index fed1a4a..4acacee 100644
--- a/chicken.h
+++ b/chicken.h
@@ -41,24 +41,29 @@
 # define __C99FEATURES__
 #endif
 
-#ifndef _XOPEN_SOURCE
-# define _XOPEN_SOURCE 700
-#endif
+/* Some OSes really dislike feature macros for standard levels */
+#ifdef C_USE_STD_FEATURE_MACROS
 
-#ifndef _BSD_SOURCE
-# define _BSD_SOURCE
-#endif
+# ifndef _XOPEN_SOURCE
+#  define _XOPEN_SOURCE 700
+# endif
 
-#ifndef _SVID_SOURCE
-# define _SVID_SOURCE
-#endif
+# ifndef _BSD_SOURCE
+#  define _BSD_SOURCE
+# endif
+
+# ifndef _SVID_SOURCE
+#  define _SVID_SOURCE
+# endif
 
 /*
  * glibc >= 2.20 synonym for _BSD_SOURCE & _SVID_SOURCE.
  */
-#ifndef _DEFAULT_SOURCE
-# define _DEFAULT_SOURCE
-#endif
+# ifndef _DEFAULT_SOURCE
+#  define _DEFAULT_SOURCE
+# endif
+
+#endif /* C_USE_STD_FEATURE_MACROS */
 
 /*
  * N.B. This file MUST not rely upon "chicken-config.h"
-- 
2.1.4

From 2732296e67c46327e5239c4c57159be41808f0e7 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Tue, 17 Jan 2017 20:57:11 +0100
Subject: [PATCH] Do not use feature macros on FreeBSD.

According to this post on the "freebsd-standards" mailing list, FreeBSD
discourages using feature macros to enable features.  It takes a very
strict approach and disables all other features, including "native"
standard BSD functions when you enable a specific standard.  There is
no way to re-enable the BSD functions (not even via _BSD_SOURCE).

https://lists.freebsd.org/pipermail/freebsd-standards/2004-March/000474.html
---
 Makefile.aix               |  1 +
 Makefile.android           |  1 +
 Makefile.bsd               |  4 ++++
 Makefile.cross-linux-mingw |  1 +
 Makefile.cygwin            |  1 +
 Makefile.haiku             |  1 +
 Makefile.hurd              |  1 +
 Makefile.ios               |  1 +
 Makefile.linux             |  1 +
 Makefile.macosx            |  1 +
 Makefile.mingw             |  1 +
 Makefile.mingw-msys        |  1 +
 chicken.h                  | 29 +++++++++++++++++------------
 13 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/Makefile.aix b/Makefile.aix
index 3a2b6c0..9ff8e01 100644
--- a/Makefile.aix
+++ b/Makefile.aix
@@ -101,6 +101,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.android b/Makefile.android
index 8350ca7..1ce8ac6 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -95,6 +95,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.bsd b/Makefile.bsd
index 02b5131..646ec66 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -101,6 +101,10 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+# Of the BSDs, only FreeBSD hates composable feature macros...
+	echo "#ifndef __FreeBSD__" >> $@
+	echo "# define C_USE_STD_FEATURE_MACROS" >> $@
+	echo "#endif" >> $@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.cross-linux-mingw b/Makefile.cross-linux-mingw
index 338adfd..9b52ec1 100644
--- a/Makefile.cross-linux-mingw
+++ b/Makefile.cross-linux-mingw
@@ -117,6 +117,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)rules.make
diff --git a/Makefile.cygwin b/Makefile.cygwin
index 54c589d..58fb7c8 100644
--- a/Makefile.cygwin
+++ b/Makefile.cygwin
@@ -115,6 +115,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.haiku b/Makefile.haiku
index 3120f30..dc54aa6 100644
--- a/Makefile.haiku
+++ b/Makefile.haiku
@@ -95,6 +95,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.hurd b/Makefile.hurd
index 696fbcb..9bb6d6f 100644
--- a/Makefile.hurd
+++ b/Makefile.hurd
@@ -96,6 +96,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.ios b/Makefile.ios
index 54b88b3..0be2120 100644
--- a/Makefile.ios
+++ b/Makefile.ios
@@ -99,6 +99,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.linux b/Makefile.linux
index aa0a771..f9dd52c 100644
--- a/Makefile.linux
+++ b/Makefile.linux
@@ -103,6 +103,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.macosx b/Makefile.macosx
index 6cf4f04..91634d8 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -124,6 +124,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/Makefile.mingw b/Makefile.mingw
index c249f45..5629fde 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -104,6 +104,7 @@ endif
 ifdef SYMBOLGC
 	echo #define C_COLLECT_ALL_SYMBOLS >>$@
 endif
+	echo #define C_USE_STD_FEATURE_MACROS >>$@
 	type chicken-defaults.h >>$@
 
 include $(SRCDIR)rules.make
diff --git a/Makefile.mingw-msys b/Makefile.mingw-msys
index 5b2aab9..eaeaaf6 100644
--- a/Makefile.mingw-msys
+++ b/Makefile.mingw-msys
@@ -109,6 +109,7 @@ endif
 ifdef SYMBOLGC
 	echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
 endif
+	echo "#define C_USE_STD_FEATURE_MACROS" >>$@
 	cat chicken-defaults.h >>$@
 
 include $(SRCDIR)/rules.make
diff --git a/chicken.h b/chicken.h
index efb9511..5c20f63 100644
--- a/chicken.h
+++ b/chicken.h
@@ -47,24 +47,29 @@
 # define __C99FEATURES__
 #endif
 
-#ifndef _XOPEN_SOURCE
-# define _XOPEN_SOURCE 700
-#endif
+/* Some OSes really dislike feature macros for standard levels */
+#ifdef C_USE_STD_FEATURE_MACROS
 
-#ifndef _BSD_SOURCE
-# define _BSD_SOURCE
-#endif
+# ifndef _XOPEN_SOURCE
+#  define _XOPEN_SOURCE 700
+# endif
 
-#ifndef _SVID_SOURCE
-# define _SVID_SOURCE
-#endif
+# ifndef _BSD_SOURCE
+#  define _BSD_SOURCE
+# endif
+
+# ifndef _SVID_SOURCE
+#  define _SVID_SOURCE
+# endif
 
 /*
  * glibc >= 2.20 synonym for _BSD_SOURCE & _SVID_SOURCE.
  */
-#ifndef _DEFAULT_SOURCE
-# define _DEFAULT_SOURCE
-#endif
+# ifndef _DEFAULT_SOURCE
+#  define _DEFAULT_SOURCE
+# endif
+
+#endif /* C_USE_STD_FEATURE_MACROS */
 
 /*
  * N.B. This file MUST not rely upon "chicken-config.h"
-- 
2.1.4

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to