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.
6 This file is part of GCC.
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)
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.
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/>. */
23 #define DEFAULT_ABI MS_ABI
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. */
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)
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() \
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) \
50 builtin_define ("__MINGW64__"); \
51 builtin_define_std ("WIN64"); \
52 builtin_define ("_WIN64"); \
57 #ifndef TARGET_USE_PTHREAD_BY_DEFAULT
58 #define SPEC_PTHREAD1 "pthread"
59 #define SPEC_PTHREAD2 "!no-pthread"
61 #define SPEC_PTHREAD1 "!no-pthread"
62 #define SPEC_PTHREAD2 "pthread"
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"
71 #define SUB_LINK_ENTRY64 "-e DllMainCRTStartup"
75 #if TARGET_64BIT_DEFAULT
76 #define SUB_LINK_ENTRY SUB_LINK_ENTRY64
78 #define SUB_LINK_ENTRY SUB_LINK_ENTRY32
81 #undef NATIVE_SYSTEM_HEADER_COMPONENT
82 #define NATIVE_SYSTEM_HEADER_COMPONENT "MINGW"
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 ": } "
94 /* For Windows applications, include more libraries, but always include
97 #define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \
98 "%{" SPEC_PTHREAD2 ": } " \
99 "%{mwindows:-lgdi32 -lcomdlg32} " \
100 "-ladvapi32 -lshell32 -luser32 -lkernel32"
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.
109 #define SHARED_LIBGCC_UNDEFS_SPEC \
110 "%{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}"
112 #define SHARED_LIBGCC_UNDEFS_SPEC ""
115 #undef SUBTARGET_EXTRA_SPECS
116 #define SUBTARGET_EXTRA_SPECS \
117 { "shared_libgcc_undefs", SHARED_LIBGCC_UNDEFS_SPEC }
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)"
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}"
131 #define SHARED_LIBGCC_SPEC /*empty*/
133 #undef REAL_LIBGCC_SPEC
134 #define REAL_LIBGCC_SPEC \
135 "%{mthreads:-lmingwthrd} -lmingw32 \
136 "SHARED_LIBGCC_SPEC" \
138 -lmoldname -lmingwex -lmsvcrt"
140 #undef STARTFILE_SPEC
141 #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
142 %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
146 #define ENDFILE_SPEC \
147 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
150 /* Override startfile prefix defaults. */
151 #ifndef STANDARD_STARTFILE_PREFIX_1
152 #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
154 #ifndef STANDARD_STARTFILE_PREFIX_2
155 #define STANDARD_STARTFILE_PREFIX_2 ""
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"
163 /* Output STRING, a string representing a filename, to FILE.
164 We canonicalize it to be in Unix format (backslashes are replaced
166 #undef OUTPUT_QUOTED_STRING
167 #define OUTPUT_QUOTED_STRING(FILE, STRING) \
169 const char *_string = (const char *) (STRING); \
172 putc ('\"', (FILE)); \
174 while ((c = *_string++) != 0) \
182 putc ('\\', (FILE)); \
186 fprintf ((FILE), "\\%03o", (unsigned char) c); \
189 putc ('\"', (FILE)); \
192 /* Define as short unsigned for compatibility with MS runtime. */
194 #define WINT_TYPE "short unsigned int"
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}"
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
207 /* Contains a pointer to type target_ovr_attr defining the target specific
208 overrides of format attributes. See c-format.h for structure
210 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
211 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
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
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
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
225 #undef TARGET_N_FORMAT_TYPES
226 #define TARGET_N_FORMAT_TYPES 3
228 /* Let defaults.h definition of TARGET_USE_JCR_SECTION apply. */
229 #undef TARGET_USE_JCR_SECTION
231 #define HAVE_ENABLE_EXECUTE_STACK
232 #undef CHECK_EXECUTE_STACK_ENABLED
233 #define CHECK_EXECUTE_STACK_ENABLED flag_setstackexecutable
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"
240 #define LIBGCC_EH_EXTN "_sjlj"
242 #define LIBGCC_SONAME "libgcc_s" LIBGCC_EH_EXTN "-1.dll"
244 /* We should find a way to not have to update this manually. */
245 #define LIBGCJ_SONAME "libgcj" /*LIBGCC_EH_EXTN*/ "-13.dll"