unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Zack Weinberg <zackw@panix.com>
Cc: Gnulib bugs <bug-gnulib@gnu.org>,
	26398-done@debbugs.gnu.org, Harald Maier <Harald@Maierh.de>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: bug#26398: GNU LIB build fails on macOS 10.12.4
Date: Sun, 9 Apr 2017 01:03:30 -0700	[thread overview]
Message-ID: <d936c05c-adba-3e62-69b2-ba9b8da8ed16__29587.7516888597$1491725055$gmane$org@cs.ucla.edu> (raw)
In-Reply-To: <CAKCAbMis9L+_1=JukqJT4N9AKePvUHBSttyb03pCbXSLj5gLig@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1703 bytes --]

Zack Weinberg wrote:

> This patch is incomplete.

Yes, it was the Emacs patch, not the Gnulib patch. I'll attach a complete Gnulib 
patch.

> If gnulib cannot use __nonnull in
> getopt_{core,ext}.h, then there is no point trying to define it in
> getopt_cdefs.h.

Good point, I've removed that in the attached.

> And you're going to need to put snippet/arg-nonnull
> back in the module file for this to work at all, aren't you?

Yes, that's in the attached patch.

> From glibc's point of view, I think it would be better if
> getopt_core.h and getopt_ext.h simply assumed _GL_ARG_NONNULL to be
> available; we can add it to either our getopt.h wrapper or to
> sys/cdefs.h - I don't want to make that call unilaterally.

By "our getopt.h wrapper" do you mean a file in glibc but not in Gnulib? If so, 
this doesn't affect Gnulib. I suspect _GL_ARG_NONNULL logically belongs in 
sys/cdefs.h but it should also work to put it into the getopt.h wrapper.

> (Do you
> know of a complete list of _GL_ macros that may appear in _public_
> header files?)

I don't know of an explicit list. You can look at all the .h files listed in the 
Files: sections of gnulib/modules/snippet/*. For example, the 
snippet/arg-nonnull module defines _GL_ARG_NONNULL, the snippet/_Noreturn module 
defines _Noreturn, and so forth. There are quite a few such macros, and (as 
_Noreturn indicates) they don't all begin with _GL_.

I installed the attached into Gnulib and merged it into Emacs, and am boldly 
marking the Emacs bug (Bug#26398) as done. I think there still needs to be some 
changes done on the proposed change to glibc, to define _GL_ARG_NONNULL 
somewhere for glibc.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-getopt-port-recent-getopt-changes-to-macOS.patch --]
[-- Type: text/x-diff; name="0001-getopt-port-recent-getopt-changes-to-macOS.patch", Size: 5591 bytes --]

From 141be0d810330ceec66ce3fab46aaeb4c633bd7e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 8 Apr 2017 17:26:03 -0700
Subject: [PATCH] getopt: port recent getopt changes to macOS

Problem reported by Harald Maier (Bug#26398).
The macOS C compiler uses __nonnull for its own purposes and that
clashes with glibc's __nonnull.
* lib/getopt.in.h: Add comment for _GL_ARG_NONNULL snippet.
* lib/getopt_cdefs.in.h (__nonnull): Remove.
* lib/getopt_core.h (getopt):
* lib/getopt_ext.h (getopt_long, getopt_long_only):
Use _GL_ARG_NONNULL, not __nonnull.
* lib/unistd.in.h: Move snippet hooks to before where the getopt
.h files are included, so that _GL_ARG_NONNULL is defined in time.
* modules/getopt-posix (Depends-on): Add snippet/arg-nonnull.
(getopt.h): Interpolate _GL_ARG_NONNULL snippet.
---
 ChangeLog             | 16 ++++++++++++++++
 lib/getopt.in.h       |  2 ++
 lib/getopt_cdefs.in.h |  8 --------
 lib/getopt_core.h     |  2 +-
 lib/getopt_ext.h      |  4 ++--
 lib/unistd.in.h       | 14 +++++++-------
 modules/getopt-posix  |  2 ++
 7 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index db893f5..595f2ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2017-04-08  Paul Eggert  <eggert@cs.ucla.edu>
+
+	getopt: port recent getopt changes to macOS
+	Problem reported by Harald Maier (Bug#26398).
+	The macOS C compiler uses __nonnull for its own purposes and that
+	clashes with glibc's __nonnull.
+	* lib/getopt.in.h: Add comment for _GL_ARG_NONNULL snippet.
+	* lib/getopt_cdefs.in.h (__nonnull): Remove.
+	* lib/getopt_core.h (getopt):
+	* lib/getopt_ext.h (getopt_long, getopt_long_only):
+	Use _GL_ARG_NONNULL, not __nonnull.
+	* lib/unistd.in.h: Move snippet hooks to before where the getopt
+	.h files are included, so that _GL_ARG_NONNULL is defined in time.
+	* modules/getopt-posix (Depends-on): Add snippet/arg-nonnull.
+	(getopt.h): Interpolate _GL_ARG_NONNULL snippet.
+
 2017-04-06  Paul Eggert  <eggert@cs.ucla.edu>
 
 	getopt-gnu: omit some duplicate code
diff --git a/lib/getopt.in.h b/lib/getopt.in.h
index c3ffd95..9f84c27 100644
--- a/lib/getopt.in.h
+++ b/lib/getopt.in.h
@@ -52,6 +52,8 @@
 # endif
 #endif
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 #include <getopt_cdefs.h>
 #include <getopt_pfx_core.h>
 #include <getopt_pfx_ext.h>
diff --git a/lib/getopt_cdefs.in.h b/lib/getopt_cdefs.in.h
index 35a2669..54da28d 100644
--- a/lib/getopt_cdefs.in.h
+++ b/lib/getopt_cdefs.in.h
@@ -64,12 +64,4 @@
 # endif
 #endif
 
-#ifndef __nonnull
-# if __GNUC_PREREQ (3,3)
-#  define __nonnull(params) __attribute__ ((__nonnull__ params))
-# else
-#  define __nonnull(params)
-# endif
-#endif
-
 #endif /* getopt_cdefs.h */
