all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Andy Moreton <andrewjmoreton@gmail.com>, emacs-devel@gnu.org
Subject: Re: Emacs build fails on Windows mingw64
Date: Mon, 25 Oct 2021 00:52:45 +0200	[thread overview]
Message-ID: <4097293.omi8TgXK3m@omega> (raw)
In-Reply-To: <86h7d61f1f.fsf@gmail.com>

Andy Moreton wrote:
> > Andy suggested a simple fix that I quoted here:
> >
> > https://lists.gnu.org/r/emacs-devel/2021-10/msg01698.html
> >
> > We could apply that patch just to ntlib.c and just in emacs-28 (do not merge
> > to master) as Andy says that works for him;
> 
> Yes, that minimal fix bootstraps on emacs-28 and master with 64bit mingw64.

Thanks for the confirmation that the lack of definitions of
_GL_ATTRIBUTE_MALLOC and _GL_ATTRIBUTE_DEALLOC_FREE was indeed the problem.

Although Paul is right in saying that every file that uses Gnulib needs to
<config.h>, we make compromises regarding this requirement for the *.in.h
files. The commit
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=354f27fea9bd4ecb53980de6bd374434a204afc5
from 2021-08-22 "Make generated .in.h files as standalone as possible"
added definitions of _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
_GL_ATTRIBUTE_MALLOC to stdlib.h, and assumed that these definitions would
also be visible in string.h, since string.h did a '#include <stdlib.h>'.

The commit
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=a4a2d039a9117266ed8cb1977241e7c34b368993
from 2021-09-07 then removed this '#include <stdlib.h>' from string.in.h.
As a compensation, it added the declaration of free/rpl_free. But it needs
also the macros _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
_GL_ATTRIBUTE_MALLOC — when <config.h> is not pre-included.

The issue was also reported to me in private mail by Jan Engelhardt,
regarding the 'cdecl' package, on 2021-09-28, but I didn't have time
to react then; sorry about that.

This patch should fix it.


2021-10-24  Bruno Haible  <bruno@clisp.org>

	string: Avoid syntax error re strdup in string.in.h (regr. 2021-09-07).
	Reported by Jan Engelhardt <jengelh@inai.de>
	and by Arash Esbati <arash@gnu.org> via Andy Moreton in
	<https://lists.gnu.org/archive/html/bug-gnulib/2021-10/msg00058.html>.
	* lib/string.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
	_GL_ATTRIBUTE_MALLOC): Add fallback declarations, like in
	lib/stdlib.in.h.
	* lib/wchar.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
	_GL_ATTRIBUTE_MALLOC): Likewise.

diff --git a/lib/string.in.h b/lib/string.in.h
index 8d77ae380..afe735086 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -67,6 +67,35 @@
 # include <strings.h>
 #endif
 
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+   that can be freed by passing them as the Ith argument to the
+   function F.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+#  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+#  define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+   can be freed via 'free'; it can be used only after declaring 'free'.  */
+/* Applies to: functions.  Cannot be used on inline functions.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+   allocated memory.  */
+/* Applies to: functions.  */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+#  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The attribute __pure__ was added in gcc 2.96.  */
 #ifndef _GL_ATTRIBUTE_PURE
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index f13379ad8..20315dd7b 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -84,6 +84,35 @@
 #ifndef _@GUARD_PREFIX@_WCHAR_H
 #define _@GUARD_PREFIX@_WCHAR_H
 
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+   that can be freed by passing them as the Ith argument to the
+   function F.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+#  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+#  define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+   can be freed via 'free'; it can be used only after declaring 'free'.  */
+/* Applies to: functions.  Cannot be used on inline functions.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+   allocated memory.  */
+/* Applies to: functions.  */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+#  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The attribute __pure__ was added in gcc 2.96.  */
 #ifndef _GL_ATTRIBUTE_PURE






  reply	other threads:[~2021-10-24 22:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <86v91nfp6e.fsf@gmail.com>
2021-10-24  3:45 ` Emacs build fails on Windows mingw64 Paul Eggert
2021-10-24  6:26   ` Eli Zaretskii
2021-10-24 10:50     ` Andy Moreton
2021-10-24 12:27       ` Paul Eggert
2021-10-24 12:25     ` Paul Eggert
2021-10-24 13:58       ` Eli Zaretskii
2021-10-24 17:05         ` Paul Eggert
2021-10-24 17:48           ` Eli Zaretskii
2021-10-24 17:57           ` Andy Moreton
2021-10-24 22:52             ` Bruno Haible [this message]
2021-10-25 11:52               ` Eli Zaretskii
2021-10-25 21:26               ` Andy Moreton
2021-10-24 18:01           ` Óscar Fuentes
2021-10-24 18:10             ` Eli Zaretskii

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

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

  git send-email \
    --in-reply-to=4097293.omi8TgXK3m@omega \
    --to=bruno@clisp.org \
    --cc=andrewjmoreton@gmail.com \
    --cc=bug-gnulib@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.