]>
Commit | Line | Data |
---|---|---|
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. |
a5544970 | 3 | Copyright (C) 1997-2019 Free Software Foundation, Inc. |
6407d0da | 4 | |
188fc5b5 | 5 | This file is part of GCC. |
6407d0da | 6 | |
188fc5b5 | 7 | GCC is free software; you can redistribute it and/or modify |
6407d0da | 8 | it under the terms of the GNU General Public License as published by |
2f83c7d6 | 9 | the Free Software Foundation; either version 3, or (at your option) |
6407d0da RK |
10 | any later version. |
11 | ||
188fc5b5 | 12 | GCC is distributed in the hope that it will be useful, |
6407d0da RK |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
2f83c7d6 NC |
18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
6407d0da | 20 | |
6510e8bb KT |
21 | #undef DEFAULT_ABI |
22 | #define DEFAULT_ABI MS_ABI | |
23 | ||
a6c46762 KT |
24 | /* By default, target has a 80387, uses IEEE compatible arithmetic, |
25 | returns float values in the 387 and needs stack probes. | |
26 | We also align doubles to 64-bits for MSVC default compatibility. | |
27 | Additionally we enable MS_BITFIELD_LAYOUT by default. */ | |
28 | ||
29 | #undef TARGET_SUBTARGET_DEFAULT | |
30 | #define TARGET_SUBTARGET_DEFAULT \ | |
31 | (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS \ | |
32 | | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \ | |
33 | | MASK_MS_BITFIELD_LAYOUT) | |
34 | ||
a7d0b2d8 DS |
35 | /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS |
36 | is for compatibility with native compiler. */ | |
f60ed6be NB |
37 | #define EXTRA_OS_CPP_BUILTINS() \ |
38 | do \ | |
39 | { \ | |
40 | builtin_define ("__MSVCRT__"); \ | |
41 | builtin_define ("__MINGW32__"); \ | |
70e5e841 CF |
42 | builtin_define ("_WIN32"); \ |
43 | builtin_define_std ("WIN32"); \ | |
44 | builtin_define_std ("WINNT"); \ | |
a7d0b2d8 DS |
45 | builtin_define_with_int_value ("_INTEGRAL_MAX_BITS", \ |
46 | TYPE_PRECISION (intmax_type_node));\ | |
51212b32 | 47 | if (TARGET_64BIT && ix86_abi == MS_ABI) \ |
ccf8e764 RH |
48 | { \ |
49 | builtin_define ("__MINGW64__"); \ | |
ccf8e764 | 50 | builtin_define_std ("WIN64"); \ |
1159da44 | 51 | builtin_define ("_WIN64"); \ |
ccf8e764 | 52 | } \ |
f60ed6be NB |
53 | } \ |
54 | while (0) | |
55 | ||
c04bdac0 KT |
56 | #ifndef TARGET_USE_PTHREAD_BY_DEFAULT |
57 | #define SPEC_PTHREAD1 "pthread" | |
58 | #define SPEC_PTHREAD2 "!no-pthread" | |
59 | #else | |
60 | #define SPEC_PTHREAD1 "!no-pthread" | |
61 | #define SPEC_PTHREAD2 "pthread" | |
62 | #endif | |
63 | ||
ad211091 KT |
64 | #undef SUB_LINK_ENTRY32 |
65 | #undef SUB_LINK_ENTRY64 | |
66 | #define SUB_LINK_ENTRY32 "-e _DllMainCRTStartup@12" | |
67 | #if defined(USE_MINGW64_LEADING_UNDERSCORES) | |
68 | #define SUB_LINK_ENTRY64 "-e _DllMainCRTStartup" | |
69 | #else | |
70 | #define SUB_LINK_ENTRY64 "-e DllMainCRTStartup" | |
71 | #endif | |
72 | ||
73 | #undef SUB_LINK_ENTRY | |
74 | #if TARGET_64BIT_DEFAULT | |
75 | #define SUB_LINK_ENTRY SUB_LINK_ENTRY64 | |
76 | #else | |
77 | #define SUB_LINK_ENTRY SUB_LINK_ENTRY32 | |
78 | #endif | |
79 | ||
08b2bad2 SB |
80 | #undef NATIVE_SYSTEM_HEADER_COMPONENT |
81 | #define NATIVE_SYSTEM_HEADER_COMPONENT "MINGW" | |
23092526 | 82 | |
2b9f972f | 83 | #undef CPP_SPEC |
c04bdac0 | 84 | #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \ |
0de99d26 | 85 | "%{" SPEC_PTHREAD1 ":-D_REENTRANT} " \ |
c04bdac0 | 86 | "%{" SPEC_PTHREAD2 ": } " |
2b9f972f | 87 | |
6407d0da RK |
88 | /* For Windows applications, include more libraries, but always include |
89 | kernel32. */ | |
90 | #undef LIB_SPEC | |
c04bdac0 KT |
91 | #define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \ |
92 | "%{" SPEC_PTHREAD2 ": } " \ | |
93 | "%{mwindows:-lgdi32 -lcomdlg32} " \ | |
f7f049fa CT |
94 | "%{fvtable-verify=preinit:-lvtv -lpsapi; \ |
95 | fvtable-verify=std:-lvtv -lpsapi} " \ | |
c04bdac0 | 96 | "-ladvapi32 -lshell32 -luser32 -lkernel32" |
6407d0da | 97 | |
d89f0ad6 AL |
98 | /* Weak symbols do not get resolved if using a Windows dll import lib. |
99 | Make the unwind registration references strong undefs. */ | |
100 | #if DWARF2_UNWIND_INFO | |
ad211091 KT |
101 | /* DW2-unwind is just available for 32-bit mode. */ |
102 | #if TARGET_64BIT_DEFAULT | |
6befaff6 SL |
103 | #define SHARED_LIBGCC_UNDEFS_SPEC \ |
104 | "%{m32: %{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}}" | |
105 | #else | |
d89f0ad6 AL |
106 | #define SHARED_LIBGCC_UNDEFS_SPEC \ |
107 | "%{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}" | |
6befaff6 | 108 | #endif |
d89f0ad6 AL |
109 | #else |
110 | #define SHARED_LIBGCC_UNDEFS_SPEC "" | |
111 | #endif | |
112 | ||
113 | #undef SUBTARGET_EXTRA_SPECS | |
114 | #define SUBTARGET_EXTRA_SPECS \ | |
115 | { "shared_libgcc_undefs", SHARED_LIBGCC_UNDEFS_SPEC } | |
116 | ||
43b01cc1 AO |
117 | #if ! MINGW_DEFAULT_LARGE_ADDR_AWARE |
118 | /* This is used without --enable-large-address-aware. */ | |
119 | # define LINK_SPEC_LARGE_ADDR_AWARE "" | |
120 | #elif ! TARGET_BI_ARCH | |
121 | /* This is used on i686-pc-mingw32 with --enable-large-address-aware. */ | |
67aeaded AO |
122 | # define LINK_SPEC_LARGE_ADDR_AWARE \ |
123 | "%{!shared:%{!mdll:--large-address-aware}}" | |
43b01cc1 AO |
124 | #elif TARGET_64BIT_DEFAULT |
125 | /* This is used on x86_64-pc-mingw32 with --enable-large-address-aware. | |
126 | ??? It probably doesn't work, because the linker emulation defaults | |
127 | to i386pep, the 64-bit mode that does not support | |
128 | --large-address-aware, and x86_64-pc-mingw32 does not override the | |
129 | emulation to i386pe for -m32, unlike x86_64-w64-mingw32. */ | |
130 | # define LINK_SPEC_LARGE_ADDR_AWARE \ | |
131 | "%{!shared:%{!mdll:%{m32:--large-address-aware}}}" | |
67aeaded | 132 | #else |
43b01cc1 AO |
133 | /* This would only be used if someone introduced a biarch |
134 | configuration that defaulted to 32-bit. */ | |
135 | # define LINK_SPEC_LARGE_ADDR_AWARE \ | |
136 | "%{!shared:%{!mdll:%{!m64:--large-address-aware}}}" | |
67aeaded AO |
137 | #endif |
138 | ||
9c7c6e6c TP |
139 | #define LINK_SPEC "%{mwindows:--subsystem windows} \ |
140 | %{mconsole:--subsystem console} \ | |
141 | %{shared: %{mdll: %eshared and mdll are not compatible}} \ | |
142 | %{shared: --shared} %{mdll:--dll} \ | |
143 | %{static:-Bstatic} %{!static:-Bdynamic} \ | |
ad211091 | 144 | %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \ |
67aeaded | 145 | " LINK_SPEC_LARGE_ADDR_AWARE "\ |
d89f0ad6 | 146 | %(shared_libgcc_undefs)" |
9c7c6e6c | 147 | |
23092526 | 148 | /* Include in the mingw32 libraries with libgcc */ |
20358adc | 149 | #ifdef ENABLE_SHARED_LIBGCC |
d71576d6 KT |
150 | #define SHARED_LIBGCC_SPEC " \ |
151 | %{static|static-libgcc:-lgcc -lgcc_eh} \ | |
152 | %{!static: \ | |
153 | %{!static-libgcc: \ | |
154 | %{!shared: \ | |
155 | %{!shared-libgcc:-lgcc -lgcc_eh} \ | |
156 | %{shared-libgcc:-lgcc_s -lgcc} \ | |
157 | } \ | |
158 | %{shared:-lgcc_s -lgcc} \ | |
159 | } \ | |
160 | } " | |
20358adc | 161 | #else |
d71576d6 | 162 | #define SHARED_LIBGCC_SPEC " -lgcc " |
20358adc | 163 | #endif |
068450d0 DS |
164 | #undef REAL_LIBGCC_SPEC |
165 | #define REAL_LIBGCC_SPEC \ | |
de27a12c | 166 | "%{mthreads:-lmingwthrd} -lmingw32 \ |
60b92097 | 167 | " SHARED_LIBGCC_SPEC " \ |
d89f0ad6 | 168 | -lmoldname -lmingwex -lmsvcrt" |
6407d0da | 169 | |
23092526 | 170 | #undef STARTFILE_SPEC |
9c7c6e6c | 171 | #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \ |
76f5e200 | 172 | %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \ |
f7f049fa CT |
173 | crtbegin.o%s \ |
174 | %{fvtable-verify=none:%s; \ | |
175 | fvtable-verify=preinit:vtv_start.o%s; \ | |
176 | fvtable-verify=std:vtv_start.o%s}" | |
23092526 | 177 | |
9bd196f0 ZM |
178 | #undef ENDFILE_SPEC |
179 | #define ENDFILE_SPEC \ | |
0691dde9 | 180 | "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ |
f70df035 | 181 | %{!shared:%:if-exists(default-manifest.o%s)}\ |
f7f049fa CT |
182 | %{fvtable-verify=none:%s; \ |
183 | fvtable-verify=preinit:vtv_end.o%s; \ | |
184 | fvtable-verify=std:vtv_end.o%s} \ | |
76f5e200 | 185 | crtend.o%s" |
9bd196f0 | 186 | |
656c7a3a AL |
187 | /* Override startfile prefix defaults. */ |
188 | #ifndef STANDARD_STARTFILE_PREFIX_1 | |
189 | #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/" | |
190 | #endif | |
191 | #ifndef STANDARD_STARTFILE_PREFIX_2 | |
192 | #define STANDARD_STARTFILE_PREFIX_2 "" | |
193 | #endif | |
0bcbfabb | 194 | |
d44f78af KT |
195 | /* For native mingw-version we need to take care that NATIVE_SYSTEM_HEADER_DIR |
196 | macro contains POSIX-style path. See bug 52947. */ | |
197 | #undef NATIVE_SYSTEM_HEADER_DIR | |
198 | #define NATIVE_SYSTEM_HEADER_DIR "/mingw/include" | |
199 | ||
0a977123 | 200 | /* Output STRING, a string representing a filename, to FILE. |
d1f87653 | 201 | We canonicalize it to be in Unix format (backslashes are replaced |
211a0cbe | 202 | forward slashes. */ |
0a977123 | 203 | #undef OUTPUT_QUOTED_STRING |
211a0cbe GDR |
204 | #define OUTPUT_QUOTED_STRING(FILE, STRING) \ |
205 | do { \ | |
3cda91d8 | 206 | const char *_string = (const char *) (STRING); \ |
211a0cbe GDR |
207 | char c; \ |
208 | \ | |
3cda91d8 | 209 | putc ('\"', (FILE)); \ |
211a0cbe | 210 | \ |
3cda91d8 | 211 | while ((c = *_string++) != 0) \ |
211a0cbe GDR |
212 | { \ |
213 | if (c == '\\') \ | |
214 | c = '/'; \ | |
215 | \ | |
216 | if (ISPRINT (c)) \ | |
217 | { \ | |
218 | if (c == '\"') \ | |
3cda91d8 UB |
219 | putc ('\\', (FILE)); \ |
220 | putc (c, (FILE)); \ | |
211a0cbe GDR |
221 | } \ |
222 | else \ | |
3cda91d8 | 223 | fprintf ((FILE), "\\%03o", (unsigned char) c); \ |
211a0cbe GDR |
224 | } \ |
225 | \ | |
3cda91d8 | 226 | putc ('\"', (FILE)); \ |
23092526 MK |
227 | } while (0) |
228 | ||
d1f87653 | 229 | /* Define as short unsigned for compatibility with MS runtime. */ |
355426ab DS |
230 | #undef WINT_TYPE |
231 | #define WINT_TYPE "short unsigned int" | |
33815e0c | 232 | |
4d51dc9e | 233 | /* mingw32 uses the -mthreads option to enable thread support. */ |
33815e0c | 234 | #undef GOMP_SELF_SPECS |
9dbe3d77 | 235 | #define GOMP_SELF_SPECS "%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): " \ |
c9c8f2e8 | 236 | "-mthreads -pthread}" |
255a9a1b EB |
237 | #undef GTM_SELF_SPECS |
238 | #define GTM_SELF_SPECS "%{fgnu-tm:-mthreads -pthread}" | |
97388150 DS |
239 | |
240 | /* mingw32 atexit function is safe to use in shared libraries. Use it | |
241 | to register C++ static destructors. */ | |
242 | #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true | |
76f5e200 | 243 | |
6590fc9f KT |
244 | /* Contains a pointer to type target_ovr_attr defining the target specific |
245 | overrides of format attributes. See c-format.h for structure | |
246 | definition. */ | |
247 | #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES | |
248 | #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides | |
249 | ||
250 | /* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE. */ | |
251 | #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT | |
252 | #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3 | |
253 | ||
94564826 KT |
254 | /* Custom initialization for warning -Wpedantic-ms-format for c-format. */ |
255 | #undef TARGET_OVERRIDES_FORMAT_INIT | |
256 | #define TARGET_OVERRIDES_FORMAT_INIT msformat_init | |
257 | ||
6590fc9f KT |
258 | /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime. */ |
259 | #undef TARGET_FORMAT_TYPES | |
260 | #define TARGET_FORMAT_TYPES mingw_format_attributes | |
261 | ||
262 | #undef TARGET_N_FORMAT_TYPES | |
263 | #define TARGET_N_FORMAT_TYPES 3 | |
264 | ||
10e48e39 | 265 | #define HAVE_ENABLE_EXECUTE_STACK |
41ca8d08 KT |
266 | #undef CHECK_EXECUTE_STACK_ENABLED |
267 | #define CHECK_EXECUTE_STACK_ENABLED flag_setstackexecutable | |
0b03b302 | 268 | |
d89f0ad6 | 269 | /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygming. */ |
3cbfaf98 DK |
270 | /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */ |
271 | #if DWARF2_UNWIND_INFO | |
272 | #define LIBGCC_EH_EXTN "_dw2" | |
273 | #else | |
274 | #define LIBGCC_EH_EXTN "_sjlj" | |
275 | #endif | |
276 | #define LIBGCC_SONAME "libgcc_s" LIBGCC_EH_EXTN "-1.dll" | |
6a92b6c7 | 277 |