---- gcc-5.4.0/libgfortran/intrinsics/chmod.c.orig 2016-12-18 10:38:13.034904609 +0100
-+++ gcc-5.4.0/libgfortran/intrinsics/chmod.c 2016-12-18 10:38:15.398237920 +0100
-@@ -30,6 +30,9 @@
- #include <string.h> /* For memcpy. */
- #include <stdlib.h> /* For free. */
+--- gcc-8.5.0/libgfortran/intrinsics/chmod.c.orig 2021-05-14 10:42:10.000000000 +0200
++++ gcc-8.5.0/libgfortran/intrinsics/chmod.c 2022-02-16 06:22:37.688407716 +0100
+@@ -28,6 +28,9 @@ see the files COPYING3 and COPYING.RUNTI
+ #if defined(HAVE_SYS_STAT_H)
+
#include <sys/stat.h> /* For stat, chmod and umask. */
+#ifdef __MINGW32__
+#include <io.h>
/* INTEGER FUNCTION CHMOD (NAME, MODE)
+--- gcc-9.5.0/libstdc++-v3/libsupc++/new_opa.cc.orig 2023-04-15 22:04:10.903826873 +0200
++++ gcc-9.5.0/libstdc++-v3/libsupc++/new_opa.cc 2023-04-15 22:58:08.356288088 +0200
+@@ -29,10 +29,13 @@
+ #include <bit>
+ #include "new"
+
+-#if !_GLIBCXX_HAVE_ALIGNED_ALLOC && !_GLIBCXX_HAVE__ALIGNED_MALLOC \
+- && !_GLIBCXX_HAVE_POSIX_MEMALIGN && _GLIBCXX_HAVE_MEMALIGN
++#if !_GLIBCXX_HAVE_ALIGNED_ALLOC && (!_GLIBCXX_HAVE__ALIGNED_MALLOC || defined(__MINGW32__)) \
++ && !_GLIBCXX_HAVE_POSIX_MEMALIGN && (_GLIBCXX_HAVE_MEMALIGN || defined(__MINGW32__))
+ # if _GLIBCXX_HOSTED && __has_include(<malloc.h>)
+ // Some C libraries declare memalign in <malloc.h>
++# ifdef __MINGW32__
++# define __MSVCRT_VERSION__ 0x0700
++# endif
+ # include <malloc.h>
+ # else
+ extern "C" void *memalign(std::size_t boundary, std::size_t size);
+--- gcc-7.5.0/libstdc++-v3/libsupc++/del_opa.cc.orig 2017-01-26 15:30:45.014860000 +0100
++++ gcc-7.5.0/libstdc++-v3/libsupc++/del_opa.cc 2019-12-26 09:41:01.210155799 +0100
+@@ -40,6 +40,16 @@
+
+ #include "new"
+
++#if !_GLIBCXX_HAVE_ALIGNED_ALLOC && (!_GLIBCXX_HAVE__ALIGNED_MALLOC || defined(__MINGW32__)) \
++ && !_GLIBCXX_HAVE_POSIX_MEMALIGN && (_GLIBCXX_HAVE_MEMALIGN || defined(__MINGW32__))
++# if _GLIBCXX_HOSTED && __has_include(<malloc.h>)
++# ifdef __MINGW32__
++# define __MSVCRT_VERSION__ 0x0700
++# endif
++# include <malloc.h>
++# endif
++#endif
++
+ // The sized deletes are defined in other files.
+ #pragma GCC diagnostic ignored "-Wsized-deallocation"
+
+--- gcc-10.4.0/libstdc++-v3/src/filesystem/ops-common.h.orig 2023-06-26 19:29:27.267246537 +0200
++++ gcc-10.4.0/libstdc++-v3/src/filesystem/ops-common.h 2023-06-26 20:39:47.401050776 +0200
+@@ -115,7 +115,7 @@ namespace __gnu_posix
+ return -1;
+ }
+
+- inline int truncate(const wchar_t* path, _off64_t length)
++ inline int truncate(const wchar_t* path, __off64_t length)
+ {
+ const int fd = ::_wopen(path, _O_BINARY|_O_RDWR);
+ if (fd == -1)
+--- gcc-9.5.0/libstdc++-v3/config/os/mingw32/error_constants.h.orig 2022-05-27 09:21:13.331391181 +0200
++++ gcc-9.5.0/libstdc++-v3/config/os/mingw32/error_constants.h 2023-04-16 18:55:43.337016242 +0200
+@@ -33,6 +33,18 @@
+ #include <bits/c++config.h>
+ #include <cerrno>
+
++#ifndef EOVERFLOW
++#define EOVERFLOW ERANGE
++#endif
++
++#ifndef ELOOP
++#define ELOOP ERANGE
++#endif
++
++#ifndef ENOTSUP
++#define ENOTSUP ENOSYS
++#endif
++
+ namespace std _GLIBCXX_VISIBILITY(default)
+ {
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+--- gcc-10.4.0/libstdc++-v3/src/c++11/system_error.cc.orig 2022-06-28 10:54:32.000000000 +0200
++++ gcc-10.4.0/libstdc++-v3/src/c++11/system_error.cc 2023-06-26 19:29:27.740577306 +0200
+@@ -168,7 +168,7 @@ namespace
+ #ifdef EISDIR
+ case EISDIR:
+ #endif
+-#ifdef ELOOP
++#if defined(ELOOP) && (ELOOP != ERANGE)
+ case ELOOP:
+ #endif
+ #ifdef EMFILE
+@@ -266,10 +266,10 @@ namespace
+ #if defined EOPNOTSUPP && (!defined ENOTSUP || EOPNOTSUPP != ENOTSUP)
+ case EOPNOTSUPP:
+ #endif
+-#ifdef EOVERFLOW
++#if defined(EOVERFLOW) && (EOVERFLOW != ERANGE)
+ case EOVERFLOW:
+ #endif
+-#ifdef EOWNERDEAD
++#if defined(EOWNERDEAD) && (!defined EILSEQ || EOWNERDEAD != EILSEQ)
+ case EOWNERDEAD:
+ #endif
+ #ifdef EPERM
+--- gcc-10.4.0/libgfortran/io/io.h.orig 2022-06-28 10:54:30.000000000 +0200
++++ gcc-10.4.0/libgfortran/io/io.h 2023-06-27 16:00:06.467225258 +0200
+@@ -291,7 +291,7 @@ typedef enum
+ unit_share;
+
+ typedef enum
+-{ CC_LIST, CC_FORTRAN, CC_NONE,
++{ CC_LIST, CC_FORTRAN, CC_NONE_,
+ CC_UNSPECIFIED
+ }
+ unit_cc;
+--- gcc-10.4.0/libgfortran/io/transfer.c.orig 2022-06-28 10:54:30.000000000 +0200
++++ gcc-10.4.0/libgfortran/io/transfer.c 2023-06-27 18:46:33.802431279 +0200
+@@ -388,7 +388,7 @@ read_sf (st_parameter_dt *dtp, size_t *l
+ q = fbuf_getc (dtp->u.p.current_unit);
+ if (q == EOF)
+ break;
+- else if (dtp->u.p.current_unit->flags.cc != CC_NONE
++ else if (dtp->u.p.current_unit->flags.cc != CC_NONE_
+ && (q == '\n' || q == '\r'))
+ {
+ /* Unexpected end of line. Set the position. */
+@@ -3660,7 +3660,7 @@ next_record_r (st_parameter_dt *dtp, int
+ }
+ break;
+ }
+- else if (dtp->u.p.current_unit->flags.cc != CC_NONE)
++ else if (dtp->u.p.current_unit->flags.cc != CC_NONE_)
+ {
+ do
+ {
+@@ -4026,7 +4026,7 @@ next_record_w (st_parameter_dt *dtp, int
+ else
+ {
+ /* Skip newlines for CC=CC_NONE. */
+- const int len = (dtp->u.p.current_unit->flags.cc == CC_NONE)
++ const int len = (dtp->u.p.current_unit->flags.cc == CC_NONE_)
+ ? 0
+ #ifdef HAVE_CRLF
+ : 2;
+@@ -4034,7 +4034,7 @@ next_record_w (st_parameter_dt *dtp, int
+ : 1;
+ #endif
+ fbuf_seek (dtp->u.p.current_unit, 0, SEEK_END);
+- if (dtp->u.p.current_unit->flags.cc != CC_NONE)
++ if (dtp->u.p.current_unit->flags.cc != CC_NONE_)
+ {
+ char *p = fbuf_alloc (dtp->u.p.current_unit, len);
+ if (!p)
+--- gcc-10.4.0/libgfortran/io/open.c.orig 2022-06-28 10:54:30.000000000 +0200
++++ gcc-10.4.0/libgfortran/io/open.c 2023-06-27 18:46:19.772507286 +0200
+@@ -63,7 +63,7 @@ static const st_option cc_opt[] =
+ {
+ { "list", CC_LIST },
+ { "fortran", CC_FORTRAN },
+- { "none", CC_NONE },
++ { "none", CC_NONE_ },
+ { NULL, 0}
+ };
+
+@@ -354,8 +354,8 @@ new_unit (st_parameter_open *opp, gfc_un
+ flags->status = STATUS_UNKNOWN;
+
+ if (flags->cc == CC_UNSPECIFIED)
+- flags->cc = flags->form == FORM_UNFORMATTED ? CC_NONE : CC_LIST;
+- else if (flags->form == FORM_UNFORMATTED && flags->cc != CC_NONE)
++ flags->cc = flags->form == FORM_UNFORMATTED ? CC_NONE_ : CC_LIST;
++ else if (flags->form == FORM_UNFORMATTED && flags->cc != CC_NONE_)
+ {
+ generate_error (&opp->common, LIBERROR_OPTION_CONFLICT,
+ "CARRIAGECONTROL parameter conflicts with UNFORMATTED form in "
+--- gcc-10.4.0/libgfortran/io/read.c.orig 2022-06-28 10:54:30.000000000 +0200
++++ gcc-10.4.0/libgfortran/io/read.c 2023-06-27 18:46:49.979010309 +0200
+@@ -1275,7 +1275,7 @@ read_x (st_parameter_dt *dtp, size_t n)
+ q = fbuf_getc (dtp->u.p.current_unit);
+ if (q == EOF)
+ break;
+- else if (dtp->u.p.current_unit->flags.cc != CC_NONE
++ else if (dtp->u.p.current_unit->flags.cc != CC_NONE_
+ && (q == '\n' || q == '\r'))
+ {
+ /* Unexpected end of line. Set the position. */
+--- gcc-10.4.0/libgfortran/io/inquire.c.orig 2022-06-28 10:54:30.000000000 +0200
++++ gcc-10.4.0/libgfortran/io/inquire.c 2023-06-27 18:46:57.988966916 +0200
+@@ -489,7 +489,7 @@ inquire_via_unit (st_parameter_inquire *
+ case CC_LIST:
+ p = "LIST";
+ break;
+- case CC_NONE:
++ case CC_NONE_:
+ p = "NONE";
+ break;
+ case CC_UNSPECIFIED:
+--- gcc-10.4.0/libstdc++-v3/src/filesystem/ops.cc.orig 2022-06-28 10:54:32.000000000 +0200
++++ gcc-10.4.0/libstdc++-v3/src/filesystem/ops.cc 2023-06-27 19:57:41.412644984 +0200
+@@ -971,7 +971,7 @@ fs::permissions(const path& p, perms prm
+ err = errno;
+ #else
+ if (nofollow && is_symlink(st))
+- ec = std::make_error_code(std::errc::operation_not_supported);
++ ec = std::make_error_code(std::errc::function_not_supported);
+ else if (posix::chmod(p.c_str(), static_cast<mode_t>(prms)))
+ err = errno;
+ #endif