[new-package] gcc12 12.2.0 for mingw32

This commit is contained in:
مهدي شينون (Mehdi Chinoune)
2023-05-04 09:13:30 +01:00
parent fd5380c8c4
commit 1e5bb2ff2c
20 changed files with 2543 additions and 0 deletions

View File

@@ -0,0 +1,856 @@
From 056d1dbaa0c542fde6e0d90a28be9a280967d6d1 Mon Sep 17 00:00:00 2001
From: Erwin Waterlander <waterlan@xs4all.nl>
Date: Wed, 5 Aug 2015 23:36:03 +0100
Subject: [PATCH 01/15] Relocate libintl
The relocatex-libintl patch adds builtin relocation for executables to the
libintl dll. With this patch the programs are automatically relocatable. There
is no need anymore to add relocation code to your program when you use this
libintl DLL.
The patch was ported from the GnuWin32 port of libintl, which has also builtin
relacation support.
At the moment the relocation support is only active if you compile with MinGW
for Windows. If you compile for Unix/Linux/Cygwin the functionality is
unchanged.
See also:
http://waterlan.home.xs4all.nl/libintl.html
http://sourceforge.net/tracker/?func=detail&atid=302435&aid=3003879&group_id=2435
GnuWin32: http://gnuwin32.sourceforge.net/
Great thanks to GnuWin32 maintainer Kees Zeelenberg.
Erwin Waterlander
waterlan@xs4all.nl
http://waterlan.home.xs4all.nl/
Additional "bogus paths for *nix-style paths" fix by Alexey Pavlov
[jes: fix for 64-bit]
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
intl/Makefile.in | 8 +-
intl/bindtextdom.c | 22 +++
intl/canonicalize.c | 343 ++++++++++++++++++++++++++++++++++++++++++++
intl/canonicalize.h | 18 +++
intl/relocatex.c | 284 ++++++++++++++++++++++++++++++++++++
intl/relocatex.h | 41 ++++++
6 files changed, 715 insertions(+), 1 deletion(-)
create mode 100644 intl/canonicalize.c
create mode 100644 intl/canonicalize.h
create mode 100644 intl/relocatex.c
create mode 100644 intl/relocatex.h
diff --git a/intl/Makefile.in b/intl/Makefile.in
index 409d693c48e..e85c99b2abe 100644
--- a/intl/Makefile.in
+++ b/intl/Makefile.in
@@ -57,6 +57,7 @@ MKID = @MKID@
COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(DEFS-$@) $(INCLUDES)
HEADERS = \
+ canonicalize.h \
gmo.h \
gettextP.h \
hash-string.h \
@@ -66,6 +67,7 @@ HEADERS = \
eval-plural.h \
localcharset.h \
relocatable.h \
+ relocatex.h \
libgnuintl.h
SOURCES = \
bindtextdom.c \
@@ -86,6 +88,8 @@ SOURCES = \
plural-exp.c \
localcharset.c \
relocatable.c \
+ relocatex.c \
+ canonicalize.c \
localename.c \
log.c \
osdep.c \
@@ -109,6 +113,8 @@ OBJECTS = \
plural-exp.o \
localcharset.o \
relocatable.o \
+ relocatex.o \
+ canonicalize.o \
localename.o \
log.o \
osdep.o \
@@ -169,7 +175,7 @@ install-info install-dvi install-ps install-pdf install-html:
$(OBJECTS): config.h libintl.h
bindtextdom.o dcgettext.o dcigettext.o dcngettext.o dgettext.o \
dngettext.o finddomain.o gettext.o intl-compat.o loadmsgcat.o \
-localealias.o ngettext.o textdomain.o: gettextP.h gmo.h loadinfo.h
+localealias.o ngettext.o textdomain.o: gettextP.h gmo.h loadinfo.h relocatex.h
dcigettext.o loadmsgcat.o: hash-string.h
explodename.o l10nflist.o: loadinfo.h
dcigettext.o loadmsgcat.o plural.o plural-exp.o: plural-exp.h plural-config.h
diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
index 6faac5756a3..1854b651b90 100644
--- a/intl/bindtextdom.c
+++ b/intl/bindtextdom.c
@@ -23,6 +23,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#ifdef _LIBC
# include <libintl.h>
@@ -91,6 +92,12 @@ static void set_binding_values PARAMS ((const char *domainname,
const char **dirnamep,
const char **codesetp));
+#if ENABLE_RELOCATABLE
+# include "relocatex.h"
+#else
+# define relocate(pathname) (pathname)
+#endif
+
/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP
to be used for the DOMAINNAME message catalog.
If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not
@@ -352,8 +359,23 @@ BINDTEXTDOMAIN (domainname, dirname)
const char *domainname;
const char *dirname;
{
+/*
set_binding_values (domainname, &dirname, NULL);
return (char *) dirname;
+*/
+ if (!dirname || !access(dirname, R_OK)) {
+ set_binding_values (domainname, &dirname, NULL);
+ return (char *) dirname;
+ } else {
+ char *locale_dirname, *installdir = strdup (dirname), *s;
+ if ((s = strrchr (installdir, '/'))) *s = '\0';
+ if ((s = strrchr (installdir, '/'))) *s = '\0';
+ locale_dirname = relocatex (installdir, dirname);
+ set_binding_values (domainname, (const char **) &locale_dirname, NULL);
+ if (installdir)
+ free (installdir);
+ return (char *) locale_dirname;
+ }
}
/* Specify the character encoding in which the messages from the
diff --git a/intl/canonicalize.c b/intl/canonicalize.c
new file mode 100644
index 00000000000..5217f304540
--- /dev/null
+++ b/intl/canonicalize.c
@@ -0,0 +1,344 @@
+/* Return the canonical absolute name of a given file.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stddef.h>
+#include <malloc.h>
+#ifdef __WIN32__
+# include <stdio.h>
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+//# include <gw32.h>
+#endif /* __WIN32__ */
+#include "canonicalize.h"
+
+#ifndef MAXSYMLINKS
+# define MAXSYMLINKS 20
+#endif
+
+#ifndef __set_errno
+# define __set_errno(Val) errno = (Val)
+#endif
+
+# ifdef VMS
+ /* We want the directory in Unix syntax, not in VMS syntax. */
+# define __getcwd(buf, max) getcwd (buf, max, 0)
+# else
+# define __getcwd getcwd
+# endif
+
+#define weak_alias(local, symbol)
+
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
+ /* Win32, Cygwin, OS/2, DOS */
+# define ISDIRSEP(C) ((C) == '/' || (C) == '\\')
+#else
+ /* Unix */
+# define ISDIRSEP(C) ((C) == '/')
+#endif
+
+#ifdef __WIN32__
+char *win2unixpath (char *FileName)
+{
+ char *s = FileName;
+ while (*s) {
+ if (*s == '\\')
+ *s = '/';
+ *s++;
+ }
+ return FileName;
+}
+#endif
+
+/* Return the canonical absolute name of file NAME. A canonical name
+ does not contain any `.', `..' components nor any repeated path
+ separators ('/') or symlinks. All path components must exist. If
+ RESOLVED is null, the result is malloc'd; otherwise, if the
+ canonical name is PATH_MAX chars or more, returns null with `errno'
+ set to ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
+ returns the name in RESOLVED. If the name cannot be resolved and
+ RESOLVED is non-NULL, it contains the path of the first component
+ that cannot be resolved. If the path can be resolved, RESOLVED
+ holds the same value as the value returned.
+ RESOLVED must be at least PATH_MAX long */
+
+static char *
+canonicalize (const char *name, char *resolved)
+{
+ char *rpath, *dest, *extra_buf = NULL;
+ const char *start, *end, *rpath_limit;
+ long int path_max;
+ int num_links = 0, old_errno;
+
+ if (name == NULL)
+ {
+ /* As per Single Unix Specification V2 we must return an error if
+ either parameter is a null pointer. We extend this to allow
+ the RESOLVED parameter to be NULL in case the we are expected to
+ allocate the room for the return value. */
+ __set_errno (EINVAL);
+ return NULL;
+ }
+
+ if (name[0] == '\0')
+ {
+ /* As per Single Unix Specification V2 we must return an error if
+ the name argument points to an empty string. */
+ __set_errno (ENOENT);
+ return NULL;
+ }
+#ifdef __WIN32__
+ {
+ char *lpFilePart;
+ int len;
+// fprintf(stderr, "name: %s\n", name);
+ rpath = resolved ? __builtin_alloca (MAX_PATH) : malloc (MAX_PATH);
+// unix2winpath (name);
+// fprintf(stderr, "name: %s\n", name);
+len = GetFullPathName(name, MAX_PATH, rpath, &lpFilePart);
+/* GetFullPathName returns bogus paths for *nix-style paths, like
+ * /foo/bar - it just prepends current drive to them. Keep them
+ * intact (they need to be for relocation to work!).
+ */
+if (name[0] == '/') {
+ strncpy (rpath, name, MAX_PATH - 1);
+ rpath[MAX_PATH - 1] = '\0';
+ len = strlen (rpath);
+}
+// fprintf(stderr, "rpath: %s\n", rpath);
+ if (len == 0) {
+ //set_werrno;
+ return NULL;
+ }
+ if (len > MAX_PATH) {
+ if (resolved)
+ __set_errno(ENAMETOOLONG);
+ else {
+ rpath = realloc(rpath, len + 2);
+ GetFullPathName(name, len, rpath, &lpFilePart);
+// fprintf(stderr, "rpath: %s\n", rpath);
+ }
+ }
+// if ( ISDIRSEP(name[strlen(name)]) && !ISDIRSEP(rpath[len]) ) {
+// rpath[len] = '\\';
+// rpath[len + 1] = 0;
+// }
+ old_errno = errno;
+ //if (!access (rpath, D_OK) && !ISDIRSEP(rpath[len - 1]) ){
+ if (!access (rpath, R_OK) && !ISDIRSEP(rpath[len - 1]) ){
+ rpath[len] = '\\';
+ rpath[len + 1] = 0;
+ }
+ errno = old_errno;
+ win2unixpath (rpath);
+// fprintf(stderr, "rpath: %s\n", rpath);
+ return resolved ? strcpy(resolved, rpath) : rpath ;
+ }
+#else /* __WIN32__ */
+
+#ifdef PATH_MAX
+ path_max = PATH_MAX;
+#else
+ path_max = pathconf (name, _PC_PATH_MAX);
+ if (path_max <= 0)
+ path_max = 1024;
+#endif
+
+ rpath = resolved ? __builtin_alloca (path_max) : malloc (path_max);
+ rpath_limit = rpath + path_max;
+
+ if (name[0] != '/')
+ {
+ if (!__getcwd (rpath, path_max))
+ {
+ rpath[0] = '\0';
+ goto error;
+ }
+ dest = strchr (rpath, '\0');
+ }
+ else
+ {
+ rpath[0] = '/';
+ dest = rpath + 1;
+ }
+
+ for (start = end = name; *start; start = end)
+ {
+#ifdef _LIBC
+ struct stat64 st;
+#else
+ struct stat st;
+#endif
+ int n;
+
+ /* Skip sequence of multiple path-separators. */
+ while (*start == '/')
+ ++start;
+
+ /* Find end of path component. */
+ for (end = start; *end && *end != '/'; ++end)
+ /* Nothing. */;
+
+ if (end - start == 0)
+ break;
+ else if (end - start == 1 && start[0] == '.')
+ /* nothing */;
+ else if (end - start == 2 && start[0] == '.' && start[1] == '.')
+ {
+ /* Back up to previous component, ignore if at root already. */
+ if (dest > rpath + 1)
+ while ((--dest)[-1] != '/');
+ }
+ else
+ {
+ size_t new_size;
+
+ if (dest[-1] != '/')
+ *dest++ = '/';
+
+ if (dest + (end - start) >= rpath_limit)
+ {
+ ptrdiff_t dest_offset = dest - rpath;
+
+ if (resolved)
+ {
+ __set_errno (ENAMETOOLONG);
+ if (dest > rpath + 1)
+ dest--;
+ *dest = '\0';
+ goto error;
+ }
+ new_size = rpath_limit - rpath;
+ if (end - start + 1 > path_max)
+ new_size += end - start + 1;
+ else
+ new_size += path_max;
+ rpath = realloc (rpath, new_size);
+ rpath_limit = rpath + new_size;
+ if (rpath == NULL)
+ return NULL;
+
+ dest = rpath + dest_offset;
+ }
+
+#ifdef _LIBC
+ dest = __mempcpy (dest, start, end - start);
+#else
+ memcpy (dest, start, end - start);
+ dest += end - start;
+#endif
+ *dest = '\0';
+
+#ifdef _LIBC
+ if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
+#else
+ if (lstat (rpath, &st) < 0)
+#endif
+ goto error;
+
+#if HAVE_READLINK
+ if (S_ISLNK (st.st_mode))
+ {
+ char *buf = __builtin_alloca (path_max);
+ size_t len;
+
+ if (++num_links > MAXSYMLINKS)
+ {
+ __set_errno (ELOOP);
+ goto error;
+ }
+
+ n = __readlink (rpath, buf, path_max);
+ if (n < 0)
+ goto error;
+ buf[n] = '\0';
+
+ if (!extra_buf)
+ extra_buf = __builtin_alloca (path_max);
+
+ len = strlen (end);
+ if ((long int) (n + len) >= path_max)
+ {
+ __set_errno (ENAMETOOLONG);
+ goto error;
+ }
+
+ /* Careful here, end may be a pointer into extra_buf... */
+ memmove (&extra_buf[n], end, len + 1);
+ name = end = memcpy (extra_buf, buf, n);
+
+ if (buf[0] == '/')
+ dest = rpath + 1; /* It's an absolute symlink */
+ else
+ /* Back up to previous component, ignore if at root already: */
+ if (dest > rpath + 1)
+ while ((--dest)[-1] != '/');
+ }
+#endif
+ }
+ }
+ if (dest > rpath + 1 && dest[-1] == '/')
+ --dest;
+ *dest = '\0';
+
+ return resolved ? memcpy (resolved, rpath, dest - rpath + 1) : rpath;
+
+error:
+ if (resolved)
+ strcpy (resolved, rpath);
+ else
+ free (rpath);
+ return NULL;
+
+#endif /* __WIN32__ */
+}
+
+
+char *
+__realpath (const char *name, char *resolved)
+{
+ if (resolved == NULL)
+ {
+ __set_errno (EINVAL);
+ return NULL;
+ }
+
+ return canonicalize (name, resolved);
+}
+weak_alias (__realpath, realpath)
+
+
+char *
+__canonicalize_file_name (const char *name)
+{
+ return canonicalize (name, NULL);
+}
+weak_alias (__canonicalize_file_name, canonicalize_file_name)
+
+char *
+canonicalize_file_name (const char *name)
+{
+ return canonicalize (name, NULL);
+}
diff --git a/intl/canonicalize.h b/intl/canonicalize.h
new file mode 100644
index 00000000000..ea707bf1bdf
--- /dev/null
+++ b/intl/canonicalize.h
@@ -0,0 +1,18 @@
+#ifndef __CANONICALIZE_H__
+#define __CANONICALIZE_H__ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *canonicalize_file_name (const char *name);
+
+#ifdef __WIN32__
+char *win2unixpath (char *path);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CANONICALIZE_H__ */
diff --git a/intl/relocatex.c b/intl/relocatex.c
new file mode 100644
index 00000000000..a2b7438fb43
--- /dev/null
+++ b/intl/relocatex.c
@@ -0,0 +1,284 @@
+/* Provide relocatable packages.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2003.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+
+/* Specification. */
+#include <errno.h>
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+/* #include <path.h> */
+#include "relocatex.h"
+#include "canonicalize.h"
+/* #include <gw32.h> */
+
+
+#if defined _WIN32 || defined __WIN32__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+//# define __GW32__
+//# include <winx/errnox.h>
+#endif
+#define set_werrno
+
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
+ /* Win32, Cygwin, OS/2, DOS */
+# define ISDIRSEP(C) ((C) == '/' || (C) == '\\')
+#else
+ /* Unix */
+# define ISDIRSEP(C) ((C) == '/')
+#endif
+
+/* Original installation prefix. */
+static char *orig_prefix = NULL;
+static size_t orig_prefix_len = 0;
+/* Current installation prefix. */
+static char *curr_prefix = NULL;
+static size_t curr_prefix_len = 0;
+/* These prefixes do not end in a slash. Anything that will be concatenated
+ to them must start with a slash. */
+
+
+int win2posixpath (const char *winpath, char *posixpath)
+{
+ strcpy (posixpath, winpath);
+ win2unixpath (posixpath);
+ return 0;
+}
+
+
+/* Sets the original and the current installation prefix of this module.
+ Relocation simply replaces a pathname starting with the original prefix
+ by the corresponding pathname with the current prefix instead. Both
+ prefixes should be directory names without trailing slash (i.e. use ""
+ instead of "/"). */
+static char *
+set_orig_prefix (const char *orig_prefix_arg)
+{
+ char *memory;
+// printf ("orig_prefix_arg: %s\n", orig_prefix_arg);
+ if (!orig_prefix_arg) {
+ orig_prefix = NULL;
+ orig_prefix_len = 0;
+ return NULL;
+ }
+ if (orig_prefix)
+ free (orig_prefix);
+
+ memory = canonicalize_file_name (orig_prefix_arg);
+// printf ("memory: %s\n", memory);
+// memory = (char *) malloc (orig_prefix_len + 1);
+ if (!memory) {
+ set_werrno;
+ orig_prefix = NULL;
+ orig_prefix_len = 0;
+ return NULL;
+ }
+ win2unixpath (memory);
+// win2posixpath (orig_prefix_arg, memory);
+ orig_prefix = memory;
+ orig_prefix_len = strlen (orig_prefix);
+// printf ("orig_prefix: %s\n", orig_prefix);
+ if (ISDIRSEP (orig_prefix[orig_prefix_len-1])) {
+ orig_prefix[orig_prefix_len-1] = '\0';
+ orig_prefix_len--;
+ }
+// printf ("orig_prefix: %s\n", orig_prefix);
+// printf ("orig_prefix_len: %d\n", orig_prefix_len);
+ return orig_prefix;
+}
+
+#if defined __WIN32__
+static char *
+set_current_prefix (const char *ModuleName)
+{
+ LPTSTR curr_prefix_arg, q, lpFilePart;
+ DWORD len;
+ int nDIRSEP = 0;
+
+ if (curr_prefix)
+ free (curr_prefix);
+ curr_prefix_arg = malloc (MAX_PATH * sizeof (TCHAR));
+ if (!curr_prefix_arg) {
+ set_werrno;
+ curr_prefix = NULL;
+ curr_prefix_len = 0;
+ return NULL;
+ }
+ if (ModuleName) {
+// printf ("ModuleName: %s\n", ModuleName);
+ len = SearchPath (NULL, ModuleName, ".DLL", MAX_PATH, curr_prefix_arg, &lpFilePart);
+ if (len) {
+// printf ("ModulePath: %s\n", curr_prefix_arg);
+// printf ("FilePart: %s\n", lpFilePart);
+ }
+ }
+ if (!ModuleName || !len) {
+ len = GetModuleFileName (NULL, curr_prefix_arg, MAX_PATH);
+ if (!len) {
+ set_werrno;
+ curr_prefix = NULL;
+ curr_prefix_len = 0;
+ return NULL;
+ }
+ }
+// strncpy (curr_prefix_arg, ModuleName, MAX_PATH);
+// printf ("curr_prefix_arg: %s\n", curr_prefix_arg);
+ win2posixpath (curr_prefix_arg, curr_prefix_arg);
+ curr_prefix = curr_prefix_arg;
+ q = curr_prefix_arg + len - 1;
+ /* strip name of executable and its directory */
+ while (!ISDIRSEP (*q) && (q > curr_prefix_arg) && nDIRSEP < 2) {
+ q--;
+ if (ISDIRSEP (*q)) {
+ *q = '\0';
+ nDIRSEP++;
+ }
+ }
+ curr_prefix_len = q - curr_prefix_arg;
+// printf ("curr_prefix: %s\n", curr_prefix);
+// printf ("curr_prefix_len: %d\n", curr_prefix_len);
+ return curr_prefix;
+}
+
+char *getshortpath (const char *longpath)
+{
+ char *shortpath = NULL;
+ DWORD len, res;
+
+// printf ("longpath: %s\n", longpath);
+ len = GetShortPathName(longpath, shortpath, 0);
+// printf ("len: %ld\n", len);
+ if (!len) {
+// WinErr ("getshortpath: len = 0");
+ set_werrno;
+ return (char *) longpath;
+ }
+ shortpath = (char *) malloc (len + 1);
+ if (!shortpath) {
+// WinErr ("getshortpath: malloc");
+ set_werrno;
+ return (char *) longpath;
+ }
+ res = GetShortPathName(longpath, shortpath, len);
+// printf ("res: %ld\n", res);
+ if (!res) {
+// WinErr ("getshortpath: res = 0");
+ free (shortpath);
+ set_werrno;
+ return (char *) longpath;
+ }
+// printf ("shortpath: %s\n", shortpath);
+ return shortpath;
+}
+
+char *relocaten (const char *ModuleName, const char *path)
+{
+ char *relative_path, *relocated_path, *relocated_short_path;
+ int relative_path_len;
+
+ if (!curr_prefix)
+ set_current_prefix (ModuleName);
+// printf ("path: %s\n", path);
+// printf ("orig_prefix: %s\n", orig_prefix);
+// printf ("curr_prefix: %s\n", curr_prefix);
+// if (strncmp (orig_prefix, path, orig_prefix_len))
+// if (strcmp (orig_prefix, path))
+// return (char *) path;
+ relative_path = (char *) path + orig_prefix_len;
+// printf ("relative_path: %s\n", relative_path);
+ relative_path_len = strlen (relative_path);
+ relocated_path = malloc (curr_prefix_len + relative_path_len + 1);
+ strcpy (relocated_path, curr_prefix);
+ strcat (relocated_path, relative_path);
+// printf ("relocated_path: %s\n", relocated_path);
+ relocated_short_path = getshortpath (relocated_path);
+// printf ("relocated_short_path: %s\n", relocated_short_path);
+ if (relocated_short_path) {
+ if (relocated_short_path != relocated_path)
+ free (relocated_path);
+ return relocated_short_path;
+ } else
+ return relocated_path;
+}
+
+#else // __WIN32__
+char *relocaten (const char *ModuleName, const char *path)
+{
+ // dummy function for Unix/Linux
+ return (char *)path;
+}
+#endif
+
+char *relocaten2 (const char *ModuleName, const char *installdir, const char *path)
+{
+ set_orig_prefix (installdir);
+ return relocaten (ModuleName, path);
+}
+
+char *relocatenx (const char *ModuleName, const char *installdir, const char *path)
+{
+ char *p;
+
+ set_orig_prefix (installdir);
+ if (access (path, R_OK))
+ p = relocaten (ModuleName, path);
+ else
+ p = (char *) path;
+// printf ("relocatenx: %s\n", p);
+ return p;
+}
+
+char *relocate2 (const char *installdir, const char *path)
+{
+ return relocaten2 (NULL, installdir, path);
+}
+
+char *relocatex (const char *installdir, const char *path)
+{
+ return relocatenx (NULL, installdir, path);
+}
+
+char *relocatepx (const char *cprefix, const char *installdir, const char *path)
+{
+ if (curr_prefix)
+ free (curr_prefix);
+ curr_prefix = strdup (cprefix);
+ return relocatex (installdir, path);
+}
+
+static char *get_orig_prefix (void)
+{
+ return orig_prefix;
+}
+
+static char *get_curr_prefix (void)
+{
+ return curr_prefix;
+}
+
+static char *set_curr_prefix (const char *ModuleName)
+{
+ if (curr_prefix)
+ free (curr_prefix);
+ set_current_prefix (ModuleName);
+ return curr_prefix;
+}
diff --git a/intl/relocatex.h b/intl/relocatex.h
new file mode 100644
index 00000000000..5cc7c5174a9
--- /dev/null
+++ b/intl/relocatex.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GnuWin C Library.
+
+ The GnuWin C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GnuWin C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GnuWin32 C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef __RELOCATE_H__
+#define __RELOCATE_H__ 1
+
+/* #include <libc-dll.h> */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *relocaten (const char *ModuleName, const char *path);
+char *relocaten2 (const char *ModuleName, const char *installdir, const char *path);
+char *relocatenx (const char *ModuleName, const char *installdir, const char *path);
+char *relocate2 (const char *installdir, const char *path);
+char *relocatex (const char *installdir, const char *path);
+
+#ifdef __cplusplus
+}
+#endif
+
+//#endif /* __GW32__ */
+
+#endif /* __RELOCATE_H__ */
--
2.35.3

