re PR rtl-optimization/63620 (RELOAD lost SET_GOT dependency on Darwin)
[gcc.git] / gcc / config / i386 / cygwin.h
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-2014 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
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.
11
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.
16
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/>. */
20
21 #define EXTRA_OS_CPP_BUILTINS() \
22 do \
23 { \
24 builtin_define ("__CYGWIN__"); \
25 if (!TARGET_64BIT) \
26 builtin_define ("__CYGWIN32__"); \
27 builtin_define ("__unix__"); \
28 builtin_define ("__unix"); \
29 } \
30 while (0)
31
32 #undef CPP_SPEC
33 #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
34 %{!ansi:-Dunix} \
35 %{pthread:-D_REENTRANT} \
36 %{mwin32:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}} \
37 %{!nostdinc:%{!mno-win32:-idirafter ../include/w32api%s -idirafter ../../include/w32api%s}}\
38 "
39
40 #undef STARTFILE_SPEC
41 #define STARTFILE_SPEC "\
42 %{!shared: %{!mdll: crt0%O%s \
43 %{pg:gcrt0%O%s}}}\
44 %{shared:crtbeginS.o%s;:crtbegin.o%s}"
45
46 #undef ENDFILE_SPEC
47 #define ENDFILE_SPEC \
48 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}\
49 %{!shared:%:if-exists(default-manifest.o%s)}\
50 crtend.o%s"
51
52 /* Normally, -lgcc is not needed since everything in it is in the DLL, but we
53 want to allow things to be added to it when installing new versions of
54 GCC without making a new CYGWIN.DLL, so we leave it. Profiling is handled
55 by calling the init function from main. */
56
57 #ifdef ENABLE_SHARED_LIBGCC
58 #define SHARED_LIBGCC_SPEC " \
59 %{static|static-libgcc:-lgcc -lgcc_eh} \
60 %{!static: \
61 %{!static-libgcc: \
62 -lgcc_s -lgcc \
63 } \
64 } "
65 #else
66 #define SHARED_LIBGCC_SPEC " -lgcc "
67 #endif
68
69 #undef REAL_LIBGCC_SPEC
70 #define REAL_LIBGCC_SPEC SHARED_LIBGCC_SPEC
71
72 /* We have to dynamic link to get to the system DLLs. All of libc, libm and
73 the Unix stuff is in cygwin.dll. The import library is called
74 'libcygwin.a'. For Windows applications, include more libraries, but
75 always include kernel32. We'd like to specific subsystem windows to
76 ld, but that doesn't work just yet. */
77
78 #undef LIB_SPEC
79 #define LIB_SPEC "\
80 %{pg:-lgmon} \
81 %{pthread: } \
82 -lcygwin \
83 %{mwindows:-lgdi32 -lcomdlg32} \
84 -ladvapi32 -lshell32 -luser32 -lkernel32"
85
86 /* To implement C++ function replacement we always wrap the cxx
87 malloc-like operators. See N2800 #17.6.4.6 [replacement.functions] */
88 #define CXX_WRAP_SPEC_LIST " \
89 --wrap _Znwj \
90 --wrap _Znaj \
91 --wrap _ZdlPv \
92 --wrap _ZdaPv \
93 --wrap _ZnwjRKSt9nothrow_t \
94 --wrap _ZnajRKSt9nothrow_t \
95 --wrap _ZdlPvRKSt9nothrow_t \
96 --wrap _ZdaPvRKSt9nothrow_t \
97 "
98
99 #if defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)
100
101 #if USE_CYGWIN_LIBSTDCXX_WRAPPERS
102 /* Default on, only explict -mno disables. */
103 #define CXX_WRAP_SPEC_OPT "!mno-use-libstdc-wrappers"
104 #else
105 /* Default off, only explict -m enables. */
106 #define CXX_WRAP_SPEC_OPT "muse-libstdc-wrappers"
107 #endif
108
109 #define CXX_WRAP_SPEC "%{" CXX_WRAP_SPEC_OPT ":" CXX_WRAP_SPEC_LIST "}"
110
111 #else /* !defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS) */
112
113 #define CXX_WRAP_SPEC ""
114
115 #endif /* ?defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS) */
116
117 #define LINK_SPEC "\
118 %{mwindows:--subsystem windows} \
119 %{mconsole:--subsystem console} \
120 " CXX_WRAP_SPEC " \
121 %{shared: %{mdll: %eshared and mdll are not compatible}} \
122 %{shared: --shared} %{mdll:--dll} \
123 %{static:-Bstatic} %{!static:-Bdynamic} \
124 %{shared|mdll: --enable-auto-image-base -e __cygwin_dll_entry@12} \
125 --dll-search-prefix=cyg \
126 %{!shared: %{!mdll: --large-address-aware --tsaware}}"
127
128 /* Binutils does not handle weak symbols from dlls correctly. For now,
129 do not use them unnecessarily in gthr-posix.h. */
130 #define GTHREAD_USE_WEAK 0
131
132 /* Every program on cygwin links against cygwin1.dll which contains
133 the pthread routines. There is no need to explicitly link them
134 and the -pthread flag is accepted only for compatibility. */
135 #undef GOMP_SELF_SPECS
136 #define GOMP_SELF_SPECS ""
137 #undef GTM_SELF_SPECS
138 #define GTM_SELF_SPECS ""
139
140 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
141 #if DWARF2_UNWIND_INFO
142 #define LIBGCC_EH_EXTN ""
143 #else
144 #define LIBGCC_EH_EXTN "-sjlj"
145 #endif
146 #define LIBGCC_SONAME "cyggcc_s" LIBGCC_EH_EXTN "-1.dll"
147
148 /* We should find a way to not have to update this manually. */
149 #define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-15.dll"
150