]> gcc.gnu.org Git - gcc.git/blame - gcc/config/i386/cygwin.h
chorus.h: Consistently define *_DEBUGGING_INFO with the value 1.
[gcc.git] / gcc / config / i386 / cygwin.h
CommitLineData
3a2c1cd8 1/* Operating system specific defines to be used when targeting GCC for
db009825 2 hosting on Windows32, using a Unix style C library and tools.
006946e4 3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
4592bdcb 4 Free Software Foundation, Inc.
3a2c1cd8
MM
5
6This file is part of GNU CC.
7
8GNU CC is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2, or (at your option)
11any later version.
12
13GNU CC is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with GNU CC; see the file COPYING. If not, write to
20the Free Software Foundation, 59 Temple Place - Suite 330,
892a2d68 21Boston, MA 02111-1307, USA. */
3a2c1cd8 22
23532de9
JT
23#define DBX_DEBUGGING_INFO 1
24#define SDB_DEBUGGING_INFO 1
73061e0f 25#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
3a2c1cd8 26
39ed301b 27#define TARGET_VERSION fprintf (stderr, " (x86 Cygwin)");
45936a85
DD
28#define TARGET_EXECUTABLE_SUFFIX ".exe"
29
79f96374 30#include <stdio.h>
39ed301b
DB
31#include "i386/i386.h"
32#include "i386/unix.h"
33#include "i386/bsd.h"
73061e0f
JW
34#include "i386/gas.h"
35#include "dbxcoff.h"
3a2c1cd8 36
f3f1190d
DS
37/* Masks for subtarget switches used by other files. */
38#define MASK_NOP_FUN_DLLIMPORT 0x08000000 /* Ignore dllimport for functions */
040688bd 39
f3f1190d 40/* Used in winnt.c. */
040688bd
GN
41#define TARGET_NOP_FUN_DLLIMPORT (target_flags & MASK_NOP_FUN_DLLIMPORT)
42
43#undef SUBTARGET_SWITCHES
44#define SUBTARGET_SWITCHES \
f3f1190d
DS
45{ "cygwin", 0, N_("Use the Cygwin interface") }, \
46{ "no-cygwin", 0, N_("Use the Mingw32 interface") }, \
47{ "windows", 0, N_("Create GUI application") }, \
48{ "no-win32", 0, N_("Don't set Windows defines") }, \
49{ "win32", 0, N_("Set Windows defines") }, \
50{ "console", 0, N_("Create console application") },\
51{ "dll", 0, N_("Generate code for a DLL") }, \
52{ "nop-fun-dllimport", MASK_NOP_FUN_DLLIMPORT, \
53 N_("Ignore dllimport for functions") }, \
54{ "no-nop-fun-dllimport", -MASK_NOP_FUN_DLLIMPORT, "" }, \
047142d3 55{ "threads", 0, N_("Use Mingw-specific thread support") },
040688bd 56
f60ed6be
NB
57#define MAYBE_UWIN_CPP_BUILTINS() /* Nothing. */
58#define TARGET_OS_CPP_BUILTINS() \
59 do \
60 { \
61 builtin_define ("_X86_=1"); \
62 builtin_assert ("system=winnt"); \
63 builtin_define ("__stdcall=__attribute__((__stdcall__))"); \
64 builtin_define ("__cdecl=__attribute__((__cdecl__))"); \
65 builtin_define ("__declspec(x)=__attribute__((x))"); \
66 if (!flag_iso) \
67 { \
68 builtin_define ("_stdcall=__attribute__((__stdcall__))"); \
69 builtin_define ("_cdecl=__attribute__((__cdecl__))"); \
70 } \
71 MAYBE_UWIN_CPP_BUILTINS (); \
72 } \
73 while (0)
3a2c1cd8 74
f6fc3552 75#ifdef CROSS_COMPILE
0a977123
CF
76#define CYGWIN_INCLUDES "%{!nostdinc:-idirafter " CYGWIN_CROSS_DIR "/include}"
77#define W32API_INC "%{!nostdinc:-idirafter " CYGWIN_CROSS_DIR "/include/w32api}"
9a33d505 78#define W32API_LIB "-L" CYGWIN_CROSS_DIR "/lib/w32api/"
4e190cf3
CF
79#define CYGWIN_LIB CYGWIN_CROSS_DIR "/lib"
80#define MINGW_LIBS "-L" CYGWIN_CROSS_DIR "/lib/mingw"
0a977123 81#define MINGW_INCLUDES "%{!nostdinc:-isystem " CYGWIN_CROSS_DIR "/include/mingw/g++-3 "\
936ee790 82 "-isystem " CYGWIN_CROSS_DIR "/include/mingw/g++ "\
0a977123 83 "-idirafter " CYGWIN_CROSS_DIR "/include/mingw}"
f6fc3552 84#else
e742b08a
CF
85#define CYGWIN_INCLUDES "%{!nostdinc:-isystem /usr/local/include "\
86 "-idirafter " CYGWIN_CROSS_DIR "/include "\
87 "-idirafter /usr/include}"
d0e06c90
CF
88#define W32API_INC "%{!nostdinc:"\
89 "-idirafter " CYGWIN_CROSS_DIR "/include/w32api "\
90 "-idirafter /usr/include/w32api}"
91#define W32API_LIB "-L" CYGWIN_CROSS_DIR "/lib/w32api/ -L/usr/lib/w32api/"
4e190cf3
CF
92#define CYGWIN_LIB "/usr/lib"
93#define MINGW_LIBS "-L/usr/local/lib/mingw -L/usr/lib/mingw"
0a977123 94#define MINGW_INCLUDES "%{!nostdinc:-isystem /usr/include/mingw/g++-3 "\
936ee790 95 "-isystem /usr/include/mingw/g++ "\
e742b08a
CF
96 "-isystem /usr/local/include/mingw "\
97 "-idirafter " CYGWIN_CROSS_DIR "/include/mingw "\
0a977123 98 "-idirafter /usr/include/mingw}"
4e190cf3
CF
99#endif
100
672a6f42
NB
101/* Get tree.c to declare a target-specific specialization of
102 merge_decl_attributes. */
103#define TARGET_DLLIMPORT_DECL_ATTRIBUTES
104
9a33d505
CF
105/* Support the __declspec keyword by turning them into attributes.
106 We currently only support: dllimport and dllexport.
107 Note that the current way we do this may result in a collision with
108 predefined attributes later on. This can be solved by using one attribute,
109 say __declspec__, and passing args to it. The problem with that approach
110 is that args are not accumulated: each new appearance would clobber any
111 existing args. */
4e190cf3
CF
112
113#undef CPP_SPEC
1ba7b414 114#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} \
9a33d505
CF
115 %{mno-win32:%{mno-cygwin: %emno-cygwin and mno-win32 are not compatible}} \
116 %{mno-cygwin:-D__MSVCRT__ -D__MINGW32__ %{mthreads:-D_MT} "\
117 MINGW_INCLUDES "} \
0a977123 118 %{!mno-cygwin:-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix "\
9a33d505 119 CYGWIN_INCLUDES "}\
0a977123 120 %{mwin32|mno-cygwin:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}}\
9a33d505
CF
121 %{!mno-win32:" W32API_INC "}\
122"
123
124#undef STARTFILE_SPEC
2baa5453 125#define STARTFILE_SPEC "\
cf521102
CF
126 %{shared|mdll: %{mno-cygwin:" MINGW_LIBS " dllcrt2%O%s}}\
127 %{!shared: %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:" MINGW_LIBS " crt2%O%s}\
9a33d505 128 %{pg:gcrt0%O%s}}}\
936ee790 129"
ffb6cec0 130
9a33d505
CF
131/* Normally, -lgcc is not needed since everything in it is in the DLL, but we
132 want to allow things to be added to it when installing new versions of
133 GCC without making a new CYGWIN.DLL, so we leave it. Profiling is handled
892a2d68 134 by calling the init function from the prologue. */
9a33d505
CF
135
136#undef LIBGCC_SPEC
137#define LIBGCC_SPEC "%{mno-cygwin: %{mthreads:-lmingwthrd} -lmingw32} -lgcc %{mno-cygwin:-lmoldname -lmsvcrt}"
138
ffb6cec0
SC
139/* This macro defines names of additional specifications to put in the specs
140 that can be used in various specifications like CC1_SPEC. Its definition
141 is an initializer with a subgrouping for each command option.
142
143 Each subgrouping contains a string constant, that defines the
144 specification name, and a string constant that used by the GNU CC driver
145 program.
146
147 Do not define this macro if it does not need to do anything. */
148
149#undef SUBTARGET_EXTRA_SPECS
150#define SUBTARGET_EXTRA_SPECS \
151 { "mingw_include_path", DEFAULT_TARGET_MACHINE }
956d6950 152
f5089633
RK
153/* We have to dynamic link to get to the system DLLs. All of libc, libm and
154 the Unix stuff is in cygwin.dll. The import library is called
155 'libcygwin.a'. For Windows applications, include more libraries, but
156 always include kernel32. We'd like to specific subsystem windows to
157 ld, but that doesn't work just yet. */
3a2c1cd8
MM
158
159#undef LIB_SPEC
2baa5453
CF
160#define LIB_SPEC "\
161 %{pg:-lgmon} \
03fb4780
CF
162 %{!mno-cygwin:-lcygwin} \
163 %{mno-cygwin:%{mthreads:-lmingwthrd} -lmingw32} \
164 %{mwindows:-lgdi32 -lcomdlg32} \
165 -luser32 -lkernel32 -ladvapi32 -lshell32"
3a2c1cd8 166
2baa5453
CF
167#define LINK_SPEC W32API_LIB "\
168 %{mwindows:--subsystem windows} \
03fb4780
CF
169 %{mconsole:--subsystem console} \
170 %{shared: %{mdll: %eshared and mdll are not compatible}} \
171 %{shared: --shared} %{mdll:--dll} \
172 %{static:-Bstatic} %{!static:-Bdynamic} \
173 %{shared|mdll: -e \
174 %{mno-cygwin:_DllMainCRTStartup@12} \
9a33d505
CF
175 %{!mno-cygwin:__cygwin_dll_entry@12}}\
176 --dll-search-prefix=cyg"
26d1d6ad 177
03fb4780
CF
178#undef MATH_LIBRARY
179#define MATH_LIBRARY ""
3a2c1cd8
MM
180
181#define SIZE_TYPE "unsigned int"
182#define PTRDIFF_TYPE "int"
3a2c1cd8
MM
183#define WCHAR_TYPE_SIZE 16
184#define WCHAR_TYPE "short unsigned int"
040688bd 185
27da1b4d 186\f
c678a7f8
NC
187/* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop). */
188#define HANDLE_PRAGMA_PACK_PUSH_POP 1
189
03fb4780
CF
190union tree_node;
191#define TREE union tree_node *
27da1b4d 192\f
3a2c1cd8 193#undef EXTRA_SECTIONS
2cc07db4 194#define EXTRA_SECTIONS in_drectve
3a2c1cd8
MM
195
196#undef EXTRA_SECTION_FUNCTIONS
197#define EXTRA_SECTION_FUNCTIONS \
27da1b4d
MK
198 DRECTVE_SECTION_FUNCTION \
199 SWITCH_TO_SECTION_FUNCTION
3a2c1cd8 200
27da1b4d
MK
201#define DRECTVE_SECTION_FUNCTION \
202void \
203drectve_section () \
204{ \
205 if (in_section != in_drectve) \
206 { \
207 fprintf (asm_out_file, "%s\n", "\t.section .drectve\n"); \
208 in_section = in_drectve; \
209 } \
210}
79f96374 211void drectve_section PARAMS ((void));
27da1b4d
MK
212
213/* Switch to SECTION (an `enum in_section').
214
215 ??? This facility should be provided by GCC proper.
216 The problem is that we want to temporarily switch sections in
217 ASM_DECLARE_OBJECT_NAME and then switch back to the original section
218 afterwards. */
219#define SWITCH_TO_SECTION_FUNCTION \
79f96374 220void switch_to_section PARAMS ((enum in_section, tree)); \
27da1b4d
MK
221void \
222switch_to_section (section, decl) \
223 enum in_section section; \
224 tree decl; \
225{ \
226 switch (section) \
227 { \
228 case in_text: text_section (); break; \
229 case in_data: data_section (); break; \
230 case in_named: named_section (decl, NULL, 0); break; \
27da1b4d
MK
231 case in_drectve: drectve_section (); break; \
232 default: abort (); break; \
233 } \
234}
235
2b9f972f 236/* Don't allow flag_pic to propagate since gas may produce invalid code
892a2d68 237 otherwise. */
2b9f972f
MK
238
239#undef SUBTARGET_OVERRIDE_OPTIONS
240#define SUBTARGET_OVERRIDE_OPTIONS \
241do { \
242 if (flag_pic) \
243 { \
244 warning ("-f%s ignored for target (all code is position independent)",\
245 (flag_pic > 1) ? "PIC" : "pic"); \
246 flag_pic = 0; \
247 } \
248} while (0) \
249
3a2c1cd8
MM
250/* Define this macro if references to a symbol must be treated
251 differently depending on something about the variable or
252 function named by the symbol (such as what section it is in).
253
3a2c1cd8
MM
254 On i386 running Windows NT, modify the assembler name with a suffix
255 consisting of an atsign (@) followed by string of digits that represents
256 the number of bytes of arguments passed to the function, if it has the
27da1b4d
MK
257 attribute STDCALL.
258
259 In addition, we must mark dll symbols specially. Definitions of
260 dllexport'd objects install some info in the .drectve section.
261 References to dllimport'd objects are fetched indirectly via
262 _imp__. If both are declared, dllexport overrides. This is also
263 needed to implement one-only vtables: they go into their own
264 section and we need to set DECL_SECTION_NAME so we do that here.
265 Note that we can be called twice on the same decl. */
266
fb49053f
RH
267#undef TARGET_ENCODE_SECTION_INFO
268#define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info
772c5265
RH
269#undef TARGET_STRIP_NAME_ENCODING
270#define TARGET_STRIP_NAME_ENCODING i386_pe_strip_name_encoding_full
27da1b4d
MK
271\f
272/* Output a reference to a label. */
273#undef ASM_OUTPUT_LABELREF
274#define ASM_OUTPUT_LABELREF(STREAM, NAME) \
275 fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, \
772c5265 276 i386_pe_strip_name_encoding (NAME)) \
27da1b4d 277
27da1b4d
MK
278/* Output a common block. */
279#undef ASM_OUTPUT_COMMON
280#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
281do { \
282 if (i386_pe_dllexport_name_p (NAME)) \
8e260ba4 283 i386_pe_record_exported_symbol (NAME, 1); \
27da1b4d
MK
284 if (! i386_pe_dllimport_name_p (NAME)) \
285 { \
286 fprintf ((STREAM), "\t.comm\t"); \
287 assemble_name ((STREAM), (NAME)); \
288 fprintf ((STREAM), ", %d\t%s %d\n", \
289 (ROUNDED), ASM_COMMENT_START, (SIZE)); \
290 } \
291} while (0)
292
293/* Output the label for an initialized variable. */
294#undef ASM_DECLARE_OBJECT_NAME
295#define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
296do { \
297 if (i386_pe_dllexport_name_p (NAME)) \
8e260ba4 298 i386_pe_record_exported_symbol (NAME, 1); \
27da1b4d
MK
299 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
300} while (0)
301
302\f
1e9b6647 303/* Emit code to check the stack when allocating more that 4000
892a2d68 304 bytes in one go. */
3a2c1cd8 305
1e9b6647 306#define CHECK_STACK_LIMIT 4000
3a2c1cd8
MM
307
308/* By default, target has a 80387, uses IEEE compatible arithmetic,
309 and returns float values in the 387 and needs stack probes */
25f94bb5 310#undef TARGET_SUBTARGET_DEFAULT
3a2c1cd8 311
25f94bb5 312#define TARGET_SUBTARGET_DEFAULT \
3a2c1cd8
MM
313 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE)
314
d5967781
MM
315/* This is how to output an assembler line
316 that says to advance the location counter
317 to a multiple of 2**LOG bytes. */
318
319#undef ASM_OUTPUT_ALIGN
320#define ASM_OUTPUT_ALIGN(FILE,LOG) \
321 if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
b64deb96 322
5b5686f5
JM
323/* Define this macro if in some cases global symbols from one translation
324 unit may not be bound to undefined symbols in another translation unit
325 without user intervention. For instance, under Microsoft Windows
326 symbols must be explicitly imported from shared libraries (DLLs). */
327#define MULTIPLE_SYMBOL_SPACES
328
03fb4780 329extern void i386_pe_unique_section PARAMS ((TREE, int));
ae46c4e0 330#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
b64deb96 331
ad4ff310 332#define SUPPORTS_ONE_ONLY 1
b64deb96 333
7c262518
RH
334/* Switch into a generic section. */
335#define TARGET_ASM_NAMED_SECTION i386_pe_asm_named_section
336
337/* Select attributes for named sections. */
338#define TARGET_SECTION_TYPE_FLAGS i386_pe_section_type_flags
8f3189a4 339
672a233f
ILT
340/* Write the extra assembler code needed to declare a function
341 properly. If we are generating SDB debugging information, this
342 will happen automatically, so we only need to handle other cases. */
c8d9f965 343#undef ASM_DECLARE_FUNCTION_NAME
672a233f
ILT
344#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
345 do \
346 { \
c8d9f965 347 if (i386_pe_dllexport_name_p (NAME)) \
8e260ba4 348 i386_pe_record_exported_symbol (NAME, 0); \
672a233f
ILT
349 if (write_symbols != SDB_DEBUG) \
350 i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \
351 ASM_OUTPUT_LABEL (FILE, NAME); \
352 } \
353 while (0)
354
355/* Add an external function to the list of functions to be declared at
356 the end of the file. */
357#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
358 do \
359 { \
360 if (TREE_CODE (DECL) == FUNCTION_DECL) \
361 i386_pe_record_external_function (NAME); \
362 } \
363 while (0)
364
365/* Declare the type properly for any external libcall. */
366#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
367 i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
368
892a2d68 369/* This says out to put a global symbol in the BSS section. */
0181177d
JL
370#undef ASM_OUTPUT_ALIGNED_BSS
371#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
372 asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
373
672a233f 374/* Output function declarations at the end of the file. */
4cf12e7e 375#undef ASM_FILE_END
672a233f
ILT
376#define ASM_FILE_END(FILE) \
377 i386_pe_asm_file_end (FILE)
378
8f3189a4
JW
379#undef ASM_COMMENT_START
380#define ASM_COMMENT_START " #"
da932f04 381
e5c4bd1b
JM
382/* DWARF2 Unwinding doesn't work with exception handling yet. To make
383 it work, we need to build a libgcc_s.dll, and dcrt0.o should be
384 changed to call __register_frame_info/__deregister_frame_info. */
385#define DWARF2_UNWIND_INFO 0
386
892a2d68 387/* Don't assume anything about the header files. */
05853640 388#define NO_IMPLICIT_EXTERN_C
672a233f 389
84530511 390#define SUBTARGET_PROLOGUE \
70f4f91c 391 if (current_function_profile \
5b47282c 392 && MAIN_NAME_P (DECL_NAME (current_function_decl))) \
84530511 393 { \
e075ae69 394 emit_call_insn (gen_rtx (CALL, VOIDmode, \
936ee790 395 gen_rtx_MEM (FUNCTION_MODE, \
e075ae69
RH
396 gen_rtx_SYMBOL_REF (Pmode, "_monstartup")), \
397 const0_rtx)); \
84530511
SC
398 }
399
672a233f
ILT
400/* External function declarations. */
401
79f96374
DB
402extern void i386_pe_record_external_function PARAMS ((const char *));
403extern void i386_pe_declare_function_type PARAMS ((FILE *, const char *, int));
404extern void i386_pe_record_exported_symbol PARAMS ((const char *, int));
405extern void i386_pe_asm_file_end PARAMS ((FILE *));
406extern int i386_pe_dllexport_name_p PARAMS ((const char *));
407extern int i386_pe_dllimport_name_p PARAMS ((const char *));
a2cd38a9
MK
408
409/* For Win32 ABI compatibility */
410#undef DEFAULT_PCC_STRUCT_RETURN
411#define DEFAULT_PCC_STRUCT_RETURN 0
412
3fafc2f6
MK
413/* No data type wants to be aligned rounder than this. */
414#undef BIGGEST_ALIGNMENT
415#define BIGGEST_ALIGNMENT 128
416
c976fa88
DS
417/* Native complier aligns internal doubles in structures on dword boundaries. */
418#undef BIGGEST_FIELD_ALIGNMENT
419#define BIGGEST_FIELD_ALIGNMENT 64
420
3fafc2f6 421/* A bitfield declared as `int' forces `int' alignment for the struct. */
006946e4
JM
422#undef PCC_BITFIELD_TYPE_MATTERS
423#define PCC_BITFIELD_TYPE_MATTERS 1
03fb4780
CF
424#define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
425
3fafc2f6 426
8c84eeed
MK
427/* Enable alias attribute support. */
428#ifndef SET_ASM_OP
71d48a01 429#define SET_ASM_OP "\t.set\t"
8c84eeed
MK
430#endif
431
0a977123
CF
432/* Override GCC's relative pathname lookup (ie., relocatability) unless
433 otherwise told by other subtargets. */
434#ifndef WIN32_NO_ABSOLUTE_INST_DIRS
abffe289
CF
435#undef MD_STARTFILE_PREFIX
436#define MD_STARTFILE_PREFIX "/usr/lib/"
437
03fb4780 438#undef STANDARD_STARTFILE_PREFIX
abffe289 439#define STANDARD_STARTFILE_PREFIX "/usr/lib/mingw/"
03fb4780 440
f6fc3552
CF
441#ifndef CROSS_COMPILE
442#undef LOCAL_INCLUDE_DIR
443#undef TOOL_INCLUDE_DIR
444#undef SYSTEM_INCLUDE_DIR
445#undef STANDARD_INCLUDE_DIR
446#define STANDARD_INCLUDE_DIR 0
0a977123
CF
447#endif /* not CROSS_COMPILE */
448#endif /* not WIN32_NO_ABSOLUTE_INST_DIRS */
f6fc3552 449
03fb4780
CF
450#undef TREE
451
452#ifndef BUFSIZ
453# undef FILE
454#endif
This page took 0.985616 seconds and 5 git commands to generate.