View File

@@ -0,0 +1,131 @@
From 8056eedaf6dbdeeb07df72221078223f4bed5161 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Wed, 5 Aug 2015 23:36:07 +0100
Subject: [PATCH 02/15] Windows: Follow Posix dir-exists semantics more closely
Make Windows behave the same as Posix in the consideration
of whether folder "/doesnt-exist/.." is a valid
path. In Posix, it isn't.
A concrete instance of when this matters is when cross
compiling GNU/Linux glibc on Windows.
---
libcpp/files.cc | 87 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/libcpp/files.cc b/libcpp/files.cc
index 24208f7b0f8..a740d7a778c 100644
--- a/libcpp/files.cc
+++ b/libcpp/files.cc
@@ -30,6 +30,14 @@ along with this program; see the file COPYING3. If not see
#include "md5.h"
#include <dirent.h>
+/* Needed for stat_st_mode_symlink below */
+#if defined(_WIN32)
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# define S_IFLNK 0xF000
+# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#endif
+
/* Variable length record files on VMS will have a stat size that includes
record control characters that won't be included in the read size. */
#ifdef VMS
@@ -200,6 +207,49 @@ static int pchf_save_compare (const void *e1, const void *e2);
static int pchf_compare (const void *d_p, const void *e_p);
static bool check_file_against_entries (cpp_reader *, _cpp_file *, bool);
+#if defined(_WIN32)
+
+static int stat_st_mode_symlink (char const* path, struct stat* buf)
+{
+ WIN32_FILE_ATTRIBUTE_DATA attr;
+ memset(buf,0,sizeof(*buf));
+ int err = GetFileAttributesExA (path, GetFileExInfoStandard, &attr) ? 0 : 1;
+ if (!err)
+ {
+ WIN32_FIND_DATAA finddata;
+ HANDLE h = FindFirstFileA (path, &finddata);
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ FindClose (h);
+ if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
+ (finddata.dwReserved0 == IO_REPARSE_TAG_SYMLINK))
+ buf->st_mode = S_IFLNK;
+ else if (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ buf->st_mode = S_IFDIR;
+ else if (finddata.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)
+ buf->st_mode = S_IFDIR;
+ else
+ buf->st_mode = S_IFREG;
+ buf->st_mode |= S_IREAD;
+ if (!(finddata.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+ buf->st_mode |= S_IWRITE;
+ }
+ else
+ {
+ buf->st_mode = S_IFDIR;
+ }
+ return 0;
+ }
+ return -1;
+}
+
+#else
+
+#define stat_st_mode_symlink (_name, _buf) stat ((_name), (_buf))
+
+#endif
+
+
/* Given a filename in FILE->PATH, with the empty string interpreted
as <stdin>, open it.
@@ -229,6 +279,43 @@ open_file (_cpp_file *file)
}
else
file->fd = open (file->path, O_RDONLY | O_NOCTTY | O_BINARY, 0666);
+#if defined(_WIN32) || defined(__CYGWIN__)
+ /* Windows and Posix differ in the face of paths of the form:
+ nonexistantdir/.. in that Posix will return ENOENT whereas
+ Windows won't care that we stepped into a non-existant dir
+ Only do these slow checks if ".." appears in file->path.
+ Cygwin also suffers from the same problem (but doesn't need
+ a new stat function):
+ http://cygwin.com/ml/cygwin/2013-05/msg00222.html
+ */
+ if (file->fd > 0)
+ {
+ char filepath[MAX_PATH];
+ strncpy (filepath, file->path, sizeof(filepath) - 1);
+ char* dirsep = &filepath[0];
+ while ( (dirsep = strchr (dirsep, '\\')) != NULL)
+ *dirsep = '/';
+ if (strstr(file->path, "/../"))
+ {
+ dirsep = &filepath[0];
+ char dirsepc;
+ /* Check each directory in the chain. */
+ while ( (dirsep = strpbrk (dirsep, "\\/")) != NULL)
+ {
+ dirsepc = *(++dirsep);
+ *dirsep = '\0';
+ if (stat_st_mode_symlink (filepath, &file->st) == -1)
+ {
+ *dirsep = dirsepc;
+ close (file->fd);
+ file->fd = -1;
+ return false;
+ }
+ *dirsep++ = dirsepc;
+ }
+ }
+ }
+#endif
if (file->fd != -1)
{
--
2.35.3

View File

@@ -0,0 +1,60 @@
From 2d1c33eeae5af6b2a634778bfb5162606414bce3 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Wed, 5 Aug 2015 23:36:09 +0100
Subject: [PATCH 03/15] Windows: Use '/' not '\' in progpath and leave case
as-is
Windows can handle both '/' and '\' dirseps. GCC will
have been built using Cygwin, MSYS* or cross-compiled
from a system where dirsep is '/' so it is cleaner to
force the dirseps to be '/' and keep the case as-is.
This way, the value will be consistent with the build
system and string operations, be they internal to GCC
or external to it (e.g. processing map files with sed)
have a better chance of working as expected.
A concrete instance of when this matters is when cross
compiling GNU/Linux glibc on Windows.
---
libiberty/lrealpath.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/libiberty/lrealpath.c b/libiberty/lrealpath.c
index 3c7053b0b70..b9cbf666210 100644
--- a/libiberty/lrealpath.c
+++ b/libiberty/lrealpath.c
@@ -138,15 +138,26 @@ lrealpath (const char *filename)
{
char buf[MAX_PATH];
char* basename;
+ char* slash;
DWORD len = GetFullPathName (filename, MAX_PATH, buf, &basename);
if (len == 0 || len > MAX_PATH - 1)
return strdup (filename);
else
{
- /* The file system is case-preserving but case-insensitive,
- Canonicalize to lowercase, using the codepage associated
- with the process locale. */
- CharLowerBuff (buf, len);
+ /* Turn all back slashes back into forward slashes
+ and don't make it lowercase.
+ Rationale:
+ Windows is as happy with / as it is with \. This will
+ have been built using Cygwin, MSYS* or cross-compiled
+ from a system where dirsep is / so it is cleaner just
+ to keep the dirseps as / (and the case un-modified).
+ This way, the value will be consistent with the build
+ system and string operations (be they internal to this
+ software or external to it, e.g. processing map files
+ with sed) work as expected. */
+ slash = buf;
+ while ((slash = strchr(slash,'\\')) != NULL)
+ *slash = '/';
return strdup (buf);
}
}
--
2.35.3

View File

@@ -0,0 +1,28 @@
From 910eea0aa52a3789ccb88343ec6574566e159ede Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Wed, 5 Aug 2015 23:36:11 +0100
Subject: [PATCH 04/15] Windows: Don't ignore native system header dir
---
gcc/config.gcc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index c5064dd3766..a72fb5bbb74 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2209,7 +2209,10 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
tmake_file="${tmake_file} i386/t-mingw-w32"
;;
esac
- native_system_header_dir=/mingw/include
+ # Don't ignore values passed in to configure via --native-system-header-dir
+ if test x$native_system_header_dir = x ; then
+ native_system_header_dir=/mingw/include
+ fi
target_gtfiles="$target_gtfiles \$(srcdir)/config/i386/winnt.cc"
extra_options="${extra_options} i386/cygming.opt i386/mingw.opt"
case ${target} in
--
2.35.3

View File

@@ -0,0 +1,44 @@
From 6ff4cbf39895026305654bb5b8bd82f9593803b9 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Wed, 5 Aug 2015 23:36:13 +0100
Subject: [PATCH 05/15] master Windows: New feature to allow overriding
-lmsvcrt
Added in support of the MinGW-w64 WIP feature "agile mscvrt dll" where
a process' loaded msvc runtime is used by a newly loaded DLL rather than
always using msvcrt.dll
---
gcc/config/i386/cygming.opt | 3 +++
gcc/config/i386/mingw32.h | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/gcc/config/i386/cygming.opt b/gcc/config/i386/cygming.opt
index 12435d813f5..5dff2ac1551 100644
--- a/gcc/config/i386/cygming.opt
+++ b/gcc/config/i386/cygming.opt
@@ -22,6 +22,9 @@ mconsole
Target RejectNegative
Create console application.
+mcrtdll=
+Target RejectNegative Joined
+
mdll
Target RejectNegative
Generate code for a DLL.
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
index d3ca0cd0279..07dcd6ba97b 100644
--- a/gcc/config/i386/mingw32.h
+++ b/gcc/config/i386/mingw32.h
@@ -185,7 +185,7 @@ along with GCC; see the file COPYING3. If not see
#define REAL_LIBGCC_SPEC \
"%{mthreads:-lmingwthrd} -lmingw32 \
" SHARED_LIBGCC_SPEC " \
- -lmoldname -lmingwex -lmsvcrt -lkernel32"
+ -lmoldname -lmingwex %{!mcrtdll=*:-lmsvcrt} %{mcrtdll=*:-l%*} -lkernel32"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
--
2.35.3

View File

@@ -0,0 +1,34 @@
From c231dea93690f8081e38e1888fbf9d77327025a7 Mon Sep 17 00:00:00 2001
From: Alexey Pavlov <alexey.pawlow@gmail.com>
Date: Wed, 5 Aug 2015 23:36:17 +0100
Subject: [PATCH 06/15] Build EXTRA_GNATTOOLS for Ada
---
gnattools/Makefile.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gnattools/Makefile.in b/gnattools/Makefile.in
index e8fc4af0788..f0daadbc1d7 100644
--- a/gnattools/Makefile.in
+++ b/gnattools/Makefile.in
@@ -201,7 +201,7 @@ gnattools-native: $(GCC_DIR)/stamp-tools $(GCC_DIR)/stamp-gnatlib-rts
../../gnatmake$(exeext) ../../gnatlink$(exeext)
# gnattools2
$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
- $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
+ $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools $(EXTRA_GNATTOOLS)
# gnatmake/link can be built with recent gnatmake/link if they are available.
# This is especially convenient for building cross tools or for rebuilding
@@ -213,7 +213,7 @@ regnattools: $(GCC_DIR)/stamp-gnatlib-rts
gnatmake-re gnatlink-re
# gnattools2
$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
- $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
+ $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools $(EXTRA_GNATTOOLS)
gnattools-cross: $(GCC_DIR)/stamp-tools
# gnattools1-re
--
2.35.3

View File

@@ -0,0 +1,41 @@
From b4c710af7f83e36caed1e2cc9ac4cd0198b44865 Mon Sep 17 00:00:00 2001
From: Alexey Pavlov <alexey.pawlow@gmail.com>
Date: Wed, 5 Aug 2015 23:36:19 +0100
Subject: [PATCH 07/15] Prettify linking -no-undefined
It might be better to put this change in a
conditional block for Windows only?
---
libgfortran/Makefile.am | 2 +-
libgfortran/Makefile.in | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
index 5ce0cd7cd05..bf072610679 100644
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -57,7 +57,7 @@ libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
cafexeclib_LTLIBRARIES = libcaf_single.la
cafexeclibdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
libcaf_single_la_SOURCES = caf/single.c
-libcaf_single_la_LDFLAGS = -static
+libcaf_single_la_LDFLAGS = -static -no-undefined
libcaf_single_la_DEPENDENCIES = caf/libcaf.h
libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS)
diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
index 7ac6bfba657..3ec67505073 100644
--- a/libgfortran/Makefile.in
+++ b/libgfortran/Makefile.in
@@ -766,7 +766,7 @@ libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
cafexeclib_LTLIBRARIES = libcaf_single.la
cafexeclibdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
libcaf_single_la_SOURCES = caf/single.c
-libcaf_single_la_LDFLAGS = -static
+libcaf_single_la_LDFLAGS = -static -no-undefined
libcaf_single_la_DEPENDENCIES = caf/libcaf.h
libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS)
@IEEE_SUPPORT_TRUE@fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
--
2.35.3

