OSDN Git Service

Latest updates from FSF 4.7 branch
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / mingw32.h
1 /* Operating system specific defines to be used when targeting GCC for
2    hosting on Windows32, using GNU tools and the Windows32 API Library.
3    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008,
4    2009, 2010, 2011 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #undef DEFAULT_ABI
23 #define DEFAULT_ABI MS_ABI
24
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
36 /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
37    is for compatibility with native compiler.  */
38 #define EXTRA_OS_CPP_BUILTINS()                                 \
39   do                                                            \
40     {                                                           \
41       builtin_define ("__MSVCRT__");                            \
42       builtin_define ("__MINGW32__");                           \
43       builtin_define ("_WIN32");                                \
44       builtin_define_std ("WIN32");                             \
45       builtin_define_std ("WINNT");                             \
46       builtin_define_with_int_value ("_INTEGRAL_MAX_BITS",      \
47                                      TYPE_PRECISION (intmax_type_node));\
48       if (TARGET_64BIT && ix86_abi == MS_ABI)                   \
49         {                                                       \
50           builtin_define ("__MINGW64__");                       \
51           builtin_define_std ("WIN64");                         \
52           builtin_define ("_WIN64");                            \
53         }                                                       \
54     }                                                           \
55   while (0)
56
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
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
81 #undef NATIVE_SYSTEM_HEADER_COMPONENT
82 #define NATIVE_SYSTEM_HEADER_COMPONENT "MINGW"
83
84 #undef  CPP_SPEC
85 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \
86   "%{mno-win32:%{mno-cygwin: %emno-cygwin and mno-win32 are not compatible}} " \
87   "%{!mno-win32:-D__MSVCRT__ -D__MINGW32__ %{!ansi:%{mthreads:-D_MT}}} " \
88   "%{mno-win32:-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix} " \
89   "%{!mno-cygwin:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}} " \
90   "%{!nostdinc:%{!mno-win32|mno-cygwin:-idirafter ../include/w32api%s -idirafter ../../include/w32api%s}} " \
91                  "%{" SPEC_PTHREAD1 ":-D_REENTRANT} " \
92                  "%{" SPEC_PTHREAD2 ": } "
93
94 /* For Windows applications, include more libraries, but always include
95    kernel32.  */
96 #undef LIB_SPEC
97 #define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \
98                  "%{" SPEC_PTHREAD2 ": } " \
99                  "%{mwindows:-lgdi32 -lcomdlg32} " \
100                  "-ladvapi32 -lshell32 -luser32 -lkernel32"
101
102 /* Weak symbols do not get resolved if using a Windows dll import lib.
103    Make the unwind registration references strong undefs.  */
104 #if DWARF2_UNWIND_INFO
105 /* DW2-unwind is just available for 32-bit mode.  */
106 #if TARGET_64BIT_DEFAULT
107 #error DW2 unwind is not available for 64-bit.
108 #endif
109 #define SHARED_LIBGCC_UNDEFS_SPEC \
110  "%{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}"
111 #else
112 #define SHARED_LIBGCC_UNDEFS_SPEC ""
113 #endif
114
115 #undef  SUBTARGET_EXTRA_SPECS
116 #define SUBTARGET_EXTRA_SPECS                                           \
117   { "shared_libgcc_undefs", SHARED_LIBGCC_UNDEFS_SPEC }
118
119 #define LINK_SPEC "%{mwindows:--subsystem windows} \
120   %{mconsole:--subsystem console} \
121   %{shared: %{mdll: %eshared and mdll are not compatible}} \
122   %{shared: --shared} %{mdll:--dll} \
123   %{static:-Bstatic} %{!static:-Bdynamic} \
124   %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \
125   %(shared_libgcc_undefs)"
126
127 /* Include in the mingw32 libraries with libgcc */
128 #ifdef ENABLE_SHARED_LIBGCC
129 #define SHARED_LIBGCC_SPEC "%{shared-libgcc:-lgcc_s} %{!shared-libgcc:-lgcc_eh}"
130 #else
131 #define SHARED_LIBGCC_SPEC /*empty*/
132 #endif
133 #undef REAL_LIBGCC_SPEC
134 #define REAL_LIBGCC_SPEC \
135   "%{mthreads:-lmingwthrd} -lmingw32 \
136    "SHARED_LIBGCC_SPEC" \
137    -lgcc \
138    -lmoldname -lmingwex -lmsvcrt"
139
140 #undef STARTFILE_SPEC
141 #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
142   %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
143   crtbegin.o%s"
144
145 #undef ENDFILE_SPEC
146 #define ENDFILE_SPEC \
147   "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
148   crtend.o%s"
149
150 /* Override startfile prefix defaults.  */
151 #ifndef STANDARD_STARTFILE_PREFIX_1
152 #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
153 #endif
154 #ifndef STANDARD_STARTFILE_PREFIX_2
155 #define STANDARD_STARTFILE_PREFIX_2 ""
156 #endif
157
158 /* For native mingw-version we need to take care that NATIVE_SYSTEM_HEADER_DIR
159    macro contains POSIX-style path.  See bug 52947.  */
160 #undef NATIVE_SYSTEM_HEADER_DIR
161 #define NATIVE_SYSTEM_HEADER_DIR "/mingw/include"
162
163 /* Output STRING, a string representing a filename, to FILE.
164    We canonicalize it to be in Unix format (backslashes are replaced
165    forward slashes.  */
166 #undef OUTPUT_QUOTED_STRING
167 #define OUTPUT_QUOTED_STRING(FILE, STRING)               \
168 do {                                                     \
169   const char *_string = (const char *) (STRING);         \
170   char c;                                                \
171                                                          \
172   putc ('\"', (FILE));                                   \
173                                                          \
174   while ((c = *_string++) != 0)                          \
175     {                                                    \
176       if (c == '\\')                                     \
177         c = '/';                                         \
178                                                          \
179       if (ISPRINT (c))                                   \
180         {                                                \
181           if (c == '\"')                                 \
182             putc ('\\', (FILE));                         \
183           putc (c, (FILE));                              \
184         }                                                \
185       else                                               \
186         fprintf ((FILE), "\\%03o", (unsigned char) c);   \
187     }                                                    \
188                                                          \
189   putc ('\"', (FILE));                                   \
190 } while (0)
191
192 /* Define as short unsigned for compatibility with MS runtime.  */
193 #undef WINT_TYPE
194 #define WINT_TYPE "short unsigned int"
195
196 /* mingw32 uses the  -mthreads option to enable thread support.  */
197 #undef GOMP_SELF_SPECS
198 #define GOMP_SELF_SPECS "%{fopenmp|ftree-parallelize-loops=*: " \
199                         "-mthreads -pthread}"
200 #undef GTM_SELF_SPECS
201 #define GTM_SELF_SPECS "%{fgnu-tm:-mthreads -pthread}"
202
203 /* mingw32 atexit function is safe to use in shared libraries.  Use it
204    to register C++ static destructors.  */
205 #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
206
207 /* Contains a pointer to type target_ovr_attr defining the target specific
208    overrides of format attributes.  See c-format.h for structure
209    definition.  */
210 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
211 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
212
213 /* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE.  */
214 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
215 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
216
217 /* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
218 #undef TARGET_OVERRIDES_FORMAT_INIT
219 #define TARGET_OVERRIDES_FORMAT_INIT msformat_init
220
221 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
222 #undef TARGET_FORMAT_TYPES
223 #define TARGET_FORMAT_TYPES mingw_format_attributes
224
225 #undef TARGET_N_FORMAT_TYPES
226 #define TARGET_N_FORMAT_TYPES 3
227
228 /* Let defaults.h definition of TARGET_USE_JCR_SECTION apply. */
229 #undef TARGET_USE_JCR_SECTION
230
231 #define HAVE_ENABLE_EXECUTE_STACK
232 #undef  CHECK_EXECUTE_STACK_ENABLED
233 #define CHECK_EXECUTE_STACK_ENABLED flag_setstackexecutable
234
235 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygming. */
236 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
237 #if DWARF2_UNWIND_INFO
238 #define LIBGCC_EH_EXTN "_dw2"
239 #else
240 #define LIBGCC_EH_EXTN "_sjlj"
241 #endif
242 #define LIBGCC_SONAME "libgcc_s" LIBGCC_EH_EXTN "-1.dll"
243
244 /* We should find a way to not have to update this manually.  */
245 #define LIBGCJ_SONAME "libgcj" /*LIBGCC_EH_EXTN*/ "-13.dll"