]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/i386/mingw32.h
trans.c (gfc_allocate_array_with_status): Mark error path as unlikely.
[thirdparty/gcc.git] / gcc / config / i386 / mingw32.h
CommitLineData
6407d0da 1/* Operating system specific defines to be used when targeting GCC for
db009825 2 hosting on Windows32, using GNU tools and the Windows32 API Library.
66647d44 3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008,
eb1eb914 4 2009, 2010, 2011 Free Software Foundation, Inc.
6407d0da 5
188fc5b5 6This file is part of GCC.
6407d0da 7
188fc5b5 8GCC is free software; you can redistribute it and/or modify
6407d0da 9it under the terms of the GNU General Public License as published by
2f83c7d6 10the Free Software Foundation; either version 3, or (at your option)
6407d0da
RK
11any later version.
12
188fc5b5 13GCC is distributed in the hope that it will be useful,
6407d0da
RK
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
2f83c7d6
NC
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
6407d0da 21
6510e8bb
KT
22#undef DEFAULT_ABI
23#define DEFAULT_ABI MS_ABI
24
a6c46762
KT
25/* By default, target has a 80387, uses IEEE compatible arithmetic,
26 returns float values in the 387 and needs stack probes.
27 We also align doubles to 64-bits for MSVC default compatibility.
28 Additionally we enable MS_BITFIELD_LAYOUT by default. */
29
30#undef TARGET_SUBTARGET_DEFAULT
31#define TARGET_SUBTARGET_DEFAULT \
32 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS \
33 | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \
34 | MASK_MS_BITFIELD_LAYOUT)
35
a7d0b2d8
DS
36/* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
37 is for compatibility with native compiler. */
f60ed6be
NB
38#define EXTRA_OS_CPP_BUILTINS() \
39 do \
40 { \
41 builtin_define ("__MSVCRT__"); \
42 builtin_define ("__MINGW32__"); \
70e5e841
CF
43 builtin_define ("_WIN32"); \
44 builtin_define_std ("WIN32"); \
45 builtin_define_std ("WINNT"); \
a7d0b2d8
DS
46 builtin_define_with_int_value ("_INTEGRAL_MAX_BITS", \
47 TYPE_PRECISION (intmax_type_node));\
51212b32 48 if (TARGET_64BIT && ix86_abi == MS_ABI) \
ccf8e764
RH
49 { \
50 builtin_define ("__MINGW64__"); \
ccf8e764 51 builtin_define_std ("WIN64"); \
1159da44 52 builtin_define ("_WIN64"); \
ccf8e764 53 } \
f60ed6be
NB
54 } \
55 while (0)
56
c04bdac0
KT
57#ifndef TARGET_USE_PTHREAD_BY_DEFAULT
58#define SPEC_PTHREAD1 "pthread"
59#define SPEC_PTHREAD2 "!no-pthread"
60#else
61#define SPEC_PTHREAD1 "!no-pthread"
62#define SPEC_PTHREAD2 "pthread"
63#endif
64
ad211091
KT
65#undef SUB_LINK_ENTRY32
66#undef SUB_LINK_ENTRY64
67#define SUB_LINK_ENTRY32 "-e _DllMainCRTStartup@12"
68#if defined(USE_MINGW64_LEADING_UNDERSCORES)
69#define SUB_LINK_ENTRY64 "-e _DllMainCRTStartup"
70#else
71#define SUB_LINK_ENTRY64 "-e DllMainCRTStartup"
72#endif
73
74#undef SUB_LINK_ENTRY
75#if TARGET_64BIT_DEFAULT
76#define SUB_LINK_ENTRY SUB_LINK_ENTRY64
77#else
78#define SUB_LINK_ENTRY SUB_LINK_ENTRY32
79#endif
80
0bcbfabb
AL
81/* Override the standard choice of /usr/include as the default prefix
82 to try when searching for header files. */
23092526 83#undef STANDARD_INCLUDE_DIR
0bcbfabb 84#define STANDARD_INCLUDE_DIR "/mingw/include"
0a977123
CF
85#undef STANDARD_INCLUDE_COMPONENT
86#define STANDARD_INCLUDE_COMPONENT "MINGW"
23092526 87
2b9f972f 88#undef CPP_SPEC
c04bdac0
KT
89#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \
90 "%{" SPEC_PTHREAD1 ":-D_REENTRANCE} " \
91 "%{" SPEC_PTHREAD2 ": } "
2b9f972f 92
6407d0da
RK
93/* For Windows applications, include more libraries, but always include
94 kernel32. */
95#undef LIB_SPEC
c04bdac0
KT
96#define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \
97 "%{" SPEC_PTHREAD2 ": } " \
98 "%{mwindows:-lgdi32 -lcomdlg32} " \
99 "-ladvapi32 -lshell32 -luser32 -lkernel32"
6407d0da 100
d89f0ad6
AL
101/* Weak symbols do not get resolved if using a Windows dll import lib.
102 Make the unwind registration references strong undefs. */
103#if DWARF2_UNWIND_INFO
ad211091
KT
104/* DW2-unwind is just available for 32-bit mode. */
105#if TARGET_64BIT_DEFAULT
106#error DW2 unwind is not available for 64-bit.
107#endif
d89f0ad6
AL
108#define SHARED_LIBGCC_UNDEFS_SPEC \
109 "%{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}"
110#else
111#define SHARED_LIBGCC_UNDEFS_SPEC ""
112#endif
113
114#undef SUBTARGET_EXTRA_SPECS
115#define SUBTARGET_EXTRA_SPECS \
116 { "shared_libgcc_undefs", SHARED_LIBGCC_UNDEFS_SPEC }
117
9c7c6e6c
TP
118#define LINK_SPEC "%{mwindows:--subsystem windows} \
119 %{mconsole:--subsystem console} \
120 %{shared: %{mdll: %eshared and mdll are not compatible}} \
121 %{shared: --shared} %{mdll:--dll} \
122 %{static:-Bstatic} %{!static:-Bdynamic} \
ad211091 123 %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \
d89f0ad6 124 %(shared_libgcc_undefs)"
9c7c6e6c 125
23092526 126/* Include in the mingw32 libraries with libgcc */
20358adc
MP
127#ifdef ENABLE_SHARED_LIBGCC
128#define SHARED_LIBGCC_SPEC "%{shared-libgcc:-lgcc_s} %{!shared-libgcc:-lgcc_eh}"
129#else
130#define SHARED_LIBGCC_SPEC /*empty*/
131#endif
068450d0
DS
132#undef REAL_LIBGCC_SPEC
133#define REAL_LIBGCC_SPEC \
de27a12c 134 "%{mthreads:-lmingwthrd} -lmingw32 \
20358adc 135 "SHARED_LIBGCC_SPEC" \
068450d0 136 -lgcc \
d89f0ad6 137 -lmoldname -lmingwex -lmsvcrt"
6407d0da 138
23092526 139#undef STARTFILE_SPEC
9c7c6e6c 140#define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
76f5e200
DS
141 %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
142 crtbegin.o%s"
23092526 143
9bd196f0
ZM
144#undef ENDFILE_SPEC
145#define ENDFILE_SPEC \
0691dde9 146 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
76f5e200 147 crtend.o%s"
9bd196f0 148
656c7a3a
AL
149/* Override startfile prefix defaults. */
150#ifndef STANDARD_STARTFILE_PREFIX_1
151#define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
152#endif
153#ifndef STANDARD_STARTFILE_PREFIX_2
154#define STANDARD_STARTFILE_PREFIX_2 ""
155#endif
0bcbfabb 156
0a977123 157/* Output STRING, a string representing a filename, to FILE.
d1f87653 158 We canonicalize it to be in Unix format (backslashes are replaced
211a0cbe 159 forward slashes. */
0a977123 160#undef OUTPUT_QUOTED_STRING
211a0cbe
GDR
161#define OUTPUT_QUOTED_STRING(FILE, STRING) \
162do { \
3cda91d8 163 const char *_string = (const char *) (STRING); \
211a0cbe
GDR
164 char c; \
165 \
3cda91d8 166 putc ('\"', (FILE)); \
211a0cbe 167 \
3cda91d8 168 while ((c = *_string++) != 0) \
211a0cbe
GDR
169 { \
170 if (c == '\\') \
171 c = '/'; \
172 \
173 if (ISPRINT (c)) \
174 { \
175 if (c == '\"') \
3cda91d8
UB
176 putc ('\\', (FILE)); \
177 putc (c, (FILE)); \
211a0cbe
GDR
178 } \
179 else \
3cda91d8 180 fprintf ((FILE), "\\%03o", (unsigned char) c); \
211a0cbe
GDR
181 } \
182 \
3cda91d8 183 putc ('\"', (FILE)); \
23092526
MK
184} while (0)
185
d1f87653 186/* Define as short unsigned for compatibility with MS runtime. */
355426ab
DS
187#undef WINT_TYPE
188#define WINT_TYPE "short unsigned int"
33815e0c 189
4d51dc9e 190/* mingw32 uses the -mthreads option to enable thread support. */
33815e0c 191#undef GOMP_SELF_SPECS
4d51dc9e 192#define GOMP_SELF_SPECS "%{fopenmp: -mthreads}"
97388150
DS
193
194/* mingw32 atexit function is safe to use in shared libraries. Use it
195 to register C++ static destructors. */
196#define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
76f5e200 197
6590fc9f
KT
198/* Contains a pointer to type target_ovr_attr defining the target specific
199 overrides of format attributes. See c-format.h for structure
200 definition. */
201#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
202#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
203
204/* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE. */
205#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
206#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
207
94564826
KT
208/* Custom initialization for warning -Wpedantic-ms-format for c-format. */
209#undef TARGET_OVERRIDES_FORMAT_INIT
210#define TARGET_OVERRIDES_FORMAT_INIT msformat_init
211
6590fc9f
KT
212/* MS specific format attributes for ms_printf, ms_scanf, ms_strftime. */
213#undef TARGET_FORMAT_TYPES
214#define TARGET_FORMAT_TYPES mingw_format_attributes
215
216#undef TARGET_N_FORMAT_TYPES
217#define TARGET_N_FORMAT_TYPES 3
218
20384976 219/* Let defaults.h definition of TARGET_USE_JCR_SECTION apply. */
76f5e200 220#undef TARGET_USE_JCR_SECTION
76f5e200 221
0b03b302
KT
222#undef MINGW_ENABLE_EXECUTE_STACK
223#define MINGW_ENABLE_EXECUTE_STACK \
224extern void __enable_execute_stack (void *); \
225void \
226__enable_execute_stack (void *addr) \
227{ \
228 MEMORY_BASIC_INFORMATION b; \
229 if (!VirtualQuery (addr, &b, sizeof(b))) \
230 abort (); \
231 VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, \
232 &b.Protect); \
233}
234
235#undef ENABLE_EXECUTE_STACK
236#define ENABLE_EXECUTE_STACK MINGW_ENABLE_EXECUTE_STACK
41ca8d08
KT
237#undef CHECK_EXECUTE_STACK_ENABLED
238#define CHECK_EXECUTE_STACK_ENABLED flag_setstackexecutable
0b03b302 239
0b03b302
KT
240#ifdef IN_LIBGCC2
241#include <windows.h>
242#endif
243
d89f0ad6 244/* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygming. */
3cbfaf98
DK
245/* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
246#if DWARF2_UNWIND_INFO
247#define LIBGCC_EH_EXTN "_dw2"
248#else
249#define LIBGCC_EH_EXTN "_sjlj"
250#endif
251#define LIBGCC_SONAME "libgcc_s" LIBGCC_EH_EXTN "-1.dll"
6a92b6c7
DK
252
253/* We should find a way to not have to update this manually. */
4c4837a3 254#define LIBGCJ_SONAME "libgcj" /*LIBGCC_EH_EXTN*/ "-12.dll"
6a92b6c7 255