git: 6275155b90de - main - devel/avr-gcc: Fix build with libc++ 17

From: Joerg Wunsch <joerg_at_FreeBSD.org>
Date: Sat, 23 Sep 2023 20:46:22 UTC
The branch main has been updated by joerg:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6275155b90de11398a1d105b053732313e7c1e7a

commit 6275155b90de11398a1d105b053732313e7c1e7a
Author:     Joerg Wunsch <joerg@FreeBSD.org>
AuthorDate: 2023-09-23 20:43:27 +0000
Commit:     Joerg Wunsch <joerg@FreeBSD.org>
CommitDate: 2023-09-23 20:46:17 +0000

    devel/avr-gcc: Fix build with libc++ 17
    
    gcc/system.h includes safe-ctype.h which redefines ctype macros such
    as toupper, tolower, etc to "poison" them.
    
    However, it should only include the safe-ctype.h header *after* any
    C++ headers, such as <list>, <map>, <string>, etc, otherwise these
    might transitively include internal ctype headers (such as with libc++
    17), causing compilation errors.
    
    PR:             274038
    Reported by:    dim
---
 devel/avr-gcc/Makefile                 |  2 +-
 devel/avr-gcc/files/patch-gcc_system.h | 42 ++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/devel/avr-gcc/Makefile b/devel/avr-gcc/Makefile
index 61fe35a14226..bb11c44a37bd 100644
--- a/devel/avr-gcc/Makefile
+++ b/devel/avr-gcc/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	gcc
 PORTVERSION=	11.2.0
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	devel
 MASTER_SITES=	GCC
 PKGNAMEPREFIX=	avr-
diff --git a/devel/avr-gcc/files/patch-gcc_system.h b/devel/avr-gcc/files/patch-gcc_system.h
new file mode 100644
index 000000000000..4cb52e33f571
--- /dev/null
+++ b/devel/avr-gcc/files/patch-gcc_system.h
@@ -0,0 +1,42 @@
+--- gcc/system.h.orig 2021-07-28 06:55:07 UTC
++++ gcc/system.h
+@@ -203,19 +203,6 @@ extern int fprintf_unlocked (FILE *, const char *, ...
+ #endif
+ #endif
+ 
+-/* There are an extraordinary number of issues with <ctype.h>.
+-   The last straw is that it varies with the locale.  Use libiberty's
+-   replacement instead.  */
+-#include "safe-ctype.h"
+-
+-#include <sys/types.h>
+-
+-#include <errno.h>
+-
+-#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
+-extern int errno;
+-#endif
+-
+ #ifdef __cplusplus
+ #if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY)
+ # include <algorithm>
+@@ -242,6 +229,19 @@ extern int errno;
+ # include <new>
+ # include <utility>
+ # include <type_traits>
++#endif
++
++/* There are an extraordinary number of issues with <ctype.h>.
++   The last straw is that it varies with the locale.  Use libiberty's
++   replacement instead.  */
++#include "safe-ctype.h"
++
++#include <sys/types.h>
++
++#include <errno.h>
++
++#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
++extern int errno;
+ #endif
+ 
+ /* Some of glibc's string inlines cause warnings.  Plus we'd rather