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