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.
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 #if TARGET_64BIT_DEFAULT
24 #define TARGET_VERSION fprintf (stderr,"(x86_64 MinGW");
26 #define TARGET_VERSION fprintf (stderr," (x86 MinGW)");
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() \
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) \
43 builtin_define ("__MINGW64__"); \
44 builtin_define_std ("WIN64"); \
45 builtin_define_std ("_WIN64"); \
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 #define STANDARD_INCLUDE_DIR "/mingw/include"
54 #undef STANDARD_INCLUDE_COMPONENT
55 #define STANDARD_INCLUDE_COMPONENT "MINGW"
58 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT}"
60 /* For Windows applications, include more libraries, but always include
63 #define LIB_SPEC "%{pg:-lgmon} %{mwindows:-lgdi32 -lcomdlg32} \
64 -luser32 -lkernel32 -ladvapi32 -lshell32"
66 /* Weak symbols do not get resolved if using a Windows dll import lib.
67 Make the unwind registration references strong undefs. */
68 #if DWARF2_UNWIND_INFO
69 #define SHARED_LIBGCC_UNDEFS_SPEC \
70 "%{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}"
72 #define SHARED_LIBGCC_UNDEFS_SPEC ""
75 #undef SUBTARGET_EXTRA_SPECS
76 #define SUBTARGET_EXTRA_SPECS \
77 { "shared_libgcc_undefs", SHARED_LIBGCC_UNDEFS_SPEC }
79 #define LINK_SPEC "%{mwindows:--subsystem windows} \
80 %{mconsole:--subsystem console} \
81 %{shared: %{mdll: %eshared and mdll are not compatible}} \
82 %{shared: --shared} %{mdll:--dll} \
83 %{static:-Bstatic} %{!static:-Bdynamic} \
84 %{shared|mdll: -e _DllMainCRTStartup@12 --enable-auto-image-base} \
85 %(shared_libgcc_undefs)"
87 /* Include in the mingw32 libraries with libgcc */
88 #ifdef ENABLE_SHARED_LIBGCC
89 #define SHARED_LIBGCC_SPEC "%{shared-libgcc:-lgcc_s} %{!shared-libgcc:-lgcc_eh}"
91 #define SHARED_LIBGCC_SPEC /*empty*/
93 #undef REAL_LIBGCC_SPEC
94 #define REAL_LIBGCC_SPEC \
95 "%{mthreads:-lmingwthrd} -lmingw32 \
96 "SHARED_LIBGCC_SPEC" \
98 -lmoldname -lmingwex -lmsvcrt"
100 #undef STARTFILE_SPEC
101 #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
102 %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
106 #define ENDFILE_SPEC \
107 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
110 /* Override startfile prefix defaults. */
111 #ifndef STANDARD_STARTFILE_PREFIX_1
112 #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
114 #ifndef STANDARD_STARTFILE_PREFIX_2
115 #define STANDARD_STARTFILE_PREFIX_2 ""
118 /* Put all *tf routines in libgcc. */
119 #undef LIBGCC2_HAS_TF_MODE
120 #define LIBGCC2_HAS_TF_MODE 1
121 #undef LIBGCC2_TF_CEXT
122 #define LIBGCC2_TF_CEXT q
126 /* Output STRING, a string representing a filename, to FILE.
127 We canonicalize it to be in Unix format (backslashes are replaced
129 #undef OUTPUT_QUOTED_STRING
130 #define OUTPUT_QUOTED_STRING(FILE, STRING) \
134 putc ('\"', asm_file); \
136 while ((c = *string++) != 0) \
144 putc ('\\', asm_file); \
145 putc (c, asm_file); \
148 fprintf (asm_file, "\\%03o", (unsigned char) c); \
151 putc ('\"', asm_file); \
154 /* Define as short unsigned for compatibility with MS runtime. */
156 #define WINT_TYPE "short unsigned int"
158 /* mingw32 uses the -mthreads option to enable thread support. */
159 #undef GOMP_SELF_SPECS
160 #define GOMP_SELF_SPECS "%{fopenmp: -mthreads}"
162 /* mingw32 atexit function is safe to use in shared libraries. Use it
163 to register C++ static destructors. */
164 #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
166 /* Contains a pointer to type target_ovr_attr defining the target specific
167 overrides of format attributes. See c-format.h for structure
169 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
170 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
172 /* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE. */
173 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
174 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
176 /* Custom initialization for warning -Wpedantic-ms-format for c-format. */
177 #undef TARGET_OVERRIDES_FORMAT_INIT
178 #define TARGET_OVERRIDES_FORMAT_INIT msformat_init
180 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime. */
181 #undef TARGET_FORMAT_TYPES
182 #define TARGET_FORMAT_TYPES mingw_format_attributes
184 #undef TARGET_N_FORMAT_TYPES
185 #define TARGET_N_FORMAT_TYPES 3
187 /* Let defaults.h definition of TARGET_USE_JCR_SECTION apply. */
188 #undef TARGET_USE_JCR_SECTION
190 #undef MINGW_ENABLE_EXECUTE_STACK
191 #define MINGW_ENABLE_EXECUTE_STACK \
192 extern void __enable_execute_stack (void *); \
194 __enable_execute_stack (void *addr) \
196 MEMORY_BASIC_INFORMATION b; \
197 if (!VirtualQuery (addr, &b, sizeof(b))) \
199 VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, \
203 #undef ENABLE_EXECUTE_STACK
204 #define ENABLE_EXECUTE_STACK MINGW_ENABLE_EXECUTE_STACK
211 #define MD_UNWIND_SUPPORT "config/i386/w32-unwind.h"
214 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygming. */
215 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
216 #if DWARF2_UNWIND_INFO
217 #define LIBGCC_EH_EXTN "_dw2"
219 #define LIBGCC_EH_EXTN "_sjlj"
221 #define LIBGCC_SONAME "libgcc_s" LIBGCC_EH_EXTN "-1.dll"