diff --git a/lib/getopt_core.h b/lib/getopt_core.h
index 1744c29..76ef466 100644
--- a/lib/getopt_core.h
+++ b/lib/getopt_core.h
@@ -89,7 +89,7 @@ extern int optopt;
    writable.  */
 
 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
-       __THROW __nonnull ((2, 3));
+       __THROW _GL_ARG_NONNULL ((2, 3));
 
 __END_DECLS
 
diff --git a/lib/getopt_ext.h b/lib/getopt_ext.h
index c1a58da..a3a6750 100644
--- a/lib/getopt_ext.h
+++ b/lib/getopt_ext.h
@@ -66,11 +66,11 @@ struct option
 extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
 			const char *__shortopts,
 		        const struct option *__longopts, int *__longind)
-       __THROW __nonnull ((2, 3));
+       __THROW _GL_ARG_NONNULL ((2, 3));
 extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
 			     const char *__shortopts,
 		             const struct option *__longopts, int *__longind)
-       __THROW __nonnull ((2, 3));
+       __THROW _GL_ARG_NONNULL ((2, 3));
 
 __END_DECLS
 
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 38a0f0a..de619dc 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -127,6 +127,13 @@
 # include <sys/types.h>
 #endif
 
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
 /* Get getopt(), optarg, optind, opterr, optopt.
    But avoid namespace pollution on glibc systems.  */
 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
@@ -142,13 +149,6 @@ _GL_INLINE_HEADER_BEGIN
 # define _GL_UNISTD_INLINE _GL_INLINE
 #endif
 
-/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
-
-/* The definition of _GL_ARG_NONNULL is copied here.  */
-
-/* The definition of _GL_WARN_ON_USE is copied here.  */
-
-
 /* Hide some function declarations from <winsock2.h>.  */
 
 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
diff --git a/modules/getopt-posix b/modules/getopt-posix
index 5844217..2208756 100644
--- a/modules/getopt-posix
+++ b/modules/getopt-posix
@@ -18,6 +18,7 @@ unistd
 extensions
 include_next
 gettext-h       [test $REPLACE_GETOPT = 1]
+snippet/arg-nonnull
 
 configure.ac:
 gl_FUNC_GETOPT_POSIX
@@ -43,6 +44,7 @@ getopt.h: getopt.in.h $(top_builddir)/config.status
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
 	      -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/getopt.in.h; \
 	} > $@-t && \
 	mv -f $@-t $@
-- 
2.7.4


      parent reply	other threads:[~2017-04-09  8:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-08  7:14 bug#26398: 26.0.50; GNU LIB build fails on macOS 10.12.4 Harald Maier
2017-04-08  8:24 ` bug#26398: " Paul Eggert
2017-04-08  8:43   ` Harald Maier
2017-04-08  9:38     ` Paul Eggert
     [not found]     ` <bdc231db-f2a9-caf6-ef8d-20f144f06702@cs.ucla.edu>
2017-04-08 10:31       ` Harald Maier
2017-04-08 15:24       ` Zack Weinberg
     [not found]       ` <CAKCAbMis9L+_1=JukqJT4N9AKePvUHBSttyb03pCbXSLj5gLig@mail.gmail.com>
2017-04-09  8:03         ` Paul Eggert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='d936c05c-adba-3e62-69b2-ba9b8da8ed16__29587.7516888597$1491725055$gmane$org@cs.ucla.edu' \
    --to=eggert@cs.ucla.edu \
    --cc=26398-done@debbugs.gnu.org \
    --cc=Harald@Maierh.de \
    --cc=bug-gnulib@gnu.org \
    --cc=libc-alpha@sourceware.org \
    --cc=zackw@panix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).