View File

@@ -0,0 +1,56 @@
From c084ab275f47cc27621e664d1c63e177525cf321 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse@126.com>
Date: Tue, 10 May 2022 13:19:07 +0800
Subject: [PATCH] Remove size limit of PCH
Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14940
Signed-off-by: LIU Hao <lh_mouse@126.com>
---
gcc/config/i386/host-mingw32.cc | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/gcc/config/i386/host-mingw32.cc b/gcc/config/i386/host-mingw32.cc
index 3b0d83ffc60..f915b85abd0 100644
--- a/gcc/config/i386/host-mingw32.cc
+++ b/gcc/config/i386/host-mingw32.cc
@@ -44,9 +44,6 @@ static size_t mingw32_gt_pch_alloc_granularity (void);
static inline void w32_error(const char*, const char*, int, const char*);
-/* FIXME: Is this big enough? */
-static const size_t pch_VA_max_size = 128 * 1024 * 1024;
-
/* Granularity for reserving address space. */
static size_t va_granularity = 0x10000;
@@ -88,9 +85,6 @@ static void *
mingw32_gt_pch_get_address (size_t size, int)
{
void* res;
- size = (size + va_granularity - 1) & ~(va_granularity - 1);
- if (size > pch_VA_max_size)
- return NULL;
/* FIXME: We let system determine base by setting first arg to NULL.
Allocating at top of available address space avoids unnecessary
@@ -100,7 +94,7 @@ mingw32_gt_pch_get_address (size_t size, int)
If we allocate at bottom we need to reserve the address as early
as possible and at the same point in each invocation. */
- res = VirtualAlloc (NULL, pch_VA_max_size,
+ res = VirtualAlloc (NULL, size,
MEM_RESERVE | MEM_TOP_DOWN,
PAGE_NOACCESS);
if (!res)
@@ -150,7 +144,7 @@ mingw32_gt_pch_use_address (void *&addr, size_t size, int fd,
/* Offset must be also be a multiple of allocation granularity for
this to work. We can't change the offset. */
- if ((offset & (va_granularity - 1)) != 0 || size > pch_VA_max_size)
+ if ((offset & (va_granularity - 1)) != 0)
return -1;
--
2.36.0

View File

@@ -0,0 +1,39 @@
From cbe4bbcd9261c2b6d4bb02025685b2047bac4e6d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCrgen=20Pfeifer?= <juergen@familiepfeifer.de>
Date: Wed, 5 Aug 2015 23:36:27 +0100
Subject: [PATCH 09/15] Enable shared gnat implib
Provide GNAT runtime import libraries to
allow to link against shared runtime
Original commit:
https://github.com/Alexpux/MINGW-packages/commit/51b4eb3b702fdb38df0460180c2f8209a686aaec
---
gcc/ada/gcc-interface/Makefile.in | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index 1e9801a8b96..a640e51df9d 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -769,13 +769,16 @@ gnatlib-shared-win32:
$(PICFLAG_FOR_TARGET) \
-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
- $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB)
+ $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ -Wl,-out-implib,libgnat$(hyphen)$(LIBRARY_VERSION).dll.a \
+ $(MISCLIB)
cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
| sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \
$(PICFLAG_FOR_TARGET) \
-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
$(GNATRTL_TASKING_OBJS) \
$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ -Wl,-out-implib,libgnarl$(hyphen)$(LIBRARY_VERSION).dll.a \
$(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
gnatlib-shared-darwin:
--
2.35.3

View File

@@ -0,0 +1,60 @@
From d40fdef088ea568820d6355d416a04794c2291dc Mon Sep 17 00:00:00 2001
From: Olivier Michel <Olivier.Michel@cyberbotics.com>
Date: Fri, 31 May 2019 15:07:06 +0200
Subject: [PATCH 10/15] Handle spaces in path for default manifest
---
gcc/gcc.cc | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index bb07cc244e3..07f07c1f26f 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -6871,7 +6871,6 @@ eval_spec_function (const char *func, const char *args,
int save_arg_going;
int save_delete_this_arg;
int save_this_is_output_file;
- int save_this_is_library_file;
int save_input_from_pipe;
int save_this_is_linker_script;
const char *save_suffix_subst;
@@ -6889,7 +6888,6 @@ eval_spec_function (const char *func, const char *args,
save_arg_going = arg_going;
save_delete_this_arg = delete_this_arg;
save_this_is_output_file = this_is_output_file;
- save_this_is_library_file = this_is_library_file;
save_this_is_linker_script = this_is_linker_script;
save_input_from_pipe = input_from_pipe;
save_suffix_subst = suffix_subst;
@@ -6921,13 +6919,15 @@ eval_spec_function (const char *func, const char *args,
argbuf.address ());
/* Pop the spec processing context. */
+ const char *saved_library_file = this_is_library_file ? argbuf.address()[0] : NULL;
argbuf.release ();
argbuf = save_argbuf;
+ if (saved_library_file)
+ argbuf.safe_push (saved_library_file);
arg_going = save_arg_going;
delete_this_arg = save_delete_this_arg;
this_is_output_file = save_this_is_output_file;
- this_is_library_file = save_this_is_library_file;
this_is_linker_script = save_this_is_linker_script;
input_from_pipe = save_input_from_pipe;
suffix_subst = save_suffix_subst;
@@ -6999,8 +6999,9 @@ handle_spec_function (const char *p, bool *retval_nonnull,
/* p now points to just past the end of the spec function expression. */
funcval = eval_spec_function (func, args, soft_matched_part);
- if (funcval != NULL && do_spec_1 (funcval, 0, NULL) < 0)
+ if (funcval != NULL && this_is_library_file == 0 && do_spec_1 (funcval, 0, NULL) < 0)
p = NULL;
+
if (retval_nonnull)
*retval_nonnull = funcval != NULL;
--
2.35.3

View File

@@ -0,0 +1,108 @@
From e2020cc059570a3c275ba78fe3c8a7bc6f746e50 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Mon, 17 Aug 2015 22:57:46 +0100
Subject: [PATCH 11/15] clone_function_name_1: Retain any stdcall suffix
Previously, clone_function_name_1 would add a suffix after
any existing stdcall suffix, for example ipa-split.c would
clone test@4 as test@4.part.0.
Later, i386_pe_strip_name_encoding_full would come along
and strip off everything from the last @ onwards which had
the effect of generating incorrect section names which
would then fall over with errors such as:
error: void test() causes a section type conflict with \
void test@4.part.0()
The following testcase, reduced from Firefox can be used
to reproduce this.
test.ii:
class ClassA {
public:
virtual int __attribute__((__stdcall__)) Dispatch() = 0;
};
class ClassB {
public:
ClassA* __attribute__((__stdcall__)) operator->();
};
class ClassC : ClassA {
int *some_int_ptr_variable;
int __attribute__((__stdcall__)) Dispatch() {
return some_int_ptr_variable
? 42
: m_ClassInstanceB->Dispatch();
}
ClassB m_ClassInstanceB;
};
ClassC ClassInstanceC;
Compile for i686-w64-mingw32 with:
cc1plus -O -fpartial-inlining -fdevirtualize \
-fdevirtualize-speculatively test.ii
Outputs:
test.ii: In member function 'virtual int ClassC::Dispatch()':
test.ii:11:36: error: virtual int ClassC::Dispatch() causes \
a section type conflict with int ClassC::_ZN6ClassC8DispatchEv@4.part.0()
int __attribute__((CALLTYPE)) Dispatch() {
^
test.ii:11:36: note: \
'int ClassC::_ZN6ClassC8DispatchEv@4.part.0()' was declared here
---
gcc/cgraphclones.cc | 14 +++++++++++++-
gcc/defaults.h | 2 +-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc
index eb0fa87b554..a959040033e 100644
--- a/gcc/cgraphclones.cc
+++ b/gcc/cgraphclones.cc
@@ -470,7 +470,8 @@ static GTY(()) hash_map<const char *, unsigned> *clone_fn_ids;
each NAME) unspecified number. If clone numbering is not needed
then the two argument clone_function_name should be used instead.
Should not be called directly except for by
- lto-partition.cc:privatize_symbol_name_1. */
+ lto-partition.cc:privatize_symbol_name_1. Final stdcall @N suffixes
+ are maintained. */
tree
clone_function_name_numbered (const char *name, const char *suffix)
@@ -511,10 +512,20 @@ clone_function_name (const char *name, const char *suffix,
char *tmp_name, *prefix;
prefix = XALLOCAVEC (char, len + strlen (suffix) + 2);
+ /* name + 1 to skip fastcall which begins with '@' */
+ const char *at_suffix = strchr (name + 1, '@');
+ size_t at_suffix_len = 0;
+ if (at_suffix)
+ {
+ at_suffix_len = strlen (at_suffix);
+ len -= at_suffix_len;
+ }
memcpy (prefix, name, len);
strcpy (prefix + len + 1, suffix);
prefix[len] = symbol_table::symbol_suffix_separator ();
ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, number);
+ if (at_suffix)
+ strcat (tmp_name, at_suffix);
return get_identifier (tmp_name);
}
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 7c7a80e596e..c47b32ad49e 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -51,7 +51,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
do { const char *const name_ = (NAME); \
char *const output_ = (OUTPUT) = \
- (char *) alloca (strlen (name_) + 32); \
+ (char *) alloca (strlen (name_) + 35); \
sprintf (output_, ASM_PN_FORMAT, name_, (unsigned long)(LABELNO)); \
} while (0)
#endif
--
2.35.3

View File

@@ -0,0 +1,53 @@
From 4617711110effcb0902857d70b9aa13d39b57c0d Mon Sep 17 00:00:00 2001
From: Liu Hao <lh_mouse@126.com>
Date: Wed, 6 May 2020 21:49:18 +0800
Subject: [PATCH 12/15] libgomp: Don't hard-code MS printf attributes
---
libgomp/libgomp.h | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h
index b9e03919993..bf28ef66e27 100644
--- a/libgomp/libgomp.h
+++ b/libgomp/libgomp.h
@@ -69,6 +69,13 @@
# endif
#endif
+#include <stdio.h>
+#ifdef __MINGW_PRINTF_FORMAT
+#define PRINTF_FORMAT __MINGW_PRINTF_FORMAT
+#else
+#define PRINTF_FORMAT printf
+#endif
+
#ifdef HAVE_ATTRIBUTE_VISIBILITY
# pragma GCC visibility push(hidden)
#endif
@@ -177,7 +184,7 @@ team_free (void *ptr)
extern void gomp_vdebug (int, const char *, va_list);
extern void gomp_debug (int, const char *, ...)
- __attribute__ ((format (printf, 2, 3)));
+ __attribute__ ((format (PRINTF_FORMAT, 2, 3)));
#define gomp_vdebug(KIND, FMT, VALIST) \
do { \
if (__builtin_expect (gomp_debug_var, 0)) \
@@ -190,11 +197,11 @@ extern void gomp_debug (int, const char *, ...)
} while (0)
extern void gomp_verror (const char *, va_list);
extern void gomp_error (const char *, ...)
- __attribute__ ((format (printf, 1, 2)));
+ __attribute__ ((format (PRINTF_FORMAT, 1, 2)));
extern void gomp_vfatal (const char *, va_list)
__attribute__ ((noreturn));
extern void gomp_fatal (const char *, ...)
- __attribute__ ((noreturn, format (printf, 1, 2)));
+ __attribute__ ((noreturn, format (PRINTF_FORMAT, 1, 2)));
struct gomp_task;
struct gomp_taskgroup;
--
2.35.3

View File

@@ -0,0 +1,76 @@
From 525fd24cc877e2f3f66817908ed0bfec425a473f Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse@126.com>
Date: Wed, 11 May 2022 22:42:53 +0800
Subject: [PATCH] [PR14940] Allow a PCH to be mapped to a different address
First, try mapping the PCH to its original address. If that fails, try
letting the system choose one; the PCH can be relocated thereafter.
Reference: https://gcc.gnu.org/pipermail/gcc-patches/2022-May/594556.html
2022-05-11 LIU Hao <lh_mouse@126.com>
PR pch/14940
* config/i386/host-mingw32.cc (mingw32_gt_pch_use_address):
Replace the loop that attempted to map the PCH only to its
original address with more adaptive operations
---
gcc/config/i386/host-mingw32.cc | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/gcc/config/i386/host-mingw32.cc b/gcc/config/i386/host-mingw32.cc
index 3b0d83ffc606..ec92483b7835 100644
--- a/gcc/config/i386/host-mingw32.cc
+++ b/gcc/config/i386/host-mingw32.cc
@@ -141,7 +141,6 @@ mingw32_gt_pch_use_address (void *&addr, size_t size, int fd,
and earlier, backslashes are invalid in object name. So, we need
to check if we are on Windows2000 or higher. */
OSVERSIONINFO version_info;
- int r;
version_info.dwOSVersionInfoSize = sizeof (version_info);
@@ -175,25 +174,24 @@ mingw32_gt_pch_use_address (void *&addr, size_t size, int fd,
return -1;
}
- /* Retry five times, as here might occure a race with multiple gcc's
- instances at same time. */
- for (r = 0; r < 5; r++)
- {
- mmap_addr = MapViewOfFileEx (mmap_handle, FILE_MAP_COPY, 0, offset,
- size, addr);
- if (mmap_addr == addr)
- break;
- if (r != 4)
- Sleep (500);
- }
-
- if (mmap_addr != addr)
+ /* Try mapping the file at `addr`. */
+ mmap_addr = MapViewOfFileEx (mmap_handle, FILE_MAP_COPY, 0, offset,
+ size, addr);
+ if (mmap_addr == NULL)
{
- w32_error (__FUNCTION__, __FILE__, __LINE__, "MapViewOfFileEx");
- CloseHandle(mmap_handle);
- return -1;
+ /* We could not map the file at its original address, so let the
+ system choose a different one. The PCH can be relocated later. */
+ mmap_addr = MapViewOfFileEx (mmap_handle, FILE_MAP_COPY, 0, offset,
+ size, NULL);
+ if (mmap_addr == NULL)
+ {
+ w32_error (__FUNCTION__, __FILE__, __LINE__, "MapViewOfFileEx");
+ CloseHandle(mmap_handle);
+ return -1;
+ }
}
+ addr = mmap_addr;
return 1;
}
--
2.36.1

View File

@@ -0,0 +1,44 @@
diff --git a/gcc/diagnostic-color.cc b/gcc/diagnostic-color.cc
index 640adfad5..f5eaf142a 100644
--- a/gcc/diagnostic-color.cc
+++ b/gcc/diagnostic-color.cc
@@ -211,9 +211,38 @@ should_colorize (void)
HANDLE h;
DWORD m;
+ bool ret = false;
h = GetStdHandle (STD_ERROR_HANDLE);
- return (h != INVALID_HANDLE_VALUE) && (h != NULL)
+ ret = (h != INVALID_HANDLE_VALUE) && (h != NULL)
&& GetConsoleMode (h, &m);
+
+ if (!ret)
+ {
+ ULONG size = sizeof (FILE_NAME_INFO) + (MAX_PATH * sizeof (wchar_t));
+ FILE_NAME_INFO *fni = (FILE_NAME_INFO*) xmalloc (size);
+ if (GetFileInformationByHandleEx (h, FileNameInfo, fni, size))
+ {
+ wchar_t name_msys[] = L"\\msys";
+ size_t len_msys = sizeof (name_msys) - sizeof (wchar_t);
+ wchar_t name_cyg[] = L"\\cygwin";
+ size_t len_cyg = sizeof (name_cyg) - sizeof (wchar_t);
+ wchar_t name_dir[] = L"-to-master";
+ size_t len_dir = sizeof (name_dir) - sizeof (wchar_t);
+
+ if (fni->FileNameLength >= len_cyg + len_dir)
+ {
+ size_t offset = 0;
+ if (!memcmp (fni->FileName, name_msys, len_msys))
+ offset = len_msys / sizeof (wchar_t);
+ else if (!memcmp (fni->FileName, name_cyg, len_cyg))
+ offset = len_cyg / sizeof (wchar_t);
+
+ ret = (offset > 0) && (wcsstr (fni->FileName + offset, name_dir) != NULL);
+ }
+ }
+ free (fni);
+ }
+ return ret;
#else
char const *t = getenv ("TERM");
/* emacs M-x shell sets TERM="dumb". */

View File

@@ -0,0 +1,191 @@
From 20897cd296f35272c4fca4f0f5f7bb48e6242758 Mon Sep 17 00:00:00 2001
From: Kai Tietz <ktietz@anaconda.com>
Date: Wed, 21 Apr 2021 07:54:59 +0200
Subject: [PATCH 13/15] add -m(no-)align-vector-insn option for i386
---
gcc/config/i386/i386-options.cc | 9 +++++--
gcc/config/i386/i386.opt | 8 ++++++
gcc/config/i386/mingw32.h | 2 +-
gcc/config/i386/predicates.md | 2 +-
gcc/config/i386/sse.md | 43 +++++++++++++++++++++++++++++----
5 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index 32cc58a764b..07e33f3d344 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -384,6 +384,7 @@ ix86_target_string (HOST_WIDE_INT isa, HOST_WIDE_INT isa2,
{ "-minline-stringops-dynamically", MASK_INLINE_STRINGOPS_DYNAMICALLY },
{ "-mms-bitfields", MASK_MS_BITFIELD_LAYOUT },
{ "-mno-align-stringops", MASK_NO_ALIGN_STRINGOPS },
+ { "-mno-align-vector-insn", MASK_NO_ALIGN_VECTOR_INSN },
{ "-mno-fancy-math-387", MASK_NO_FANCY_MATH_387 },
{ "-mno-push-args", MASK_NO_PUSH_ARGS },
{ "-mno-red-zone", MASK_NO_RED_ZONE },
@@ -1100,8 +1101,12 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
MASK_INLINE_STRINGOPS_DYNAMICALLY),
IX86_ATTR_NO ("align-stringops",
- OPT_mno_align_stringops,
- MASK_NO_ALIGN_STRINGOPS),
+ OPT_mno_align_stringops,
+ MASK_NO_ALIGN_STRINGOPS),
+
+ IX86_ATTR_NO ("align-vector-insn",
+ OPT_mno_align_vector_insn,
+ MASK_NO_ALIGN_VECTOR_INSN),
IX86_ATTR_YES ("recip",
OPT_mrecip,
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index a6b0e28f238..2ba61b0e4ea 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -241,6 +241,10 @@ malign-stringops
Target RejectNegative InverseMask(NO_ALIGN_STRINGOPS, ALIGN_STRINGOPS) Save
Align destination of the string operations.
+malign-vector-insn
+Target RejectNegative InverseMask(NO_ALIGN_VECTOR_INSN, ALIGN_VECTOR_INSN) Save
+Use aligned vector instruction
+
malign-data=
Target RejectNegative Joined Var(ix86_align_data_type) Enum(ix86_align_data) Init(ix86_align_data_type_compat)
Use the given data alignment.
@@ -420,6 +424,10 @@ mpc80
Target RejectNegative
Set 80387 floating-point precision to 80-bit.
+mno-align-vector-insn
+Target Mask(NO_ALIGN_VECTOR_INSN) Save
+Uses unaligned over aligned vector instruction memonics
+
mpreferred-stack-boundary=
Target RejectNegative Joined UInteger Var(ix86_preferred_stack_boundary_arg)
Attempt to keep stack aligned to this power of 2.
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
index 07dcd6ba97b..217230de7d1 100644
--- a/gcc/config/i386/mingw32.h
+++ b/gcc/config/i386/mingw32.h
@@ -30,7 +30,7 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_SUBTARGET_DEFAULT \
(MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS \
| MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \
- | MASK_MS_BITFIELD_LAYOUT)
+ | MASK_MS_BITFIELD_LAYOUT | MASK_NO_ALIGN_VECTOR_INSN)
/* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
is for compatibility with native compiler. */
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index a8cc17a054d..dacf9ae9564 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -1556,7 +1556,7 @@
;; less than its natural alignment.
(define_predicate "misaligned_operand"
(and (match_code "mem")
- (match_test "MEM_ALIGN (op) < GET_MODE_BITSIZE (mode)")))
+ (match_test "TARGET_NO_ALIGN_VECTOR_INSN || MEM_ALIGN (op) < GET_MODE_BITSIZE (mode)")))
;; Return true if OP is a parallel for an mov{d,q,dqa,ps,pd} vec_select,
;; where one of the two operands of the vec_concat is const0_operand.
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 5e93aa23b47..4bcc048a351 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -1705,7 +1705,8 @@
(vec_concat:V2DF (vec_select:DF (match_dup 2)
(parallel [(const_int 0)]))
(match_operand:DF 3 "memory_operand")))]
- "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
+ "TARGET_SSE2
+ && (TARGET_SSE_UNALIGNED_LOAD_OPTIMAL || TARGET_NO_ALIGN_VECTOR_INSN)
&& ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
[(set (match_dup 2) (match_dup 5))]
"operands[5] = adjust_address (operands[1], V2DFmode, 0);")
@@ -1716,7 +1717,8 @@
(set (match_operand:V2DF 2 "sse_reg_operand")
(vec_concat:V2DF (match_operand:DF 4 "sse_reg_operand")
(match_operand:DF 3 "memory_operand")))]
- "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
+ "TARGET_SSE2
+ && (TARGET_SSE_UNALIGNED_LOAD_OPTIMAL || TARGET_NO_ALIGN_VECTOR_INSN)
&& REGNO (operands[4]) == REGNO (operands[2])
&& ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
[(set (match_dup 2) (match_dup 5))]
@@ -1730,7 +1732,8 @@
(set (match_operand:DF 2 "memory_operand")
(vec_select:DF (match_operand:V2DF 3 "sse_reg_operand")
(parallel [(const_int 1)])))]
- "TARGET_SSE2 && TARGET_SSE_UNALIGNED_STORE_OPTIMAL
+ "TARGET_SSE2
+ && (TARGET_SSE_UNALIGNED_STORE_OPTIMAL || TARGET_NO_ALIGN_VECTOR_INSN)
&& ix86_operands_ok_for_move_multiple (operands, false, DFmode)"
[(set (match_dup 4) (match_dup 1))]
"operands[4] = adjust_address (operands[0], V2DFmode, 0);")
@@ -10310,7 +10313,8 @@
(vec_select:V2SF
(match_operand:V4SF 1 "nonimmediate_operand" " v,v,m")
(parallel [(const_int 0) (const_int 1)])))]
- "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
+ "TARGET_SSE && TARGET_ALIGN_VECTOR_INSN
+ && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
"@
%vmovlps\t{%1, %0|%q0, %1}
%vmovaps\t{%1, %0|%0, %1}
@@ -10319,6 +10323,21 @@
(set_attr "prefix" "maybe_vex")
(set_attr "mode" "V2SF,V4SF,V2SF")])
+(define_insn "sse_storelps_unalign"
+ [(set (match_operand:V2SF 0 "nonimmediate_operand" "=m,v,v")
+ (vec_select:V2SF
+ (match_operand:V4SF 1 "nonimmediate_operand" " v,v,m")
+ (parallel [(const_int 0) (const_int 1)])))]
+ "TARGET_SSE && TARGET_NO_ALIGN_VECTOR_INSN
+ && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
+ "@
+ %vmovlps\t{%1, %0|%q0, %1}
+ %vmovups\t{%1, %0|%0, %1}
+ %vmovlps\t{%1, %d0|%d0, %q1}"
+ [(set_attr "type" "ssemov")
+ (set_attr "prefix" "maybe_vex")
+ (set_attr "mode" "V2SF,V4SF,V2SF")])
+
(define_expand "sse_loadlps_exp"
[(set (match_operand:V4SF 0 "nonimmediate_operand")
(vec_concat:V4SF
@@ -13131,7 +13150,7 @@
(vec_select:DF
(match_operand:V2DF 1 "nonimmediate_operand" "x,x,m")
(parallel [(const_int 0)])))]
- "!TARGET_SSE2 && TARGET_SSE
+ "!TARGET_SSE2 && TARGET_SSE && TARGET_ALIGN_VECTOR_INSN
&& !(MEM_P (operands[0]) && MEM_P (operands[1]))"
"@
movlps\t{%1, %0|%0, %1}
@@ -13140,6 +13159,20 @@
[(set_attr "type" "ssemov")
(set_attr "mode" "V2SF,V4SF,V2SF")])
+(define_insn "*vec_extractv2df_0_sse_unalign"
+ [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
+ (vec_select:DF
+ (match_operand:V2DF 1 "nonimmediate_operand" "x,x,m")
+ (parallel [(const_int 0)])))]
+ "!TARGET_SSE2 && TARGET_SSE && TARGET_NO_ALIGN_VECTOR_INSN
+ && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
+ "@
+ movlps\t{%1, %0|%0, %1}
+ movups\t{%1, %0|%0, %1}
+ movlps\t{%1, %0|%0, %q1}"
+ [(set_attr "type" "ssemov")
+ (set_attr "mode" "V2SF,V4SF,V2SF")])
+
(define_expand "sse2_loadhpd_exp"
[(set (match_operand:V2DF 0 "nonimmediate_operand")
(vec_concat:V2DF
--
2.35.3

View File

@@ -0,0 +1,122 @@
From bcbea3d668db5c836826a1758cc997cbbc9069de Mon Sep 17 00:00:00 2001
From: Tomas Kalibera <tomas.kalibera@gmail.com>
Date: Thu, 13 Jan 2022 05:25:32 -0500
Subject: [PATCH 14/15] c-family: Let stdio.h override built in printf format
[PR95130,PR92292]
Mingw32 targets use ms_printf format for printf, but mingw-w64 when
configured for UCRT uses gnu_format (via stdio.h). GCC then checks both
formats, which means that one cannot print a 64-bit integer without a
warning. All these lines issue a warning:
printf("Hello %"PRIu64"\n", x);
printf("Hello %I64u\n", x);
printf("Hello %llu\n", x);
because each of them violates one of the formats. Also, one gets a warning
twice if the format string violates both formats.
Fixed by disabling the built in format in case there are additional ones.
gcc/c-family/ChangeLog:
PR c/95130
PR c/92292
* c-common.c (check_function_arguments): Pass also function
declaration to check_function_format.
* c-common.h (check_function_format): Extra argument - function
declaration.
* c-format.c (check_function_format): For builtin functions with a
built in format and at least one more, do not check the first one.
---
gcc/c-family/c-common.cc | 2 +-
gcc/c-family/c-common.h | 2 +-
gcc/c-family/c-format.cc | 32 ++++++++++++++++++++++++++++++--
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index bb0544eeaea..a063468f26d 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -6071,7 +6071,7 @@ check_function_arguments (location_t loc, const_tree fndecl, const_tree fntype,
/* Check for errors in format strings. */
if (warn_format || warn_suggest_attribute_format)
- check_function_format (fntype, TYPE_ATTRIBUTES (fntype), nargs, argarray,
+ check_function_format (fndecl, fntype, TYPE_ATTRIBUTES (fntype), nargs, argarray,
arglocs);
if (warn_format)
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 52a85bfb783..7b8c87bec19 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -857,7 +857,7 @@ extern void check_function_arguments_recurse (void (*)
opt_code);
extern bool check_builtin_function_arguments (location_t, vec<location_t>,
tree, tree, int, tree *);
-extern void check_function_format (const_tree, tree, int, tree *,
+extern void check_function_format (const_tree, const_tree, tree, int, tree *,
vec<location_t> *);
extern bool attribute_fallthrough_p (tree);
extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc
index 98f28c0dcc6..f3adcf9642d 100644
--- a/gcc/c-family/c-format.cc
+++ b/gcc/c-family/c-format.cc
@@ -1160,12 +1160,13 @@ decode_format_type (const char *s, bool *is_raw /* = NULL */)
attribute themselves. */
void
-check_function_format (const_tree fntype, tree attrs, int nargs,
+check_function_format (const_tree fndecl, const_tree fntype, tree attrs, int nargs,
tree *argarray, vec<location_t> *arglocs)
{
- tree a;
+ tree a, aa;
tree atname = get_identifier ("format");
+ bool skipped_default_format = false;
/* See if this function has any format attributes. */
for (a = attrs; a; a = TREE_CHAIN (a))
@@ -1176,6 +1177,33 @@ check_function_format (const_tree fntype, tree attrs, int nargs,
function_format_info info;
decode_format_attr (fntype, atname, TREE_VALUE (a), &info,
/*validated=*/true);
+
+ /* Mingw32 targets have traditionally used ms_printf format for the
+ printf function, and this format is built in GCC. But nowadays,
+ if mingw-w64 is configured to target UCRT, the printf function
+ uses the gnu_printf format (specified in the stdio.h header). This
+ causes GCC to check both formats, which means that there is no way
+ to e.g. print a long long unsigned without a warning (ms_printf
+ warns for %llu and gnu_printf warns for %I64u). Also, GCC would warn
+ twice about the same issue when both formats are violated, e.g.
+ for %lu used to print long long unsigned.
+
+ Hence, if there are multiple format specifiers, we skip the first
+ one. See PR 95130, PR 92292. */
+
+ if (!skipped_default_format && fndecl)
+ {
+ for(aa = TREE_CHAIN (a); aa; aa = TREE_CHAIN(aa))
+ if (is_attribute_p ("format", get_attribute_name (aa)) &&
+ fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
+ {
+ skipped_default_format = true;
+ break;
+ }
+ if (skipped_default_format)
+ continue;
+ }
+
if (warn_format)
{
/* FIXME: Rewrite all the internal functions in this file
--
2.35.3

View File

@@ -0,0 +1,36 @@
From 2f8227361a671f41b21fdd70ee40866c5f32ee86 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Fri, 27 May 2022 10:42:08 +0200
Subject: [PATCH 1/2] libgomp: use _aligned_free in gomp_aligned_free()if
needed
gomp_aligned_alloc() currently uses the Windows aligned allocation API
_aligned_malloc() when available, but unlike other APIs on other platform
this one allocates memory that can't be freed with free(), but requires
the special _aligned_free() or things can crash.
Fix by using _aligned_free() in gomp_aligned_free() if gomp_aligned_alloc()
uses _aligned_malloc().
---
libgomp/alloc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libgomp/alloc.c b/libgomp/alloc.c
index a2a25befdf3..67569192130 100644
--- a/libgomp/alloc.c
+++ b/libgomp/alloc.c
@@ -105,7 +105,11 @@ void
gomp_aligned_free (void *ptr)
{
#ifdef GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC
+#ifdef HAVE__ALIGNED_MALLOC
+ _aligned_free (ptr);
+#else
free (ptr);
+#endif
#else
if (ptr)
free (((void **) ptr)[-1]);
--
2.36.1

View File

@@ -0,0 +1,37 @@
From 8aa5b026a777cf038fe3f14b9e23b9b638c2f7ae Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Fri, 27 May 2022 10:45:34 +0200
Subject: [PATCH 2/2] libgomp: don't use GOMP_USE_ALIGNED_WORK_SHARES on
Windows
In case GOMP_USE_ALIGNED_WORK_SHARES is defined, various places
use gomp_aligned_alloc() instead of normal allocations, but then don't
use gomp_aligned_free() in the end, but normal free.
On most platforms this doesn't make a difference, but on Windows
gomp_aligned_alloc() and free() can't be mixed and free() might crash.
Work around this for now by disabling GOMP_USE_ALIGNED_WORK_SHARES
in those cases and add a note on what needs to be done to fix it.
---
libgomp/libgomp.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h
index b9e03919993..7b33465754c 100644
--- a/libgomp/libgomp.h
+++ b/libgomp/libgomp.h
@@ -95,7 +95,9 @@ enum memmodel
#define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC 1
#endif
-#if defined(GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC) && !defined(__AMDGCN__)
+/* FIXME: Disabled for HAVE__ALIGNED_MALLOC because that needs matching gomp_aligned_free() calls
+ for every gomp_aligned_alloc() and that's still missing in various places */
+#if defined(GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC) && !defined(__AMDGCN__) && !defined(HAVE__ALIGNED_MALLOC)
#define GOMP_USE_ALIGNED_WORK_SHARES 1
#endif
--
2.36.1

521
mingw-w64-gcc-12/PKGBUILD Normal file
View File

@@ -0,0 +1,521 @@
# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Alexey Borzenkov <snaury@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>
# Contributor: wirx6 <wirx654@gmail.com>
# Contributor: Kirill Müller <krlmlr@mailbox.org>
_enable_ada=yes
_enable_objc=yes
_enable_jit=yes
_threads="posix"
_realname=gcc
pkgbase=mingw-w64-${_realname}12
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}"
"${MINGW_PACKAGE_PREFIX}-${_realname}-libs"
"${MINGW_PACKAGE_PREFIX}-${_realname}-libgfortran"
"${MINGW_PACKAGE_PREFIX}-${_realname}-fortran"
$([[ "$_enable_ada" == "yes" ]] && echo "${MINGW_PACKAGE_PREFIX}-${_realname}-ada")
$([[ "$_enable_objc" == "yes" ]] && echo "${MINGW_PACKAGE_PREFIX}-${_realname}-objc")
$([[ "$_enable_jit" == "yes" ]] && echo "${MINGW_PACKAGE_PREFIX}-libgccjit")
)
#_snapshot=20181214
pkgver=12.2.0
#_majorver=${pkgver:0:1}
#_sourcedir=${_realname}-${_majorver}-${_snapshot}
_sourcedir=${_realname}-${pkgver}
pkgrel=12
pkgdesc="GCC for the MinGW-w64"
arch=('any')
mingw_arch=('mingw32')
url="https://gcc.gnu.org"
license=('GPL' 'LGPL' 'FDL' 'custom')
groups=("${MINGW_PACKAGE_PREFIX}-toolchain")
makedepends=("${MINGW_PACKAGE_PREFIX}-${_realname}"
$([[ "$_enable_ada" == "yes" ]] && echo "${MINGW_PACKAGE_PREFIX}-${_realname}-ada")
"${MINGW_PACKAGE_PREFIX}-binutils"
"${MINGW_PACKAGE_PREFIX}-crt"
"${MINGW_PACKAGE_PREFIX}-headers"
"${MINGW_PACKAGE_PREFIX}-gmp"
"${MINGW_PACKAGE_PREFIX}-isl"
"${MINGW_PACKAGE_PREFIX}-libiconv"
"${MINGW_PACKAGE_PREFIX}-mpc"
"${MINGW_PACKAGE_PREFIX}-mpfr"
"${MINGW_PACKAGE_PREFIX}-windows-default-manifest"
"${MINGW_PACKAGE_PREFIX}-winpthreads"
"${MINGW_PACKAGE_PREFIX}-zlib"
"${MINGW_PACKAGE_PREFIX}-zstd"
"${MINGW_PACKAGE_PREFIX}-gperf"
"${MINGW_PACKAGE_PREFIX}-autotools")
options=('!emptydirs') # '!strip' 'debug')
source=("https://ftp.gnu.org/gnu/gcc/${_realname}-${pkgver%%+*}/${_realname}-${pkgver}.tar.xz"{,.sig}
#https://www.mirrorservice.org/sites/sourceware.org/pub/gcc/snapshots/${_majorver}-${_snapshot}/gcc-${_majorver}-${_snapshot}.tar.xz
"gdbinit"
0002-Relocate-libintl.patch
0003-Windows-Follow-Posix-dir-exists-semantics-more-close.patch
0004-Windows-Use-not-in-progpath-and-leave-case-as-is.patch
0005-Windows-Don-t-ignore-native-system-header-dir.patch
0006-Windows-New-feature-to-allow-overriding.patch
0007-Build-EXTRA_GNATTOOLS-for-Ada.patch
0008-Prettify-linking-no-undefined.patch
0010-Fix-using-large-PCH.patch
0011-Enable-shared-gnat-implib.patch
0012-Handle-spaces-in-path-for-default-manifest.patch
0014-gcc-9-branch-clone_function_name_1-Retain-any-stdcall-suffix.patch
0020-libgomp-Don-t-hard-code-MS-printf-attributes.patch
0021-PR14940-Allow-a-PCH-to-be-mapped-to-a-different-addr.patch
0140-gcc-diagnostic-color.patch
0200-add-m-no-align-vector-insn-option-for-i386.patch
0300-override-builtin-printf-format.patch)
sha256sums=('e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff'
'SKIP'
'bce81824fc89e5e62cca350de4c17a27e27a18a1a1ad5ca3492aec1fc5af3234'
'2c1a5fdb39d8ecf449632b0ebdd4b41bf9e070aea4093f299513cad95484b5c3'
'3f55d6493d459f6b875f750735231df140339b62eb0d2cc5edfbf10332c1bd5f'
'be1dd73bca4e802df5e263a2b27355c3b42d7298491b94fdcc35e00be2e2cb68'
'2a208d5b13f370c6b2187c7932a13d6caedfc3722f02afc8e5ee9426fb8e64cc'
'56832cb8f939fe14eaadf8fb2d4c784012acc87e1661320398b42b7389643bb7'
'87472619bb0f9520cce20e3e5f5f57b9ab1fbea297bc81cb00216697d64084b1'
'd7066b206d7b4d81a25d4f9c2ee88751e041b81176d915d8175b9b85f5cbc425'
'acaf6f1b8df91bf0fe7c363b2abd10c2f7b967b563761160892559358da9bf91'
'b1ddd82c9a4f0cd7ba3a4877510b56b019304d04ed1d804626eb511ae206dd60'
'0483451eaed8b36b8fbdc30d10a04d73424d58ca83dde0320902d39f0ef623a6'
'b3c6dc1fe61ba3c46d15b5bd38f4a94cd8133923eb9832679944f534d46f7318'
'a501666d1f5cae726f2b2f1618d187a397c3525c0ffa1bcb03a441fd8e8020cf'
'a4b4f7e97635ddf0443ee17cd093b9d10953f97eb290466999585d02ef8bf72d'
'e0a5b470f49a29f20215cc9f9d04c1cb9969dff6f0e546542799d3a693ef1c84'
'ce832a1be7271a2249e4dd46647474b37cf51f578678d9bd9433b32aacefb528'
'0d82cf1d748c9f1d4d3c7ee43ca3be1b6efbd431dc13ce652ae00ee489d67eec')
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
# Helper macros to help make tasks easier #
apply_patch_with_msg() {
for _patch in "$@"
do
msg2 "Applying ${_patch}"
patch -Nbp1 -i "${srcdir}/${_patch}"
done
}
del_file_exists() {
for _fname in "$@"
do
if [ -f ${_fname} ]; then
rm -rf ${_fname}
fi
done
}
# =========================================== #
prepare() {
cd ${srcdir}/${_sourcedir}
del_file_exists intl/canonicalize.c intl/canonicalize.h \
intl/relocatex.c intl/relocatex.h
apply_patch_with_msg \
0002-Relocate-libintl.patch \
0003-Windows-Follow-Posix-dir-exists-semantics-more-close.patch \
0004-Windows-Use-not-in-progpath-and-leave-case-as-is.patch \
0005-Windows-Don-t-ignore-native-system-header-dir.patch \
0006-Windows-New-feature-to-allow-overriding.patch \
0007-Build-EXTRA_GNATTOOLS-for-Ada.patch \
0008-Prettify-linking-no-undefined.patch \
0010-Fix-using-large-PCH.patch \
0011-Enable-shared-gnat-implib.patch \
0012-Handle-spaces-in-path-for-default-manifest.patch \
0014-gcc-9-branch-clone_function_name_1-Retain-any-stdcall-suffix.patch \
0020-libgomp-Don-t-hard-code-MS-printf-attributes.patch \
0021-PR14940-Allow-a-PCH-to-be-mapped-to-a-different-addr.patch
# Enable diagnostic color under mintty
# based on https://github.com/BurntSushi/ripgrep/issues/94#issuecomment-261761687
apply_patch_with_msg \
0140-gcc-diagnostic-color.patch
# workaround for AVX misalignment issue for pass-by-value arguments
# cf. https://github.com/msys2/MSYS2-packages/issues/1209
# cf. https://sourceforge.net/p/mingw-w64/discussion/723797/thread/bc936130/
# Issue is longstanding upstream at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412
# Potential alternative: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=939559
# https://github.com/msys2/MINGW-packages/pull/8317#issuecomment-824548411
apply_patch_with_msg \
0200-add-m-no-align-vector-insn-option-for-i386.patch
# Patch from https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588341.html
# Related bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95130
apply_patch_with_msg \
0300-override-builtin-printf-format.patch
# do not expect ${prefix}/mingw symlink - this should be superceded by
# 0005-Windows-Don-t-ignore-native-system-header-dir.patch .. but isn't!
sed -i 's/${prefix}\/mingw\//${prefix}\//g' configure
# change hardcoded /mingw prefix to the real prefix .. isn't this rubbish?
# it might work at build time and could be important there but beyond that?!
local MINGW_NATIVE_PREFIX=$(cygpath -am ${MINGW_PREFIX})
sed -i "s#\\/mingw\\/#${MINGW_NATIVE_PREFIX//\//\\/}\\/#g" gcc/config/i386/mingw32.h
}
build() {
mkdir -p ${srcdir}/build-${MSYSTEM} && cd ${srcdir}/build-${MSYSTEM}
declare -a extra_config
if check_option "debug" "n"; then
extra_config+=("--disable-libstdcxx-debug")
else
extra_config+=("--enable-libstdcxx-debug")
fi
case "${CARCH}" in
i686)
extra_config+=(
"--disable-sjlj-exceptions"
"--with-dwarf2"
)
LDFLAGS+=" -Wl,--large-address-aware"
local _arch=pentium4
;;
x86_64)
local _arch=nocona
;;
esac
local _languages="c,lto,c++,fortran"
if [ "$_enable_ada" == "yes" ]; then
_languages+=",ada"
fi
if [ "$_enable_objc" == "yes" ]; then
_languages+=",objc,obj-c++"
fi
if [ "$_enable_jit" == "yes" ]; then
_languages+=",jit"
fi
# so libgomp DLL gets built despide static libdl
export lt_cv_deplibs_check_method='pass_all'
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507#c3
# At least with mingw32 + dwarf-2 exceptions there can only be one libgcc in
# process, or exceptions will no longer work. Since some of the gcc deps are
# linked dynamically like gmp/zlib/zstd and those pull in libgcc we can't
# allow libgcc to be linked statically. The default is "-static-libstdc++
# -static-libgcc" for both, so we drop "-static-libgcc" here:
extra_config+=(
'--with-boot-ldflags="-static-libstdc++"'
'--with-stage1-ldflags="-static-libstdc++"'
)
# -fstack-protector-strong breaks libssp
# https://github.com/msys2/MINGW-packages/issues/13830
# TODO: This can be removed once we drop libssp all together
CFLAGS+=" -fno-stack-protector"
# TODO: remove this with gcc 13.x, which includes a proper fix:
# https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=902c755930326cb4405672aa3ea13c35c653cbff
CPPFLAGS+=" -DWIN32_LEAN_AND_MEAN"
# In addition adaint.c does `#include <accctrl.h>` which pulls in msxml.h, hacky hack:
CPPFLAGS+=" -DCOM_NO_WINDOWS_H"
../${_sourcedir}/configure \
--prefix=${MINGW_PREFIX} \
--with-local-prefix=${MINGW_PREFIX}/local \
--build=${MINGW_CHOST} \
--host=${MINGW_CHOST} \
--target=${MINGW_CHOST} \
--with-native-system-header-dir=${MINGW_PREFIX}/include \
--libexecdir=${MINGW_PREFIX}/lib \
--enable-bootstrap \
--enable-checking=release \
--with-arch=${_arch} \
--with-tune=generic \
--enable-languages=${_languages} \
--enable-shared \
--enable-static \
--enable-libatomic \
--enable-threads=${_threads} \
--enable-graphite \
--enable-fully-dynamic-string \
--enable-libstdcxx-filesystem-ts \
--enable-libstdcxx-time \
--disable-libstdcxx-pch \
--enable-lto \
--enable-libgomp \
--disable-multilib \
--disable-rpath \
--disable-win32-registry \
--disable-nls \
--disable-werror \
--disable-symvers \
--with-libiconv \
--with-system-zlib \
--with-{gmp,mpfr,mpc,isl}=${MINGW_PREFIX} \
--with-pkgversion="Rev${pkgrel}, Built by MSYS2 project" \
--with-bugurl="https://github.com/msys2/MINGW-packages/issues" \
--with-gnu-as \
--with-gnu-ld \
"${extra_config[@]}"
# While we're debugging -fopenmp problems at least.
# .. we may as well not strip anything.
if check_option "strip" "n"; then
sed -i 's,^STRIP = .*$,STRIP = true,g' Makefile
sed -i 's,^STRIP_FOR_TARGET=.*$,STRIP_FOR_TARGET=true,g' Makefile
fi
make V=1 all
rm -rf ${srcdir}${MINGW_PREFIX}
make -j1 DESTDIR=${srcdir} install
if [ "$_enable_ada" == "yes" ]; then
mv ${srcdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/adalib/*.dll ${srcdir}${MINGW_PREFIX}/bin/
fi
}
package_gcc-libs() {
pkgdesc="GNU Compiler Collection (libraries) for MinGW-w64"
depends=("${MINGW_PACKAGE_PREFIX}-libwinpthread")
provides=("${MINGW_PACKAGE_PREFIX}-libssp"
"${MINGW_PACKAGE_PREFIX}-omp")
# Licensing information
# Part of the package is GCCRLE, part is LGPL2+, see README generation below.
# Since the packaged GCCRLE libraries are also GPL3+, and LGPL2+ is compatible
# with GPL3+, the whole package can be redistributed under GPL3+.
license=(GPL3+ partial:'GCCRLE' partial:'LGPL2+')
# We explain the licensing in this generated README file
mkdir -p "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-libs"
cat << ENDFILE > "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-libs/README"
The libgcc, libssp, libstdc++, libgomp and libatomic libraries are covered by
GPL3+ with the GCC Runtime Library Exception. The libquadmath library is covered
by LGPL2+. The package as a whole can be redistributed under GPL3+.
ENDFILE
# License files
install -Dm644 "${srcdir}/${_sourcedir}/COPYING3" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-libs/COPYING3"
install -Dm644 "${srcdir}/${_sourcedir}/COPYING.LIB" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-libs/COPYING.LIB"
install -Dm644 "${srcdir}/${_sourcedir}/COPYING.RUNTIME" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-libs/COPYING.RUNTIME"
mkdir -p ${pkgdir}${MINGW_PREFIX}/bin
cd ${srcdir}${MINGW_PREFIX}
# libitm* and libvtv* are disbled until fixed
cp bin/{libatomic*,libgcc*,libgomp*,libquadmath*,libssp*,libstdc*}.dll ${pkgdir}${MINGW_PREFIX}/bin/
if [ "$_enable_jit" == "yes" ]; then
rm ${pkgdir}${MINGW_PREFIX}/bin/libgccjit-0.dll
fi
}
package_gcc() {
pkgdesc="GNU Compiler Collection (C,C++,OpenMP) for MinGW-w64"
depends=("${MINGW_PACKAGE_PREFIX}-binutils"
"${MINGW_PACKAGE_PREFIX}-crt"
"${MINGW_PACKAGE_PREFIX}-headers"
"${MINGW_PACKAGE_PREFIX}-isl"
"${MINGW_PACKAGE_PREFIX}-libiconv"
"${MINGW_PACKAGE_PREFIX}-gmp"
"${MINGW_PACKAGE_PREFIX}-mpfr"
"${MINGW_PACKAGE_PREFIX}-mpc"
"${MINGW_PACKAGE_PREFIX}-${_realname}-libs=${pkgver}-${pkgrel}"
"${MINGW_PACKAGE_PREFIX}-windows-default-manifest"
"${MINGW_PACKAGE_PREFIX}-winpthreads"
"${MINGW_PACKAGE_PREFIX}-zlib"
"${MINGW_PACKAGE_PREFIX}-zstd")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}-base"
"${MINGW_PACKAGE_PREFIX}-cc")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}-base")
mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,include,lib,share}
cd ${srcdir}${MINGW_PREFIX}
cp bin/cpp.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/gcc.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/gcc.exe ${pkgdir}${MINGW_PREFIX}/bin/cc.exe
cp bin/gcc-ar.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/gcc-nm.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/gcc-ranlib.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/gcov.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/gcov-tool.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/c++.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/g++.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/${MINGW_CHOST}-c++.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/${MINGW_CHOST}-g++.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/${MINGW_CHOST}-gcc-${pkgver%%+*}.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/${MINGW_CHOST}-gcc.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/${MINGW_CHOST}-gcc.exe ${pkgdir}${MINGW_PREFIX}/bin/${MINGW_CHOST}-cc.exe
cp bin/${MINGW_CHOST}-gcc-ar.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/${MINGW_CHOST}-gcc-nm.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/${MINGW_CHOST}-gcc-ranlib.exe ${pkgdir}${MINGW_PREFIX}/bin/
#cp bin/{libgcc*,libgomp*,libquadmath*,libstdc*}.dll ${pkgdir}${MINGW_PREFIX}/bin/
mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/include
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/include/*.h ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/include/
cp -r lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/include-fixed ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp -r lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/install-tools ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
#cp -r lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/plugin ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/cc1.exe ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/collect2.exe ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/crt*.o ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/liblto* ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/libgcov* ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/lto*.exe ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/cc1plus.exe ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/g++-mapper-server.exe ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/libatomic* ${pkgdir}${MINGW_PREFIX}/lib/
cp lib/libgcc_* ${pkgdir}${MINGW_PREFIX}/lib/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/libgcc* ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/libgomp* ${pkgdir}${MINGW_PREFIX}/lib/
# cp lib/libitm* ${pkgdir}${MINGW_PREFIX}/lib/
cp lib/libquadmath* ${pkgdir}${MINGW_PREFIX}/lib/
# cp lib/libvtv* ${pkgdir}${MINGW_PREFIX}/lib/
cp lib/libstdc++* ${pkgdir}${MINGW_PREFIX}/lib/
cp lib/libsupc++* ${pkgdir}${MINGW_PREFIX}/lib/
#mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/lib
#cp ${srcdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/lib/libgcc_s.a ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
#cp lib/gcc/${MINGW_CHOST}/lib/libgcc_s.a ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/lib/
#cp -r lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/include/c++ ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/include/
cp -r include/c++ ${pkgdir}${MINGW_PREFIX}/include/
#cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/libstdc++* ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
#cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/libsupc++* ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
mkdir -p ${pkgdir}${MINGW_PREFIX}/share/{doc,info,locale,man}
#cp -r share/doc/gcc-${pkgver%%+*} ${pkgdir}${MINGW_PREFIX}/share/doc/
cp share/info/cpp.info* ${pkgdir}${MINGW_PREFIX}/share/info/
cp share/info/cppinternals.info* ${pkgdir}${MINGW_PREFIX}/share/info/
cp share/info/gcc.info* ${pkgdir}${MINGW_PREFIX}/share/info/
cp share/info/gccinstall.info* ${pkgdir}${MINGW_PREFIX}/share/info/
cp share/info/gccint.info* ${pkgdir}${MINGW_PREFIX}/share/info/
# cp share/info/libitm.info* ${pkgdir}${MINGW_PREFIX}/share/info/
cp share/info/libgomp.info* ${pkgdir}${MINGW_PREFIX}/share/info/
cp share/info/libquadmath.info* ${pkgdir}${MINGW_PREFIX}/share/info/
#cp share/locale/* ${pkgdir}${MINGW_PREFIX}/share/locale/
mkdir -p ${pkgdir}${MINGW_PREFIX}/share/gcc-${pkgver%%+*}/python
cp -r share/gcc-${pkgver%%+*}/python/libstdcxx ${pkgdir}${MINGW_PREFIX}/share/gcc-${pkgver%%+*}/python/
mkdir -p ${pkgdir}${MINGW_PREFIX}/share/man/man1
cp share/man/man1/cpp.1* ${pkgdir}${MINGW_PREFIX}/share/man/man1/
cp share/man/man1/gcc.1* ${pkgdir}${MINGW_PREFIX}/share/man/man1/
cp share/man/man1/gcov.1* ${pkgdir}${MINGW_PREFIX}/share/man/man1/
cp share/man/man7/fsf-funding.7* ${pkgdir}${MINGW_PREFIX}/share/man/man1/
cp share/man/man7/gfdl.7* ${pkgdir}${MINGW_PREFIX}/share/man/man1/
cp share/man/man7/gpl.7* ${pkgdir}${MINGW_PREFIX}/share/man/man1/
cp share/man/man1/g++.1* ${pkgdir}${MINGW_PREFIX}/share/man/man1/
# install plugins for binutils
mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/bfd-plugins
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/*plugin*.dll ${pkgdir}${MINGW_PREFIX}/lib/bfd-plugins/
# install "custom" system gdbinit
install -D -m644 ${srcdir}/gdbinit ${pkgdir}${MINGW_PREFIX}/etc/gdbinit
sed -i 's|%GCC_NAME%|gcc-'${pkgver%%+*}'|g' ${pkgdir}${MINGW_PREFIX}/etc/gdbinit
}
package_gcc-libgfortran() {
pkgdesc="GNU Compiler Collection (libgfortran) for MinGW-w64"
depends=("${MINGW_PACKAGE_PREFIX}-${_realname}-libs=${pkgver}-${pkgrel}")
mkdir -p ${pkgdir}${MINGW_PREFIX}/bin
cd ${srcdir}${MINGW_PREFIX}
cp bin/libgfortran*.dll ${pkgdir}${MINGW_PREFIX}/bin/
}
package_gcc-fortran() {
pkgdesc="GNU Compiler Collection (Fortran) for MinGW-w64"
depends=("${MINGW_PACKAGE_PREFIX}-${_realname}=${pkgver}-${pkgrel}"
"${MINGW_PACKAGE_PREFIX}-${_realname}-libgfortran=${pkgver}-${pkgrel}")
provides=("${MINGW_PACKAGE_PREFIX}-fc")
mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib,share}
cd ${srcdir}${MINGW_PREFIX}
cp bin/gfortran.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/${MINGW_CHOST}-gfortran.exe ${pkgdir}${MINGW_PREFIX}/bin/
#cp bin/libgfortran*.dll ${pkgdir}${MINGW_PREFIX}/bin/
mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}
cp -r lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/finclude ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/f951.exe ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/libcaf_single.a ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/libgfortran* ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
mkdir -p ${pkgdir}${MINGW_PREFIX}/share/man/man1
cp share/man/man1/gfortran.1* ${pkgdir}${MINGW_PREFIX}/share/man/man1/
mkdir -p ${pkgdir}${MINGW_PREFIX}/share/info
cp share/info/gfortran.info* ${pkgdir}${MINGW_PREFIX}/share/info/
}
package_gcc-ada() {
pkgdesc="GNU Compiler Collection (Ada) for MinGW-w64"
depends=("${MINGW_PACKAGE_PREFIX}-${_realname}=${pkgver}-${pkgrel}")
mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib,share}
cd ${srcdir}${MINGW_PREFIX}
cp bin/gnat*.exe ${pkgdir}${MINGW_PREFIX}/bin/
cp bin/{libgnarl*,libgnat*}.dll ${pkgdir}${MINGW_PREFIX}/bin/
mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}
cp -r lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/adainclude ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp -r lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/adalib ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/gnat1.exe ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
mkdir -p ${pkgdir}${MINGW_PREFIX}/share/info
cp share/info/gnat-style.info* ${pkgdir}${MINGW_PREFIX}/share/info/
cp share/info/gnat_rm.info* ${pkgdir}${MINGW_PREFIX}/share/info/
cp share/info/gnat_ugn.info* ${pkgdir}${MINGW_PREFIX}/share/info/
}
package_gcc-objc() {
pkgdesc="GNU Compiler Collection (ObjC,Obj-C++) for MinGW-w64"
depends=("${MINGW_PACKAGE_PREFIX}-${_realname}=${pkgver}-${pkgrel}")
mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib}
cd ${srcdir}${MINGW_PREFIX}
cp bin/libobjc*.dll ${pkgdir}${MINGW_PREFIX}/bin/
mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/include
cp -r lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/include/objc ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/include/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/cc1obj.exe ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/cc1objplus.exe ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
cp lib/libobjc.* ${pkgdir}${MINGW_PREFIX}/lib/gcc/${MINGW_CHOST}/${pkgver%%+*}/
}
package_libgccjit() {
pkgdesc="GNU Compiler Collection (libgccjit) for MinGW-w64"
depends=("${MINGW_PACKAGE_PREFIX}-${_realname}=${pkgver}-${pkgrel}")
mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib,include}
cd ${srcdir}${MINGW_PREFIX}
cp bin/libgccjit-0.dll ${pkgdir}${MINGW_PREFIX}/bin/
cp include/libgccjit.h ${pkgdir}${MINGW_PREFIX}/include/
cp include/libgccjit++.h ${pkgdir}${MINGW_PREFIX}/include/
cp lib/libgccjit.dll.a ${pkgdir}${MINGW_PREFIX}/lib/
mkdir -p ${pkgdir}${MINGW_PREFIX}/share/info
cp share/info/libgccjit.info ${pkgdir}${MINGW_PREFIX}/share/info/
}
# template start; name=mingw-w64-splitpkg-wrappers; version=1.0;
# vim: set ft=bash :
# generate wrappers
for _name in "${pkgname[@]}"; do
_short="package_${_name#${MINGW_PACKAGE_PREFIX}-}"
_func="$(declare -f "${_short}")"
eval "${_func/#${_short}/package_${_name}}"
done
# template end;

6
mingw-w64-gcc-12/gdbinit Normal file
View File

@@ -0,0 +1,6 @@
python
import sys
sys.path.insert(0, sys.path[0] + '/../../%GCC_NAME%/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end