I attempted to fix the problem by installing the attached patch into gnulib master. I can't easily test this, though, as I don't have macOS. Can you please try running the following shell commands on a macOS host, and see whether the last one succeeds? You'll need the autotools installed. Thanks.

git clone git://git.savannah.gnu.org/gnulib.git
cd gnulib
./gnulib-tool --test sched

From b1941d8e4f00a6dd8a0d12c5027499b7e0641a9a Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 24 Sep 2016 21:10:12 -0700
Subject: [PATCH] sched: port to GCC 6.2.1 on macOS Sierra
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Denis Davydov in:
http://lists.gnu.org/archive/html/bug-gnulib/2016-09/msg00056.html
* lib/sched.in.h [HAVE_SYS_CDEFS_H]:
Include <sys/cdefs.h> before <sched.h>.
* m4/nproc.m4 (gl_PREREQ_NPROC): Include errno.h before sched.h,
so that we needn’t worry about the sched.h include bug here.
* m4/sched_h.m4 (gl_SCHED_H): Check for sys/cdefs.h,
and include it before <sched.h> if it exists, when
checking for <sched.h>.
---
 ChangeLog      | 11 +++++++++++
 lib/sched.in.h |  5 ++++-
 m4/nproc.m4    |  5 +++--
 m4/sched_h.m4  | 19 ++++++++++++++-----
 4 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b006ef0..d929818 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2016-09-24  Paul Eggert  <egg...@cs.ucla.edu>
 
+       sched: port to GCC 6.2.1 on macOS Sierra
+       Problem reported by Denis Davydov in:
+       http://lists.gnu.org/archive/html/bug-gnulib/2016-09/msg00056.html
+       * lib/sched.in.h [HAVE_SYS_CDEFS_H]:
+       Include <sys/cdefs.h> before <sched.h>.
+       * m4/nproc.m4 (gl_PREREQ_NPROC): Include errno.h before sched.h,
+       so that we needn’t worry about the sched.h include bug here.
+       * m4/sched_h.m4 (gl_SCHED_H): Check for sys/cdefs.h,
+       and include it before <sched.h> if it exists, when
+       checking for <sched.h>.
+
        tests/init.sh: port Alpine fix to AIX 7.1
        * tests/init.sh (compare_): When attempting to use diff -U3,
        prefer diff -u to -U3 to -c to plain diff.  Do not insist on
diff --git a/lib/sched.in.h b/lib/sched.in.h
index 1c0fe59..63ac5bd 100644
--- a/lib/sched.in.h
+++ b/lib/sched.in.h
@@ -1,4 +1,4 @@
-/* Replacement <sched.h> for platforms that lack it.
+/* A GNU-like <sched.h>.
    Copyright (C) 2008-2016 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -23,6 +23,9 @@
 
 /* The include_next requires a split double-inclusion guard.  */
 #if @HAVE_SCHED_H@
+# if @HAVE_SYS_CDEFS_H@
+#  include <sys/cdefs.h>
+# endif
 # @INCLUDE_NEXT@ @NEXT_SCHED_H@
 #endif
 
diff --git a/m4/nproc.m4 b/m4/nproc.m4
index fead234..f38591b 100644
--- a/m4/nproc.m4
+++ b/m4/nproc.m4
@@ -1,4 +1,4 @@
-# nproc.m4 serial 4
+# nproc.m4 serial 5
 dnl Copyright (C) 2009-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -40,7 +40,8 @@ AC_DEFUN([gl_PREREQ_NPROC],
       [gl_cv_func_sched_getaffinity3],
       [AC_COMPILE_IFELSE(
          [AC_LANG_PROGRAM(
-            [[#include <sched.h>]],
+            [[#include <errno.h>
+              #include <sched.h>]],
             [[sched_getaffinity (0, 0, (cpu_set_t *) 0);]])],
          [gl_cv_func_sched_getaffinity3=yes],
          [gl_cv_func_sched_getaffinity3=no])
diff --git a/m4/sched_h.m4 b/m4/sched_h.m4
index f564541..7192b63 100644
--- a/m4/sched_h.m4
+++ b/m4/sched_h.m4
@@ -1,4 +1,4 @@
-# sched_h.m4 serial 7
+# sched_h.m4 serial 8
 dnl Copyright (C) 2008-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,7 @@ dnl Written by Bruno Haible.
 
 AC_DEFUN([gl_SCHED_H],
 [
+  AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
   AC_COMPILE_IFELSE(
     [AC_LANG_PROGRAM([[
        #include <sched.h>
@@ -17,10 +18,14 @@ AC_DEFUN([gl_SCHED_H],
      ]])],
     [SCHED_H=''],
     [SCHED_H='sched.h'
+     AC_CHECK_HEADERS([sched.h], [], [],
+       [[#if HAVE_SYS_CDEFS_H
+          #include <sys/cdefs.h>
+         #endif
+       ]])
+     gl_NEXT_HEADERS([sched.h])
 
-     gl_CHECK_NEXT_HEADERS([sched.h])
-
-     if test $ac_cv_header_sched_h = yes; then
+     if test "$ac_cv_header_sched_h" = yes; then
        HAVE_SCHED_H=1
      else
        HAVE_SCHED_H=0
@@ -30,7 +35,11 @@ AC_DEFUN([gl_SCHED_H],
      if test "$HAVE_SCHED_H" = 1; then
        AC_CHECK_TYPE([struct sched_param],
          [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0],
-         [#include <sched.h>])
+         [[#if HAVE_SYS_CDEFS_H
+            #include <sys/cdefs.h>
+           #endif
+           #include <sched.h>
+         ]])
      else
        dnl On OS/2 kLIBC, struct sched_param is in spawn.h.
        AC_CHECK_TYPE([struct sched_param],
-- 
2.7.4

Reply via email to