doc: Remove i?86-*-linux* installation note from 2003
[official-gcc.git] / gcc / config / i386 / cygming.h
blob9c8c7e33cc2924a0baad86dbc7f5121debcece17
1 /* Operating system specific defines to be used when targeting GCC for
2 hosting on Windows32, using a Unix style C library and tools.
3 Copyright (C) 1995-2024 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #define DWARF2_DEBUGGING_INFO 1
23 #define CODEVIEW_DEBUGGING_INFO 1
25 #undef PREFERRED_DEBUGGING_TYPE
26 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
28 #undef TARGET_SEH
29 #define TARGET_SEH (TARGET_64BIT_MS_ABI && flag_unwind_tables)
31 /* Win64 with SEH cannot represent DRAP stack frames. Disable its use.
32 Force the use of different mechanisms to allocate aligned local data. */
33 #undef MAX_STACK_ALIGNMENT
34 #define MAX_STACK_ALIGNMENT (TARGET_SEH ? 128 : MAX_OFILE_ALIGNMENT)
36 /* 32-bit Windows aligns the stack on a 4-byte boundary but SSE instructions
37 may require 16-byte alignment. */
38 #undef STACK_REALIGN_DEFAULT
39 #define STACK_REALIGN_DEFAULT TARGET_SSE
41 /* Support hooks for SEH. */
42 #undef TARGET_ASM_UNWIND_EMIT
43 #define TARGET_ASM_UNWIND_EMIT i386_pe_seh_unwind_emit
44 #undef TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
45 #define TARGET_ASM_UNWIND_EMIT_BEFORE_INSN false
46 #undef TARGET_ASM_FUNCTION_END_PROLOGUE
47 #define TARGET_ASM_FUNCTION_END_PROLOGUE i386_pe_seh_end_prologue
48 #undef TARGET_ASM_EMIT_EXCEPT_PERSONALITY
49 #define TARGET_ASM_EMIT_EXCEPT_PERSONALITY i386_pe_seh_emit_except_personality
50 #undef TARGET_ASM_INIT_SECTIONS
51 #define TARGET_ASM_INIT_SECTIONS i386_pe_seh_init_sections
52 #define SUBTARGET_ASM_UNWIND_INIT i386_pe_seh_init
54 #undef DEFAULT_ABI
55 #define DEFAULT_ABI (TARGET_64BIT ? MS_ABI : SYSV_ABI)
57 #undef TARGET_PECOFF
58 #define TARGET_PECOFF 1
60 #if ! defined (USE_MINGW64_LEADING_UNDERSCORES)
61 #undef USER_LABEL_PREFIX
62 #define USER_LABEL_PREFIX (TARGET_64BIT ? "" : "_")
64 #undef LOCAL_LABEL_PREFIX
65 #define LOCAL_LABEL_PREFIX (TARGET_64BIT ? "." : "")
67 #undef ASM_GENERATE_INTERNAL_LABEL
68 #define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \
69 sprintf ((BUF), "*%s%s%ld", LOCAL_LABEL_PREFIX, \
70 (PREFIX), (long)(NUMBER))
72 #undef LPREFIX
73 #define LPREFIX (TARGET_64BIT ? ".L" : "L")
75 #endif
77 #undef DEBUGGER_REGNO
78 #define DEBUGGER_REGNO(n) \
79 (TARGET_64BIT ? debugger64_register_map[n] \
80 : (dwarf_debuginfo_p () \
81 ? svr4_debugger_register_map[n] : debugger_register_map[n]))
83 /* Map gcc register number to DWARF 2 CFA column number. For 32 bit
84 target, always use the svr4_debugger_register_map for DWARF .eh_frame
85 even if we don't use DWARF .debug_frame. */
86 #undef DWARF_FRAME_REGNUM
87 #define DWARF_FRAME_REGNUM(n) \
88 (TARGET_64BIT ? debugger64_register_map[(n)] \
89 : svr4_debugger_register_map[(n)])
91 /* The 64-bit MS_ABI changes the set of call-used registers. */
92 #undef DWARF_FRAME_REGISTERS
93 #define DWARF_FRAME_REGISTERS (TARGET_64BIT ? 33 : 17)
95 /* Use section relative relocations for debugging offsets. Unlike
96 other targets that fake this by putting the section VMA at 0, PE
97 won't allow it. */
98 #define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, OFFSET, SECTION) \
99 do { \
100 switch (SIZE) \
102 case 4: \
103 fputs ("\t.secrel32\t", FILE); \
104 assemble_name (FILE, LABEL); \
105 if ((OFFSET) != 0) \
106 fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, \
107 (HOST_WIDE_INT) (OFFSET)); \
108 break; \
109 case 8: \
110 /* This is a hack. There is no 64-bit section relative \
111 relocation. However, the COFF format also does not \
112 support 64-bit file offsets; 64-bit applications are \
113 limited to 32-bits of code+data in any one module. \
114 Fake the 64-bit offset by zero-extending it. */ \
115 fputs ("\t.secrel32\t", FILE); \
116 assemble_name (FILE, LABEL); \
117 if ((OFFSET) != 0) \
118 fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, \
119 (HOST_WIDE_INT) (OFFSET)); \
120 fputs ("\n\t.long\t0", FILE); \
121 break; \
122 default: \
123 gcc_unreachable (); \
125 } while (0)
127 #define TARGET_EXECUTABLE_SUFFIX ".exe"
129 #define TARGET_OS_CPP_BUILTINS() \
130 do \
132 if (!TARGET_64BIT) \
133 builtin_define ("_X86_=1"); \
134 if (TARGET_SEH) \
135 builtin_define ("__SEH__"); \
136 builtin_assert ("system=winnt"); \
137 builtin_define ("__stdcall=__attribute__((__stdcall__))"); \
138 builtin_define ("__fastcall=__attribute__((__fastcall__))"); \
139 builtin_define ("__thiscall=__attribute__((__thiscall__))"); \
140 builtin_define ("__cdecl=__attribute__((__cdecl__))"); \
141 if (!flag_iso) \
143 builtin_define ("_stdcall=__attribute__((__stdcall__))"); \
144 builtin_define ("_fastcall=__attribute__((__fastcall__))"); \
145 builtin_define ("_thiscall=__attribute__((__thiscall__))"); \
146 builtin_define ("_cdecl=__attribute__((__cdecl__))"); \
148 /* Even though linkonce works with static libs, this is needed \
149 to compare typeinfo symbols across dll boundaries. */ \
150 builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0"); \
151 builtin_define ("__GXX_TYPEINFO_EQUALITY_INLINE=0"); \
152 EXTRA_OS_CPP_BUILTINS (); \
154 while (0)
156 /* Get tree.cc to declare a target-specific specialization of
157 merge_decl_attributes. */
158 #define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
160 /* This macro defines names of additional specifications to put in the specs
161 that can be used in various specifications like CC1_SPEC. Its definition
162 is an initializer with a subgrouping for each command option.
164 Each subgrouping contains a string constant, that defines the
165 specification name, and a string constant that used by the GCC driver
166 program.
168 Do not define this macro if it does not need to do anything. */
170 #undef SUBTARGET_EXTRA_SPECS
171 #define SUBTARGET_EXTRA_SPECS \
172 { "mingw_include_path", DEFAULT_TARGET_MACHINE }
174 #undef MATH_LIBRARY
175 #define MATH_LIBRARY ""
177 #undef TARGET_LIBC_HAS_FUNCTION
178 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
180 #define SIZE_TYPE (TARGET_64BIT ? "long long unsigned int" : "unsigned int")
181 #define PTRDIFF_TYPE (TARGET_64BIT ? "long long int" : "int")
183 #define WCHAR_TYPE_SIZE 16
184 #define WCHAR_TYPE "short unsigned int"
186 /* Windows64 continues to use a 32-bit long type. */
187 #undef LONG_TYPE_SIZE
188 #define LONG_TYPE_SIZE 32
190 #define drectve_section() \
191 (fprintf (asm_out_file, "\t.section .drectve\n"), \
192 in_section = NULL)
194 /* Older versions of gas don't handle 'r' as data.
195 Explicitly set data flag with 'd'. */
196 #define READONLY_DATA_SECTION_ASM_OP "\t.section .rdata,\"dr\""
198 /* Don't allow flag_pic to propagate since gas may produce invalid code
199 otherwise. */
201 #undef SUBTARGET_OVERRIDE_OPTIONS
202 #define SUBTARGET_OVERRIDE_OPTIONS \
203 do { \
204 flag_pic = TARGET_64BIT ? 1 : 0; \
205 } while (0)
207 /* Define this macro if references to a symbol must be treated
208 differently depending on something about the variable or
209 function named by the symbol (such as what section it is in).
211 On i386 running Windows NT, modify the assembler name with a suffix
212 consisting of an atsign (@) followed by string of digits that represents
213 the number of bytes of arguments passed to the function, if it has the
214 attribute STDCALL.
216 In addition, we must mark dll symbols specially. Definitions of
217 dllexport'd objects install some info in the .drectve section.
218 References to dllimport'd objects are fetched indirectly via
219 _imp__. If both are declared, dllexport overrides. This is also
220 needed to implement one-only vtables: they go into their own
221 section and we need to set DECL_SECTION_NAME so we do that here.
222 Note that we can be called twice on the same decl. */
224 #define SUBTARGET_ENCODE_SECTION_INFO mingw_pe_encode_section_info
226 /* Local and global relocs can be placed always into readonly memory
227 for PE-COFF targets. */
228 #undef TARGET_ASM_RELOC_RW_MASK
229 #define TARGET_ASM_RELOC_RW_MASK i386_pe_reloc_rw_mask
231 /* Output a common block. */
232 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
233 #define ASM_OUTPUT_ALIGNED_DECL_COMMON \
234 i386_pe_asm_output_aligned_decl_common
236 /* Output the label for an initialized variable. */
237 #undef ASM_DECLARE_OBJECT_NAME
238 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
239 do { \
240 mingw_pe_maybe_record_exported_symbol (DECL, NAME, 1); \
241 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
242 } while (0)
244 /* Output a reference to a label. Fastcall function symbols
245 keep their '@' prefix, while other symbols are prefixed
246 with user_label_prefix. */
247 #undef ASM_OUTPUT_LABELREF
248 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
249 do { \
250 if ((NAME)[0] != FASTCALL_PREFIX) \
251 fputs (user_label_prefix, (STREAM)); \
252 fputs ((NAME), (STREAM)); \
253 } while (0)
255 /* This does much the same in memory rather than to a stream. */
256 #undef TARGET_MANGLE_ASSEMBLER_NAME
257 #define TARGET_MANGLE_ASSEMBLER_NAME i386_pe_mangle_assembler_name
260 /* Emit code to check the stack when allocating more than 4000
261 bytes in one go. */
262 #define CHECK_STACK_LIMIT 4000
264 /* By default, target has a 80387, uses IEEE compatible arithmetic,
265 returns float values in the 387 and needs stack probes.
266 We also align doubles to 64-bits for MSVC default compatibility. */
268 #undef TARGET_SUBTARGET_DEFAULT
269 #define TARGET_SUBTARGET_DEFAULT \
270 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS \
271 | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE)
273 #undef TARGET_SUBTARGET64_DEFAULT
274 #define TARGET_SUBTARGET64_DEFAULT \
275 MASK_128BIT_LONG_DOUBLE
277 /* This is how to output an assembler line
278 that says to advance the location counter
279 to a multiple of 2**LOG bytes. */
281 #undef ASM_OUTPUT_ALIGN
282 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
283 if ((LOG) != 0) fprintf ((FILE), "\t.align %d\n", 1 << (LOG))
285 /* Windows uses explicit import from shared libraries. */
286 #define MULTIPLE_SYMBOL_SPACES 1
288 #define TARGET_ASM_UNIQUE_SECTION mingw_pe_unique_section
289 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
291 #define SUPPORTS_ONE_ONLY 1
293 /* Switch into a generic section. */
294 #define TARGET_ASM_NAMED_SECTION mingw_pe_asm_named_section
296 /* Select attributes for named sections. */
297 #define TARGET_SECTION_TYPE_FLAGS mingw_pe_section_type_flags
299 /* Write the extra assembler code needed to declare a function
300 properly. */
301 #undef ASM_DECLARE_FUNCTION_NAME
302 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
303 i386_pe_start_function (FILE, NAME, DECL)
305 /* Write the extra assembler code needed to declare the name of a
306 cold function partition properly. */
308 #undef ASM_DECLARE_COLD_FUNCTION_NAME
309 #define ASM_DECLARE_COLD_FUNCTION_NAME(FILE, NAME, DECL) \
310 do \
312 mingw_pe_declare_function_type (FILE, NAME, 0); \
313 i386_pe_seh_cold_init (FILE, NAME); \
314 ASM_OUTPUT_LABEL (FILE, NAME); \
316 while (0)
318 #undef ASM_DECLARE_FUNCTION_SIZE
319 #define ASM_DECLARE_FUNCTION_SIZE(FILE,NAME,DECL) \
320 i386_pe_end_function (FILE, NAME, DECL)
322 #undef ASM_DECLARE_COLD_FUNCTION_SIZE
323 #define ASM_DECLARE_COLD_FUNCTION_SIZE(FILE,NAME,DECL) \
324 i386_pe_end_cold_function (FILE, NAME, DECL)
326 /* Add an external function to the list of functions to be declared at
327 the end of the file. */
328 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
329 do \
331 if (TREE_CODE (DECL) == FUNCTION_DECL) \
332 i386_pe_record_external_function ((DECL), (NAME)); \
334 while (0)
336 /* Declare the type properly for any external libcall. */
337 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
338 mingw_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
340 /* This says out to put a global symbol in the BSS section. */
341 #undef ASM_OUTPUT_ALIGNED_BSS
342 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
343 asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
345 /* Output function declarations at the end of the file. */
346 #undef TARGET_ASM_FILE_END
347 #define TARGET_ASM_FILE_END mingw_pe_file_end
349 /* Kludge because of missing PE-COFF support for early LTO debug. */
350 #undef TARGET_ASM_LTO_START
351 #define TARGET_ASM_LTO_START i386_pe_asm_lto_start
352 #undef TARGET_ASM_LTO_END
353 #define TARGET_ASM_LTO_END i386_pe_asm_lto_end
355 #undef ASM_COMMENT_START
356 #define ASM_COMMENT_START " #"
358 #ifndef DWARF2_UNWIND_INFO
359 /* If configured with --disable-sjlj-exceptions, use DWARF2 for 32-bit
360 mode else default to SJLJ. 64-bit code uses SEH unless you request
361 SJLJ. */
362 #if (defined (CONFIG_SJLJ_EXCEPTIONS) && !CONFIG_SJLJ_EXCEPTIONS)
363 /* The logic of this #if must be kept synchronised with the logic
364 for selecting the tmake_eh_file fragment in libgcc/config.host. */
365 #define DWARF2_UNWIND_INFO 1
366 #else
367 #define DWARF2_UNWIND_INFO 0
368 #endif
369 #endif
371 #undef PROFILE_HOOK
372 #define PROFILE_HOOK(LABEL) \
373 if (MAIN_NAME_P (DECL_NAME (current_function_decl))) \
375 emit_call_insn (gen_rtx_CALL (VOIDmode, \
376 gen_rtx_MEM (FUNCTION_MODE, \
377 gen_rtx_SYMBOL_REF (Pmode, "_monstartup")), \
378 const0_rtx)); \
381 /* For Win32 ABI compatibility */
382 #undef DEFAULT_PCC_STRUCT_RETURN
383 #define DEFAULT_PCC_STRUCT_RETURN 0
385 /* MSVC returns aggregate types of up to 8 bytes via registers.
386 See i386.cc:ix86_return_in_memory. */
387 #undef MS_AGGREGATE_RETURN
388 #define MS_AGGREGATE_RETURN 1
390 /* Biggest alignment supported by the object file format of this
391 machine. Use this macro to limit the alignment which can be
392 specified using the `__attribute__ ((aligned (N)))' construct. If
393 not defined, the default value is `BIGGEST_ALIGNMENT'. */
394 /* IMAGE_SCN_ALIGN_8192BYTES is the largest section alignment flag
395 specified in the PECOFF60 spec. Native MS compiler also limits
396 user-specified alignment to 8192 bytes. */
397 #undef MAX_OFILE_ALIGNMENT
398 #define MAX_OFILE_ALIGNMENT (8192 * 8)
400 /* BIGGEST_FIELD_ALIGNMENT macro is used directly by libobjc, There, we
401 align internal doubles in structures on dword boundaries. Otherwise,
402 support vector modes using ADJUST_FIELD_ALIGN, defined in i386.h. */
403 #ifdef IN_TARGET_LIBS
404 #undef BIGGEST_FIELD_ALIGNMENT
405 #define BIGGEST_FIELD_ALIGNMENT 64
406 #endif
408 /* Enable alias attribute support. */
409 #ifndef SET_ASM_OP
410 #define SET_ASM_OP "\t.set\t"
411 #endif
413 /* This implements the `alias' attribute, keeping any stdcall or
414 fastcall decoration. */
415 #undef ASM_OUTPUT_DEF_FROM_DECLS
416 #define ASM_OUTPUT_DEF_FROM_DECLS(STREAM, DECL, TARGET) \
417 do \
419 const char *alias \
420 = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
421 mingw_pe_maybe_record_exported_symbol (DECL, alias, 0); \
422 if (TREE_CODE (DECL) == FUNCTION_DECL) \
423 mingw_pe_declare_function_type (STREAM, alias, \
424 TREE_PUBLIC (DECL)); \
425 ASM_OUTPUT_DEF (STREAM, alias, IDENTIFIER_POINTER (TARGET)); \
426 } while (0)
428 /* GNU as supports weak symbols on PECOFF. */
429 #ifdef HAVE_GAS_WEAK
430 #define ASM_WEAKEN_LABEL(FILE, NAME) \
431 do \
433 fputs ("\t.weak\t", (FILE)); \
434 assemble_name ((FILE), (NAME)); \
435 fputc ('\n', (FILE)); \
437 while (0)
439 #endif /* HAVE_GAS_WEAK */
441 /* Decide whether it is safe to use a local alias for a virtual function
442 when constructing thunks. */
443 #undef TARGET_USE_LOCAL_THUNK_ALIAS_P
444 #define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) (!DECL_ONE_ONLY (DECL))
446 #define SUBTARGET_ATTRIBUTE_TABLE \
447 { "selectany", 0, 0, true, false, false, false, \
448 mingw_handle_selectany_attribute, NULL }
449 /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
450 affects_type_identity, handler, exclude } */
452 /* mcount() does not need a counter variable. */
453 #undef NO_PROFILE_COUNTERS
454 #define NO_PROFILE_COUNTERS 1
456 #define TARGET_VALID_DLLIMPORT_ATTRIBUTE_P mingw_pe_valid_dllimport_attribute_p
457 #define TARGET_CXX_ADJUST_CLASS_AT_DEFINITION i386_pe_adjust_class_at_definition
458 #define SUBTARGET_MANGLE_DECL_ASSEMBLER_NAME i386_pe_mangle_decl_assembler_name
460 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
461 #define TARGET_ASM_ASSEMBLE_VISIBILITY i386_pe_assemble_visibility
463 #undef SUB_TARGET_RECORD_STUB
464 #define SUB_TARGET_RECORD_STUB mingw_pe_record_stub
466 /* Static stack checking is supported by means of probes. */
467 #define STACK_CHECK_STATIC_BUILTIN 1
469 #ifndef HAVE_GAS_ALIGNED_COMM
470 # define HAVE_GAS_ALIGNED_COMM 0
471 #endif
473 #define PE_COFF_LEGITIMIZE_EXTERN_DECL \
474 (ix86_cmodel == CM_LARGE_PIC || ix86_cmodel == CM_MEDIUM_PIC)
476 #define HAVE_64BIT_POINTERS TARGET_64BIT_DEFAULT