| 1 | 709 | jeremybenn | /* 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 |  |  |                  "%{" SPEC_PTHREAD1 ":-D_REENTRANT} " \
 | 
      
         | 87 |  |  |                  "%{" SPEC_PTHREAD2 ": } "
 | 
      
         | 88 |  |  |  
 | 
      
         | 89 |  |  | /* For Windows applications, include more libraries, but always include
 | 
      
         | 90 |  |  |    kernel32.  */
 | 
      
         | 91 |  |  | #undef LIB_SPEC
 | 
      
         | 92 |  |  | #define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \
 | 
      
         | 93 |  |  |                  "%{" SPEC_PTHREAD2 ": } " \
 | 
      
         | 94 |  |  |                  "%{mwindows:-lgdi32 -lcomdlg32} " \
 | 
      
         | 95 |  |  |                  "-ladvapi32 -lshell32 -luser32 -lkernel32"
 | 
      
         | 96 |  |  |  
 | 
      
         | 97 |  |  | /* Weak symbols do not get resolved if using a Windows dll import lib.
 | 
      
         | 98 |  |  |    Make the unwind registration references strong undefs.  */
 | 
      
         | 99 |  |  | #if DWARF2_UNWIND_INFO
 | 
      
         | 100 |  |  | /* DW2-unwind is just available for 32-bit mode.  */
 | 
      
         | 101 |  |  | #if TARGET_64BIT_DEFAULT
 | 
      
         | 102 |  |  | #error DW2 unwind is not available for 64-bit.
 | 
      
         | 103 |  |  | #endif
 | 
      
         | 104 |  |  | #define SHARED_LIBGCC_UNDEFS_SPEC \
 | 
      
         | 105 |  |  |  "%{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}"
 | 
      
         | 106 |  |  | #else
 | 
      
         | 107 |  |  | #define SHARED_LIBGCC_UNDEFS_SPEC ""
 | 
      
         | 108 |  |  | #endif
 | 
      
         | 109 |  |  |  
 | 
      
         | 110 |  |  | #undef  SUBTARGET_EXTRA_SPECS
 | 
      
         | 111 |  |  | #define SUBTARGET_EXTRA_SPECS                                           \
 | 
      
         | 112 |  |  |   { "shared_libgcc_undefs", SHARED_LIBGCC_UNDEFS_SPEC }
 | 
      
         | 113 |  |  |  
 | 
      
         | 114 |  |  | #define LINK_SPEC "%{mwindows:--subsystem windows} \
 | 
      
         | 115 |  |  |   %{mconsole:--subsystem console} \
 | 
      
         | 116 |  |  |   %{shared: %{mdll: %eshared and mdll are not compatible}} \
 | 
      
         | 117 |  |  |   %{shared: --shared} %{mdll:--dll} \
 | 
      
         | 118 |  |  |   %{static:-Bstatic} %{!static:-Bdynamic} \
 | 
      
         | 119 |  |  |   %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \
 | 
      
         | 120 |  |  |   %(shared_libgcc_undefs)"
 | 
      
         | 121 |  |  |  
 | 
      
         | 122 |  |  | /* Include in the mingw32 libraries with libgcc */
 | 
      
         | 123 |  |  | #ifdef ENABLE_SHARED_LIBGCC
 | 
      
         | 124 |  |  | #define SHARED_LIBGCC_SPEC "%{shared-libgcc:-lgcc_s} %{!shared-libgcc:-lgcc_eh}"
 | 
      
         | 125 |  |  | #else
 | 
      
         | 126 |  |  | #define SHARED_LIBGCC_SPEC /*empty*/
 | 
      
         | 127 |  |  | #endif
 | 
      
         | 128 |  |  | #undef REAL_LIBGCC_SPEC
 | 
      
         | 129 |  |  | #define REAL_LIBGCC_SPEC \
 | 
      
         | 130 |  |  |   "%{mthreads:-lmingwthrd} -lmingw32 \
 | 
      
         | 131 |  |  |    "SHARED_LIBGCC_SPEC" \
 | 
      
         | 132 |  |  |    -lgcc \
 | 
      
         | 133 |  |  |    -lmoldname -lmingwex -lmsvcrt"
 | 
      
         | 134 |  |  |  
 | 
      
         | 135 |  |  | #undef STARTFILE_SPEC
 | 
      
         | 136 |  |  | #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
 | 
      
         | 137 |  |  |   %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
 | 
      
         | 138 |  |  |   crtbegin.o%s"
 | 
      
         | 139 |  |  |  
 | 
      
         | 140 |  |  | #undef ENDFILE_SPEC
 | 
      
         | 141 |  |  | #define ENDFILE_SPEC \
 | 
      
         | 142 |  |  |   "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
 | 
      
         | 143 |  |  |   crtend.o%s"
 | 
      
         | 144 |  |  |  
 | 
      
         | 145 |  |  | /* Override startfile prefix defaults.  */
 | 
      
         | 146 |  |  | #ifndef STANDARD_STARTFILE_PREFIX_1
 | 
      
         | 147 |  |  | #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
 | 
      
         | 148 |  |  | #endif
 | 
      
         | 149 |  |  | #ifndef STANDARD_STARTFILE_PREFIX_2
 | 
      
         | 150 |  |  | #define STANDARD_STARTFILE_PREFIX_2 ""
 | 
      
         | 151 |  |  | #endif
 | 
      
         | 152 |  |  |  
 | 
      
         | 153 |  |  | /* Output STRING, a string representing a filename, to FILE.
 | 
      
         | 154 |  |  |    We canonicalize it to be in Unix format (backslashes are replaced
 | 
      
         | 155 |  |  |    forward slashes.  */
 | 
      
         | 156 |  |  | #undef OUTPUT_QUOTED_STRING
 | 
      
         | 157 |  |  | #define OUTPUT_QUOTED_STRING(FILE, STRING)               \
 | 
      
         | 158 |  |  | do {                                                     \
 | 
      
         | 159 |  |  |   const char *_string = (const char *) (STRING);         \
 | 
      
         | 160 |  |  |   char c;                                                \
 | 
      
         | 161 |  |  |                                                          \
 | 
      
         | 162 |  |  |   putc ('\"', (FILE));                                   \
 | 
      
         | 163 |  |  |                                                          \
 | 
      
         | 164 |  |  |   while ((c = *_string++) != 0)                          \
 | 
      
         | 165 |  |  |     {                                                    \
 | 
      
         | 166 |  |  |       if (c == '\\')                                     \
 | 
      
         | 167 |  |  |         c = '/';                                         \
 | 
      
         | 168 |  |  |                                                          \
 | 
      
         | 169 |  |  |       if (ISPRINT (c))                                   \
 | 
      
         | 170 |  |  |         {                                                \
 | 
      
         | 171 |  |  |           if (c == '\"')                                 \
 | 
      
         | 172 |  |  |             putc ('\\', (FILE));                         \
 | 
      
         | 173 |  |  |           putc (c, (FILE));                              \
 | 
      
         | 174 |  |  |         }                                                \
 | 
      
         | 175 |  |  |       else                                               \
 | 
      
         | 176 |  |  |         fprintf ((FILE), "\\%03o", (unsigned char) c);   \
 | 
      
         | 177 |  |  |     }                                                    \
 | 
      
         | 178 |  |  |                                                          \
 | 
      
         | 179 |  |  |   putc ('\"', (FILE));                                   \
 | 
      
         | 180 |  |  | } while (0)
 | 
      
         | 181 |  |  |  
 | 
      
         | 182 |  |  | /* Define as short unsigned for compatibility with MS runtime.  */
 | 
      
         | 183 |  |  | #undef WINT_TYPE
 | 
      
         | 184 |  |  | #define WINT_TYPE "short unsigned int"
 | 
      
         | 185 |  |  |  
 | 
      
         | 186 |  |  | /* mingw32 uses the  -mthreads option to enable thread support.  */
 | 
      
         | 187 |  |  | #undef GOMP_SELF_SPECS
 | 
      
         | 188 |  |  | #define GOMP_SELF_SPECS "%{fopenmp|ftree-parallelize-loops=*: " \
 | 
      
         | 189 |  |  |                         "-mthreads -pthread}"
 | 
      
         | 190 |  |  | #undef GTM_SELF_SPECS
 | 
      
         | 191 |  |  | #define GTM_SELF_SPECS "%{fgnu-tm:-mthreads -pthread}"
 | 
      
         | 192 |  |  |  
 | 
      
         | 193 |  |  | /* mingw32 atexit function is safe to use in shared libraries.  Use it
 | 
      
         | 194 |  |  |    to register C++ static destructors.  */
 | 
      
         | 195 |  |  | #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
 | 
      
         | 196 |  |  |  
 | 
      
         | 197 |  |  | /* Contains a pointer to type target_ovr_attr defining the target specific
 | 
      
         | 198 |  |  |    overrides of format attributes.  See c-format.h for structure
 | 
      
         | 199 |  |  |    definition.  */
 | 
      
         | 200 |  |  | #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
 | 
      
         | 201 |  |  | #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
 | 
      
         | 202 |  |  |  
 | 
      
         | 203 |  |  | /* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE.  */
 | 
      
         | 204 |  |  | #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
 | 
      
         | 205 |  |  | #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
 | 
      
         | 206 |  |  |  
 | 
      
         | 207 |  |  | /* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
 | 
      
         | 208 |  |  | #undef TARGET_OVERRIDES_FORMAT_INIT
 | 
      
         | 209 |  |  | #define TARGET_OVERRIDES_FORMAT_INIT msformat_init
 | 
      
         | 210 |  |  |  
 | 
      
         | 211 |  |  | /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
 | 
      
         | 212 |  |  | #undef TARGET_FORMAT_TYPES
 | 
      
         | 213 |  |  | #define TARGET_FORMAT_TYPES mingw_format_attributes
 | 
      
         | 214 |  |  |  
 | 
      
         | 215 |  |  | #undef TARGET_N_FORMAT_TYPES
 | 
      
         | 216 |  |  | #define TARGET_N_FORMAT_TYPES 3
 | 
      
         | 217 |  |  |  
 | 
      
         | 218 |  |  | /* Let defaults.h definition of TARGET_USE_JCR_SECTION apply. */
 | 
      
         | 219 |  |  | #undef TARGET_USE_JCR_SECTION
 | 
      
         | 220 |  |  |  
 | 
      
         | 221 |  |  | #define HAVE_ENABLE_EXECUTE_STACK
 | 
      
         | 222 |  |  | #undef  CHECK_EXECUTE_STACK_ENABLED
 | 
      
         | 223 |  |  | #define CHECK_EXECUTE_STACK_ENABLED flag_setstackexecutable
 | 
      
         | 224 |  |  |  
 | 
      
         | 225 |  |  | /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygming. */
 | 
      
         | 226 |  |  | /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
 | 
      
         | 227 |  |  | #if DWARF2_UNWIND_INFO
 | 
      
         | 228 |  |  | #define LIBGCC_EH_EXTN "_dw2"
 | 
      
         | 229 |  |  | #else
 | 
      
         | 230 |  |  | #define LIBGCC_EH_EXTN "_sjlj"
 | 
      
         | 231 |  |  | #endif
 | 
      
         | 232 |  |  | #define LIBGCC_SONAME "libgcc_s" LIBGCC_EH_EXTN "-1.dll"
 | 
      
         | 233 |  |  |  
 | 
      
         | 234 |  |  | /* We should find a way to not have to update this manually.  */
 | 
      
         | 235 |  |  | #define LIBGCJ_SONAME "libgcj" /*LIBGCC_EH_EXTN*/ "-13.dll"
 |