]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/i386/mingw32.h
configure.ac (MPFR check): Bump minimum version to 2.3.0 and recommended version...
[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.
2f83c7d6 3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
e898926c 4 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
70e5e841 22#undef TARGET_VERSION
ccf8e764
RH
23#if TARGET_64BIT_DEFAULT
24#define TARGET_VERSION fprintf (stderr,"(x86_64 MinGW");
25#else
26#define TARGET_VERSION fprintf (stderr," (x86 MinGW)");
27#endif
45936a85 28
a7d0b2d8
DS
29/* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
30 is for compatibility with native compiler. */
f60ed6be
NB
31#define EXTRA_OS_CPP_BUILTINS() \
32 do \
33 { \
34 builtin_define ("__MSVCRT__"); \
35 builtin_define ("__MINGW32__"); \
70e5e841
CF
36 builtin_define ("_WIN32"); \
37 builtin_define_std ("WIN32"); \
38 builtin_define_std ("WINNT"); \
a7d0b2d8
DS
39 builtin_define_with_int_value ("_INTEGRAL_MAX_BITS", \
40 TYPE_PRECISION (intmax_type_node));\
7c800926 41 if (TARGET_64BIT && DEFAULT_ABI == MS_ABI) \
ccf8e764
RH
42 { \
43 builtin_define ("__MINGW64__"); \
ccf8e764
RH
44 builtin_define_std ("WIN64"); \
45 builtin_define_std ("_WIN64"); \
46 } \
f60ed6be
NB
47 } \
48 while (0)
49
0bcbfabb
AL
50/* Override the standard choice of /usr/include as the default prefix
51 to try when searching for header files. */
23092526 52#undef STANDARD_INCLUDE_DIR
ccf8e764
RH
53#if TARGET_64BIT_DEFAULT
54#define STANDARD_INCLUDE_DIR "/mingw/include64"
55#else
0bcbfabb 56#define STANDARD_INCLUDE_DIR "/mingw/include"
ccf8e764 57#endif
0a977123
CF
58#undef STANDARD_INCLUDE_COMPONENT
59#define STANDARD_INCLUDE_COMPONENT "MINGW"
23092526 60
2b9f972f 61#undef CPP_SPEC
f60ed6be 62#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT}"
2b9f972f 63
6407d0da
RK
64/* For Windows applications, include more libraries, but always include
65 kernel32. */
66#undef LIB_SPEC
9b0b6c51 67#define LIB_SPEC "%{pg:-lgmon} %{mwindows:-lgdi32 -lcomdlg32} \
c6df90d8 68 -luser32 -lkernel32 -ladvapi32 -lshell32"
6407d0da 69
d89f0ad6
AL
70/* Weak symbols do not get resolved if using a Windows dll import lib.
71 Make the unwind registration references strong undefs. */
72#if DWARF2_UNWIND_INFO
73#define SHARED_LIBGCC_UNDEFS_SPEC \
74 "%{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}"
75#else
76#define SHARED_LIBGCC_UNDEFS_SPEC ""
77#endif
78
79#undef SUBTARGET_EXTRA_SPECS
80#define SUBTARGET_EXTRA_SPECS \
81 { "shared_libgcc_undefs", SHARED_LIBGCC_UNDEFS_SPEC }
82
9c7c6e6c
TP
83#define LINK_SPEC "%{mwindows:--subsystem windows} \
84 %{mconsole:--subsystem console} \
85 %{shared: %{mdll: %eshared and mdll are not compatible}} \
86 %{shared: --shared} %{mdll:--dll} \
87 %{static:-Bstatic} %{!static:-Bdynamic} \
d89f0ad6
AL
88 %{shared|mdll: -e _DllMainCRTStartup@12 --enable-auto-image-base} \
89 %(shared_libgcc_undefs)"
9c7c6e6c 90
23092526 91/* Include in the mingw32 libraries with libgcc */
068450d0
DS
92#undef REAL_LIBGCC_SPEC
93#define REAL_LIBGCC_SPEC \
de27a12c 94 "%{mthreads:-lmingwthrd} -lmingw32 \
068450d0
DS
95 %{shared-libgcc:-lgcc_s} \
96 %{!shared-libgcc:-lgcc_eh} \
97 -lgcc \
d89f0ad6 98 -lmoldname -lmingwex -lmsvcrt"
6407d0da 99
23092526 100#undef STARTFILE_SPEC
9c7c6e6c 101#define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
76f5e200
DS
102 %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
103 crtbegin.o%s"
23092526 104
9bd196f0
ZM
105#undef ENDFILE_SPEC
106#define ENDFILE_SPEC \
76f5e200
DS
107 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
108 crtend.o%s"
9bd196f0 109
656c7a3a
AL
110/* Override startfile prefix defaults. */
111#ifndef STANDARD_STARTFILE_PREFIX_1
ccf8e764
RH
112#if TARGET_64BIT_DEFAULT
113#define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib64/"
114#else
656c7a3a
AL
115#define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
116#endif
ccf8e764 117#endif
656c7a3a
AL
118#ifndef STANDARD_STARTFILE_PREFIX_2
119#define STANDARD_STARTFILE_PREFIX_2 ""
120#endif
0bcbfabb 121
0a977123 122/* Output STRING, a string representing a filename, to FILE.
d1f87653 123 We canonicalize it to be in Unix format (backslashes are replaced
211a0cbe 124 forward slashes. */
0a977123 125#undef OUTPUT_QUOTED_STRING
211a0cbe
GDR
126#define OUTPUT_QUOTED_STRING(FILE, STRING) \
127do { \
128 char c; \
129 \
130 putc ('\"', asm_file); \
131 \
132 while ((c = *string++) != 0) \
133 { \
134 if (c == '\\') \
135 c = '/'; \
136 \
137 if (ISPRINT (c)) \
138 { \
139 if (c == '\"') \
140 putc ('\\', asm_file); \
141 putc (c, asm_file); \
142 } \
143 else \
144 fprintf (asm_file, "\\%03o", (unsigned char) c); \
145 } \
146 \
147 putc ('\"', asm_file); \
23092526
MK
148} while (0)
149
d1f87653 150/* Define as short unsigned for compatibility with MS runtime. */
355426ab
DS
151#undef WINT_TYPE
152#define WINT_TYPE "short unsigned int"
33815e0c 153
4d51dc9e 154/* mingw32 uses the -mthreads option to enable thread support. */
33815e0c 155#undef GOMP_SELF_SPECS
4d51dc9e 156#define GOMP_SELF_SPECS "%{fopenmp: -mthreads}"
97388150
DS
157
158/* mingw32 atexit function is safe to use in shared libraries. Use it
159 to register C++ static destructors. */
160#define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
76f5e200 161
6590fc9f
KT
162/* Contains a pointer to type target_ovr_attr defining the target specific
163 overrides of format attributes. See c-format.h for structure
164 definition. */
165#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
166#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
167
168/* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE. */
169#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
170#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
171
172/* MS specific format attributes for ms_printf, ms_scanf, ms_strftime. */
173#undef TARGET_FORMAT_TYPES
174#define TARGET_FORMAT_TYPES mingw_format_attributes
175
176#undef TARGET_N_FORMAT_TYPES
177#define TARGET_N_FORMAT_TYPES 3
178
20384976 179/* Let defaults.h definition of TARGET_USE_JCR_SECTION apply. */
76f5e200 180#undef TARGET_USE_JCR_SECTION
76f5e200 181
0b03b302
KT
182#undef MINGW_ENABLE_EXECUTE_STACK
183#define MINGW_ENABLE_EXECUTE_STACK \
184extern void __enable_execute_stack (void *); \
185void \
186__enable_execute_stack (void *addr) \
187{ \
188 MEMORY_BASIC_INFORMATION b; \
189 if (!VirtualQuery (addr, &b, sizeof(b))) \
190 abort (); \
191 VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, \
192 &b.Protect); \
193}
194
195#undef ENABLE_EXECUTE_STACK
196#define ENABLE_EXECUTE_STACK MINGW_ENABLE_EXECUTE_STACK
197
0b03b302
KT
198#ifdef IN_LIBGCC2
199#include <windows.h>
200#endif
201
76f5e200
DS
202#if !TARGET_64BIT
203#define MD_UNWIND_SUPPORT "config/i386/w32-unwind.h"
204#endif
d89f0ad6
AL
205
206/* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygming. */
207#define LIBGCC_SONAME "libgcc_s_1.dll"