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