OSDN Git Service

ChangeLog for gcc
[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 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 TARGET_VERSION
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
28
29 /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
30    is for compatibility with native compiler.  */
31 #define EXTRA_OS_CPP_BUILTINS()                                 \
32   do                                                            \
33     {                                                           \
34       builtin_define ("__MSVCRT__");                            \
35       builtin_define ("__MINGW32__");                           \
36       builtin_define ("_WIN32");                                \
37       builtin_define_std ("WIN32");                             \
38       builtin_define_std ("WINNT");                             \
39       builtin_define_with_int_value ("_INTEGRAL_MAX_BITS",      \
40                                      TYPE_PRECISION (intmax_type_node));\
41       if (TARGET_64BIT && ix86_abi == MS_ABI)                   \
42         {                                                       \
43           builtin_define ("__MINGW64__");                       \
44           builtin_define_std ("WIN64");                         \
45           builtin_define_std ("_WIN64");                        \
46         }                                                       \
47     }                                                           \
48   while (0)
49
50 /* Override the standard choice of /usr/include as the default prefix
51    to try when searching for header files.  */
52 #undef STANDARD_INCLUDE_DIR
53 #if TARGET_64BIT_DEFAULT
54 #define STANDARD_INCLUDE_DIR "/mingw/include64"
55 #else
56 #define STANDARD_INCLUDE_DIR "/mingw/include"
57 #endif
58 #undef STANDARD_INCLUDE_COMPONENT
59 #define STANDARD_INCLUDE_COMPONENT "MINGW"
60
61 #undef CPP_SPEC
62 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT}"
63
64 /* For Windows applications, include more libraries, but always include
65    kernel32.  */
66 #undef LIB_SPEC
67 #define LIB_SPEC "%{pg:-lgmon} %{mwindows:-lgdi32 -lcomdlg32} \
68                   -luser32 -lkernel32 -ladvapi32 -lshell32"
69
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
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} \
88   %{shared|mdll: -e _DllMainCRTStartup@12 --enable-auto-image-base} \
89   %(shared_libgcc_undefs)"
90
91 /* Include in the mingw32 libraries with libgcc */
92 #ifdef ENABLE_SHARED_LIBGCC
93 #define SHARED_LIBGCC_SPEC "%{shared-libgcc:-lgcc_s} %{!shared-libgcc:-lgcc_eh}"
94 #else
95 #define SHARED_LIBGCC_SPEC /*empty*/
96 #endif
97 #undef REAL_LIBGCC_SPEC
98 #define REAL_LIBGCC_SPEC \
99   "%{mthreads:-lmingwthrd} -lmingw32 \
100    "SHARED_LIBGCC_SPEC" \
101    -lgcc \
102    -lmoldname -lmingwex -lmsvcrt"
103
104 #undef STARTFILE_SPEC
105 #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
106   %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
107   crtbegin.o%s"
108
109 #undef ENDFILE_SPEC
110 #define ENDFILE_SPEC \
111   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
112   crtend.o%s"
113
114 /* Override startfile prefix defaults.  */
115 #ifndef STANDARD_STARTFILE_PREFIX_1
116 #if TARGET_64BIT_DEFAULT
117 #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib64/"
118 #else
119 #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
120 #endif
121 #endif
122 #ifndef STANDARD_STARTFILE_PREFIX_2
123 #define STANDARD_STARTFILE_PREFIX_2 ""
124 #endif
125
126 /* Put all *tf routines in libgcc.  */
127 #undef LIBGCC2_HAS_TF_MODE
128 #define LIBGCC2_HAS_TF_MODE 1
129 #undef LIBGCC2_TF_CEXT
130 #define LIBGCC2_TF_CEXT q
131 #undef TF_SIZE
132 #define TF_SIZE 113
133
134 /* Output STRING, a string representing a filename, to FILE.
135    We canonicalize it to be in Unix format (backslashes are replaced
136    forward slashes.  */
137 #undef OUTPUT_QUOTED_STRING
138 #define OUTPUT_QUOTED_STRING(FILE, STRING)               \
139 do {                                                     \
140   char c;                                                \
141                                                          \
142   putc ('\"', asm_file);                                 \
143                                                          \
144   while ((c = *string++) != 0)                           \
145     {                                                    \
146       if (c == '\\')                                     \
147         c = '/';                                         \
148                                                          \
149       if (ISPRINT (c))                                   \
150         {                                                \
151           if (c == '\"')                                 \
152             putc ('\\', asm_file);                       \
153           putc (c, asm_file);                            \
154         }                                                \
155       else                                               \
156         fprintf (asm_file, "\\%03o", (unsigned char) c); \
157     }                                                    \
158                                                          \
159   putc ('\"', asm_file);                                 \
160 } while (0)
161
162 /* Define as short unsigned for compatibility with MS runtime.  */
163 #undef WINT_TYPE
164 #define WINT_TYPE "short unsigned int"
165
166 /* mingw32 uses the  -mthreads option to enable thread support.  */
167 #undef GOMP_SELF_SPECS
168 #define GOMP_SELF_SPECS "%{fopenmp: -mthreads}"
169
170 /* mingw32 atexit function is safe to use in shared libraries.  Use it
171    to register C++ static destructors.  */
172 #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
173
174 /* Contains a pointer to type target_ovr_attr defining the target specific
175    overrides of format attributes.  See c-format.h for structure
176    definition.  */
177 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
178 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
179
180 /* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE.  */
181 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
182 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
183
184 /* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
185 #undef TARGET_OVERRIDES_FORMAT_INIT
186 #define TARGET_OVERRIDES_FORMAT_INIT msformat_init
187
188 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
189 #undef TARGET_FORMAT_TYPES
190 #define TARGET_FORMAT_TYPES mingw_format_attributes
191
192 #undef TARGET_N_FORMAT_TYPES
193 #define TARGET_N_FORMAT_TYPES 3
194
195 /* Let defaults.h definition of TARGET_USE_JCR_SECTION apply. */
196 #undef TARGET_USE_JCR_SECTION
197
198 #undef MINGW_ENABLE_EXECUTE_STACK
199 #define MINGW_ENABLE_EXECUTE_STACK     \
200 extern void __enable_execute_stack (void *);    \
201 void         \
202 __enable_execute_stack (void *addr)                                     \
203 {                                                                       \
204   MEMORY_BASIC_INFORMATION b;                                           \
205   if (!VirtualQuery (addr, &b, sizeof(b)))                              \
206     abort ();                                                           \
207   VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE,  \
208                   &b.Protect);                                          \
209 }
210
211 #undef ENABLE_EXECUTE_STACK
212 #define ENABLE_EXECUTE_STACK MINGW_ENABLE_EXECUTE_STACK
213
214 #ifdef IN_LIBGCC2
215 #include <windows.h>
216 #endif
217
218 #if !TARGET_64BIT
219 #define MD_UNWIND_SUPPORT "config/i386/w32-unwind.h"
220 #endif
221
222 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygming. */
223 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
224 #if DWARF2_UNWIND_INFO
225 #define LIBGCC_EH_EXTN "_dw2"
226 #else
227 #define LIBGCC_EH_EXTN "_sjlj"
228 #endif
229 #define LIBGCC_SONAME "libgcc_s" LIBGCC_EH_EXTN "-1.dll"