authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-11-05 20:04:25+02:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-11-05 20:04:25+02:00
log3e1639c53b879b8c40f8efcf7c096d3060ee2407
tree088ff7a3ecbee25beb3fe667be88e84f13ce68eb
parent708962d51e91eb2004af1216d6a9a5865b616256
signaturelock-open Commit is signed but in an unrecognized format.

Fixed mingw-w64 8.0.0 compilation

Reaplied mingw-w64 header patch

8 files changed, 561 insertions(+), 22 deletions(-)

lib/libc/include/any-windows-any/_mingw.h+2-2
......@@ -222,7 +222,7 @@ limitations in handling dllimport attribute. */
222222#ifndef __MSVCRT_VERSION__
223223/* High byte is the major version, low byte is the minor. */
224224# ifndef _UCRT
225# define __MSVCRT_VERSION__ @DEFAULT_MSVCRT_VERSION@
225# define __MSVCRT_VERSION__ 0x700
226226# else
227227# define __MSVCRT_VERSION__ 0xE00
228228# endif
......@@ -230,7 +230,7 @@ limitations in handling dllimport attribute. */
230230
231231
232232#ifndef _WIN32_WINNT
233#define _WIN32_WINNT @DEFAULT_WIN32_WINNT@
233#define _WIN32_WINNT 0x0603
234234#endif
235235
236236#ifndef _INT128_DEFINED
lib/libc/include/any-windows-any/intrin.h+1-1
......@@ -50,7 +50,7 @@
5050 * On GCC 4.9 we may always include those headers. On older GCCs, we may do it only if CPU
5151 * features used by them are enabled, so we need to check macros like __SSE__ or __MMX__ first.
5252 */
53#if __MINGW_GNUC_PREREQ(4, 9)
53#if __MINGW_GNUC_PREREQ(4, 9) || defined(__clang__)
5454#define __MINGW_FORCE_SYS_INTRINS
5555#endif
5656
lib/libc/mingw/crt/charmax.c created+22
......@@ -0,0 +1,22 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#include <crtdefs.h>
8#include <sect_attribs.h>
9#include <corecrt_startup.h>
10
11__declspec(dllimport) int __lconv_init (void);
12
13int mingw_initcharmax = 0;
14
15int _charmax = 255;
16
17static int my_lconv_init(void)
18{
19 return __lconv_init();
20}
21
22_CRTALLOC(".CRT$XIC") _PIFV __mingw_pinit = my_lconv_init;
lib/libc/mingw/crt/crtexe.c created+436
......@@ -0,0 +1,436 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#undef CRTDLL
8#ifndef _DLL
9#define _DLL
10#endif
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#define SPECIAL_CRTEXE
17
18#include <oscalls.h>
19#include <internal.h>
20#include <process.h>
21#include <signal.h>
22#include <math.h>
23#include <stdlib.h>
24#include <tchar.h>
25#include <sect_attribs.h>
26#include <locale.h>
27
28#if defined(__SEH__) && (!defined(__clang__) || __clang_major__ >= 7)
29#define SEH_INLINE_ASM
30#endif
31
32#ifndef __winitenv
33extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
34#define __winitenv (* __MINGW_IMP_SYMBOL(__winitenv))
35#endif
36
37#if !defined(__initenv) && !defined(__arm__) && !defined(__aarch64__)
38extern char *** __MINGW_IMP_SYMBOL(__initenv);
39#define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
40#endif
41
42/* Hack, for bug in ld. Will be removed soon. */
43#if defined(__GNUC__)
44#define __ImageBase __MINGW_LSYMBOL(_image_base__)
45#endif
46/* This symbol is defined by ld. */
47extern IMAGE_DOS_HEADER __ImageBase;
48
49extern void _fpreset (void);
50#define SPACECHAR _T(' ')
51#define DQUOTECHAR _T('\"')
52
53int *__cdecl __p__commode(void);
54
55#undef _fmode
56extern int _fmode;
57extern int _commode;
58extern int _dowildcard;
59
60extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
61
62static int __cdecl check_managed_app (void);
63
64extern _CRTALLOC(".CRT$XIA") _PIFV __xi_a[];
65extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
66extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
67extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
68
69#ifndef HAVE_CTOR_LIST
70__attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void *)))) const void * __CTOR_LIST__ = (void *) -1;
71__attribute__ (( __section__ (".dtors"), __used__ , aligned(sizeof(void *)))) const void * __DTOR_LIST__ = (void *) -1;
72__attribute__ (( __section__ (".ctors.99999"), __used__ , aligned(sizeof(void *)))) const void * __CTOR_END__ = (void *) 0;
73__attribute__ (( __section__ (".dtors.99999"), __used__ , aligned(sizeof(void *)))) const void * __DTOR_END__ = (void *) 0;
74#endif
75
76/* TLS initialization hook. */
77extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
78
79extern int mingw_app_type;
80
81HINSTANCE __mingw_winmain_hInstance;
82_TCHAR *__mingw_winmain_lpCmdLine;
83DWORD __mingw_winmain_nShowCmd = SW_SHOWDEFAULT;
84
85static int argc;
86extern void __main(void);
87#ifdef WPRFLAG
88static wchar_t **argv;
89static wchar_t **envp;
90#else
91static char **argv;
92static char **envp;
93#endif
94
95static int argret;
96static int mainret=0;
97static int managedapp;
98static int has_cctor = 0;
99static _startupinfo startinfo;
100extern LPTOP_LEVEL_EXCEPTION_FILTER __mingw_oldexcpt_handler;
101
102extern void _pei386_runtime_relocator (void);
103long CALLBACK _gnu_exception_handler (EXCEPTION_POINTERS * exception_data);
104#ifdef WPRFLAG
105static void duplicate_ppstrings (int ac, wchar_t ***av);
106#else
107static void duplicate_ppstrings (int ac, char ***av);
108#endif
109
110static int __cdecl pre_c_init (void);
111static void __cdecl pre_cpp_init (void);
112_CRTALLOC(".CRT$XIAA") _PIFV mingw_pcinit = pre_c_init;
113_CRTALLOC(".CRT$XCAA") _PVFV mingw_pcppinit = pre_cpp_init;
114
115extern int _MINGW_INSTALL_DEBUG_MATHERR;
116
117#ifdef __MINGW_SHOW_INVALID_PARAMETER_EXCEPTION
118#define __UNUSED_PARAM_1(x) x
119#else
120#define __UNUSED_PARAM_1 __UNUSED_PARAM
121#endif
122static void
123__mingw_invalidParameterHandler (const wchar_t * __UNUSED_PARAM_1(expression),
124 const wchar_t * __UNUSED_PARAM_1(function),
125 const wchar_t * __UNUSED_PARAM_1(file),
126 unsigned int __UNUSED_PARAM_1(line),
127 uintptr_t __UNUSED_PARAM(pReserved))
128{
129#ifdef __MINGW_SHOW_INVALID_PARAMETER_EXCEPTION
130 wprintf(L"Invalid parameter detected in function %s. File: %s Line: %d\n", function, file, line);
131 wprintf(L"Expression: %s\n", expression);
132#endif
133}
134
135static int __cdecl
136pre_c_init (void)
137{
138 managedapp = check_managed_app ();
139 if (mingw_app_type)
140 __set_app_type(_GUI_APP);
141 else
142 __set_app_type (_CONSOLE_APP);
143
144 * __p__fmode() = _fmode;
145 * __p__commode() = _commode;
146
147#ifdef WPRFLAG
148 _wsetargv();
149#else
150 _setargv();
151#endif
152 if (_MINGW_INSTALL_DEBUG_MATHERR == 1)
153 {
154 __setusermatherr (_matherr);
155 }
156
157 if (__globallocalestatus == -1)
158 {
159 }
160 return 0;
161}
162
163static void __cdecl
164pre_cpp_init (void)
165{
166 startinfo.newmode = _newmode;
167
168#ifdef WPRFLAG
169 argret = __wgetmainargs(&argc,&argv,&envp,_dowildcard,&startinfo);
170#else
171 argret = __getmainargs(&argc,&argv,&envp,_dowildcard,&startinfo);
172#endif
173}
174
175static int __tmainCRTStartup (void);
176
177int WinMainCRTStartup (void);
178
179int WinMainCRTStartup (void)
180{
181 int ret = 255;
182#ifdef SEH_INLINE_ASM
183 asm ("\t.l_startw:\n");
184#endif
185 mingw_app_type = 1;
186 ret = __tmainCRTStartup ();
187#ifdef SEH_INLINE_ASM
188 asm ("\tnop\n"
189 "\t.l_endw: nop\n"
190 "\t.seh_handler __C_specific_handler, @except\n"
191 "\t.seh_handlerdata\n"
192 "\t.long 1\n"
193 "\t.rva .l_startw, .l_endw, _gnu_exception_handler ,.l_endw\n"
194 "\t.text");
195#endif
196 return ret;
197}
198
199int mainCRTStartup (void);
200
201#if defined(__x86_64__) && !defined(__SEH__)
202int __mingw_init_ehandler (void);
203#endif
204
205int mainCRTStartup (void)
206{
207 int ret = 255;
208#ifdef SEH_INLINE_ASM
209 asm ("\t.l_start:\n");
210#endif
211 mingw_app_type = 0;
212 ret = __tmainCRTStartup ();
213#ifdef SEH_INLINE_ASM
214 asm ("\tnop\n"
215 "\t.l_end: nop\n"
216 "\t.seh_handler __C_specific_handler, @except\n"
217 "\t.seh_handlerdata\n"
218 "\t.long 1\n"
219 "\t.rva .l_start, .l_end, _gnu_exception_handler ,.l_end\n"
220 "\t.text");
221#endif
222 return ret;
223}
224
225static
226#if defined(__i386__) || defined(_X86_)
227/* We need to make sure that we align the stack to 16 bytes for the sake of SSE
228 opts in main or in functions called main. */
229__attribute__((force_align_arg_pointer))
230#endif
231__declspec(noinline) int
232__tmainCRTStartup (void)
233{
234 _TCHAR *lpszCommandLine = NULL;
235 STARTUPINFO StartupInfo;
236 WINBOOL inDoubleQuote = FALSE;
237 memset (&StartupInfo, 0, sizeof (STARTUPINFO));
238
239 if (mingw_app_type)
240 GetStartupInfo (&StartupInfo);
241 {
242 void *lock_free = NULL;
243 void *fiberid = ((PNT_TIB)NtCurrentTeb())->StackBase;
244 int nested = FALSE;
245 while((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,
246 fiberid, 0)) != 0)
247 {
248 if (lock_free == fiberid)
249 {
250 nested = TRUE;
251 break;
252 }
253 Sleep(1000);
254 }
255 if (__native_startup_state == __initializing)
256 {
257 _amsg_exit (31);
258 }
259 else if (__native_startup_state == __uninitialized)
260 {
261 __native_startup_state = __initializing;
262 _initterm ((_PVFV *)(void *)__xi_a, (_PVFV *)(void *) __xi_z);
263 }
264 else
265 has_cctor = 1;
266
267 if (__native_startup_state == __initializing)
268 {
269 _initterm (__xc_a, __xc_z);
270 __native_startup_state = __initialized;
271 }
272 _ASSERTE(__native_startup_state == __initialized);
273 if (! nested)
274 (VOID)InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
275
276 if (__dyn_tls_init_callback != NULL)
277 __dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
278
279 _pei386_runtime_relocator ();
280 __mingw_oldexcpt_handler = SetUnhandledExceptionFilter (_gnu_exception_handler);
281#if defined(__x86_64__) && !defined(__SEH__)
282 __mingw_init_ehandler ();
283#endif
284 _set_invalid_parameter_handler (__mingw_invalidParameterHandler);
285
286 _fpreset ();
287
288 __mingw_winmain_hInstance = (HINSTANCE) &__ImageBase;
289
290#ifdef WPRFLAG
291 lpszCommandLine = (_TCHAR *) _wcmdln;
292#else
293 lpszCommandLine = (char *) _acmdln;
294#endif
295
296 if (lpszCommandLine)
297 {
298 while (*lpszCommandLine > SPACECHAR || (*lpszCommandLine && inDoubleQuote))
299 {
300 if (*lpszCommandLine == DQUOTECHAR)
301 inDoubleQuote = !inDoubleQuote;
302#ifdef _MBCS
303 if (_ismbblead (*lpszCommandLine))
304 {
305 if (lpszCommandLine[1])
306 ++lpszCommandLine;
307 }
308#endif
309 ++lpszCommandLine;
310 }
311 while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR))
312 lpszCommandLine++;
313
314 __mingw_winmain_lpCmdLine = lpszCommandLine;
315 }
316
317 if (mingw_app_type)
318 {
319 __mingw_winmain_nShowCmd = StartupInfo.dwFlags & STARTF_USESHOWWINDOW ?
320 StartupInfo.wShowWindow : SW_SHOWDEFAULT;
321 }
322 duplicate_ppstrings (argc, &argv);
323 __main ();
324#ifdef WPRFLAG
325 __winitenv = envp;
326 /* C++ initialization.
327 gcc inserts this call automatically for a function called main, but not for wmain. */
328 mainret = wmain (argc, argv, envp);
329#else
330#if !defined(__arm__) && !defined(__aarch64__)
331 __initenv = envp;
332#endif
333 mainret = main (argc, argv, envp);
334#endif
335 if (!managedapp)
336 exit (mainret);
337
338 if (has_cctor == 0)
339 _cexit ();
340 }
341 return mainret;
342}
343
344extern int mingw_initltsdrot_force;
345extern int mingw_initltsdyn_force;
346extern int mingw_initltssuo_force;
347extern int mingw_initcharmax;
348
349static int __cdecl
350check_managed_app (void)
351{
352 PIMAGE_DOS_HEADER pDOSHeader;
353 PIMAGE_NT_HEADERS pPEHeader;
354 PIMAGE_OPTIONAL_HEADER32 pNTHeader32;
355 PIMAGE_OPTIONAL_HEADER64 pNTHeader64;
356
357 /* Force to be linked. */
358 mingw_initltsdrot_force=1;
359 mingw_initltsdyn_force=1;
360 mingw_initltssuo_force=1;
361 mingw_initcharmax=1;
362
363 pDOSHeader = (PIMAGE_DOS_HEADER) &__ImageBase;
364 if (pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE)
365 return 0;
366
367 pPEHeader = (PIMAGE_NT_HEADERS)((char *)pDOSHeader + pDOSHeader->e_lfanew);
368 if (pPEHeader->Signature != IMAGE_NT_SIGNATURE)
369 return 0;
370
371 pNTHeader32 = (PIMAGE_OPTIONAL_HEADER32) &pPEHeader->OptionalHeader;
372 switch (pNTHeader32->Magic)
373 {
374 case IMAGE_NT_OPTIONAL_HDR32_MAGIC:
375 if (pNTHeader32->NumberOfRvaAndSizes <= IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR)
376 return 0;
377 return !! pNTHeader32->DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress;
378 case IMAGE_NT_OPTIONAL_HDR64_MAGIC:
379 pNTHeader64 = (PIMAGE_OPTIONAL_HEADER64)pNTHeader32;
380 if (pNTHeader64->NumberOfRvaAndSizes <= IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR)
381 return 0;
382 return !! pNTHeader64->DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress;
383 }
384 return 0;
385}
386
387#ifdef WPRFLAG
388static size_t wbytelen(const wchar_t *p)
389{
390 size_t ret = 1;
391 while (*p!=0) {
392 ret++,++p;
393 }
394 return ret*2;
395}
396static void duplicate_ppstrings (int ac, wchar_t ***av)
397{
398 wchar_t **avl;
399 int i;
400 wchar_t **n = (wchar_t **) malloc (sizeof (wchar_t *) * (ac + 1));
401
402 avl=*av;
403 for (i=0; i < ac; i++)
404 {
405 size_t l = wbytelen (avl[i]);
406 n[i] = (wchar_t *) malloc (l);
407 memcpy (n[i], avl[i], l);
408 }
409 n[i] = NULL;
410 *av = n;
411}
412#else
413static void duplicate_ppstrings (int ac, char ***av)
414{
415 char **avl;
416 int i;
417 char **n = (char **) malloc (sizeof (char *) * (ac + 1));
418
419 avl=*av;
420 for (i=0; i < ac; i++)
421 {
422 size_t l = strlen (avl[i]) + 1;
423 n[i] = (char *) malloc (l);
424 memcpy (n[i], avl[i], l);
425 }
426 n[i] = NULL;
427 *av = n;
428}
429#endif
430
431int __cdecl atexit (_PVFV func)
432{
433 return _onexit((_onexit_t)func) ? 0 : -1;
434}
435
436char __mingw_module_is_dll = 0;
lib/libc/mingw/crt/dll_argv.c created+25
......@@ -0,0 +1,25 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#ifdef CRTDLL
8#undef CRTDLL
9#endif
10
11#include <internal.h>
12
13extern int _dowildcard;
14
15#ifdef WPRFLAG
16int __CRTDECL
17__wsetargv (void)
18#else
19int __CRTDECL
20__setargv (void)
21#endif
22{
23 _dowildcard = 1;
24 return 0;
25}
lib/libc/mingw/crt/mingw_custom.c deleted-16
......@@ -1,16 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#include <_mingw.h>
8#include "../revstamp.h"
9
10const char *__mingw_get_crt_info (void)
11{
12 return "MinGW-W64 Runtime " __MINGW64_VERSION_STR " ("
13 __MINGW64_VERSION_STATE " - "
14 "rev. " __MINGW_W64_REV ") " __MINGW_W64_REV_STAMP;
15}
16
lib/libc/mingw/include/config.h created+74
......@@ -0,0 +1,74 @@
1/* config.h. Generated from config.h.in by configure. */
2/* config.h.in. Generated from configure.ac by autoheader. */
3
4/* Whether the linker provides __CTOR_LIST__ */
5#define HAVE_CTOR_LIST 1
6
7/* Define to 1 if you have the <inttypes.h> header file. */
8#define HAVE_INTTYPES_H 1
9
10/* Define to 1 if you have the <memory.h> header file. */
11#define HAVE_MEMORY_H 1
12
13/* Define to 1 if you have the <stdint.h> header file. */
14#define HAVE_STDINT_H 1
15
16/* Define to 1 if you have the <stdlib.h> header file. */
17#define HAVE_STDLIB_H 1
18
19/* Define to 1 if you have the <strings.h> header file. */
20#define HAVE_STRINGS_H 1
21
22/* Define to 1 if you have the <string.h> header file. */
23#define HAVE_STRING_H 1
24
25/* Define to 1 if you have the <sys/stat.h> header file. */
26#define HAVE_SYS_STAT_H 1
27
28/* Define to 1 if you have the <sys/types.h> header file. */
29#define HAVE_SYS_TYPES_H 1
30
31/* Define to 1 if you have the <unistd.h> header file. */
32#define HAVE_UNISTD_H 1
33
34/* Name of package */
35#define PACKAGE "mingw-w64-runtime"
36
37/* Define to the address where bug reports for this package should be sent. */
38#define PACKAGE_BUGREPORT "mingw-w64-public@lists.sourceforge.net"
39
40/* Define to the full name of this package. */
41#define PACKAGE_NAME "mingw-w64-runtime"
42
43/* Define to the full name and version of this package. */
44#define PACKAGE_STRING "mingw-w64-runtime 4.0b"
45
46/* Define to the one symbol short name of this package. */
47#define PACKAGE_TARNAME "mingw-w64-runtime"
48
49/* Define to the home page for this package. */
50#define PACKAGE_URL ""
51
52/* Define to the version of this package. */
53#define PACKAGE_VERSION "4.0b"
54
55/* Define to 1 if you have the ANSI C header files. */
56#define STDC_HEADERS 1
57
58/* Version number of package */
59#define VERSION "4.0b"
60
61/* Build DFP support */
62/* #undef __ENABLE_DFP */
63
64/* Define as -1 to enable command line globbing or 0 to disable it. */
65#define __ENABLE_GLOBBING 0
66
67/* Build DFP support */
68/* #undef __ENABLE_PRINTF128 */
69
70/* Build DFP support */
71/* #undef __ENABLE_REGISTEREDPRINTF */
72
73/* Build softmath routines */
74/* #undef __ENABLE_SOFTMATH */
src/mingw.zig+1-3
......@@ -524,7 +524,6 @@ const mingw32_lib_deps = [_][]const u8{
524524 "udllargc.c",
525525 "xthdloc.c",
526526 "CRT_fp10.c",
527 "mingw_custom.c",
528527 "mingw_helpers.c",
529528 "pseudo-reloc.c",
530529 "udll_argv.c",
......@@ -598,6 +597,7 @@ const msvcrt_common_src = [_][]const u8{
598597const msvcrt_i386_src = [_][]const u8{
599598 "misc" ++ path.sep_str ++ "lc_locale_func.c",
600599 "misc" ++ path.sep_str ++ "___mb_cur_max_func.c",
600 "misc" ++ path.sep_str ++ "wassert.c",
601601};
602602
603603const msvcrt_other_src = [_][]const u8{
......@@ -751,7 +751,6 @@ const mingwex_generic_src = [_][]const u8{
751751 "math" ++ path.sep_str ++ "powi.c",
752752 "math" ++ path.sep_str ++ "powif.c",
753753 "math" ++ path.sep_str ++ "powil.c",
754 "math" ++ path.sep_str ++ "rint.c",
755754 "math" ++ path.sep_str ++ "round.c",
756755 "math" ++ path.sep_str ++ "roundf.c",
757756 "math" ++ path.sep_str ++ "roundl.c",
......@@ -829,7 +828,6 @@ const mingwex_generic_src = [_][]const u8{
829828 "misc" ++ path.sep_str ++ "uchar_c32rtomb.c",
830829 "misc" ++ path.sep_str ++ "uchar_mbrtoc16.c",
831830 "misc" ++ path.sep_str ++ "uchar_mbrtoc32.c",
832 "misc" ++ path.sep_str ++ "wassert.c",
833831 "misc" ++ path.sep_str ++ "wcrtomb.c",
834832 "misc" ++ path.sep_str ++ "wcsnlen.c",
835833 "misc" ++ path.sep_str ++ "wcstof.c",