xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/netbsd.h (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /* Base configuration file for all NetBSD targets.
2    Copyright (C) 1997-2015 Free Software Foundation, Inc.
3 
4 This file is part of GCC.
5 
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10 
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3.  If not see
18 <http://www.gnu.org/licenses/>.  */
19 
20 /* TARGET_OS_CPP_BUILTINS() common to all NetBSD targets.  */
21 #define NETBSD_OS_CPP_BUILTINS_COMMON()		\
22   do						\
23     {						\
24       builtin_define ("__NetBSD__");		\
25       builtin_define ("__unix__");		\
26       builtin_define ("__syslog_attribute__");	\
27       builtin_assert ("system=bsd");		\
28       builtin_assert ("system=unix");		\
29       builtin_assert ("system=NetBSD");		\
30     }						\
31   while (0)
32 
33 /* CPP_SPEC parts common to all NetBSD targets.  */
34 #define NETBSD_CPP_SPEC				\
35   "%{posix:-D_POSIX_SOURCE} \
36    %{pthread:-D_REENTRANT -D_PTHREADS}"
37 
38 /* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD
39    source tree so it can be configured appropriately without using
40    the GNU configure/build mechanism.
41 
42    NETBSD_TOOLS is defined when gcc is built as cross-compiler for
43    the in-tree toolchain.
44  */
45 
46 #if defined(NETBSD_NATIVE) || defined(NETBSD_TOOLS)
47 
48 /* Look for the include files in the system-defined places.  */
49 
50 #undef GPLUSPLUS_INCLUDE_DIR
51 #define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++"
52 
53 #undef GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT
54 #define GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT 1
55 
56 #undef GPLUSPLUS_BACKWARD_INCLUDE_DIR
57 #define GPLUSPLUS_BACKWARD_INCLUDE_DIR "/usr/include/g++/backward"
58 
59 #undef GCC_INCLUDE_DIR_ADD_SYSROOT
60 #define GCC_INCLUDE_DIR_ADD_SYSROOT 1
61 
62 /*
63  * XXX figure out a better way to do this
64  */
65 #undef GCC_INCLUDE_DIR
66 #define GCC_INCLUDE_DIR "/usr/include/gcc-5"
67 
68 /* Under NetBSD, the normal location of the various *crt*.o files is the
69    /usr/lib directory.  */
70 
71 #undef STANDARD_STARTFILE_PREFIX
72 #define STANDARD_STARTFILE_PREFIX	"/usr/lib/"
73 #undef STANDARD_STARTFILE_PREFIX_1
74 #define STANDARD_STARTFILE_PREFIX_1	"/usr/lib/"
75 
76 #endif /* NETBSD_NATIVE || NETBSD_TOOLS */
77 
78 #if defined(NETBSD_NATIVE)
79 /* Under NetBSD, the normal location of the compiler back ends is the
80    /usr/libexec directory.  */
81 
82 #undef STANDARD_EXEC_PREFIX
83 #define STANDARD_EXEC_PREFIX		"/usr/libexec/"
84 
85 #undef TOOLDIR_BASE_PREFIX
86 #define TOOLDIR_BASE_PREFIX		"../"
87 
88 #undef STANDARD_BINDIR_PREFIX
89 #define STANDARD_BINDIR_PREFIX		"/usr/bin"
90 
91 #undef STANDARD_LIBEXEC_PREFIX
92 #define STANDARD_LIBEXEC_PREFIX		STANDARD_EXEC_PREFIX
93 
94 #endif /* NETBSD_NATIVE */
95 
96 
97 /* Provide a LIB_SPEC appropriate for NetBSD.  Here we:
98 
99    1. Select the appropriate set of libs, depending on whether we're
100       profiling.
101 
102    2. Include the pthread library if -pthread is specified (only
103       if threads are enabled).
104 
105    3. Include the posix library if -posix is specified.
106 
107    FIXME: Could eliminate the duplication here if we were allowed to
108    use string concatenation.  */
109 
110 #ifdef NETBSD_ENABLE_PTHREADS
111 #define NETBSD_LIB_SPEC		\
112   "%{pthread:			\
113      %{!p:			\
114        %{!pg:-lpthread}}	\
115      %{p:-lpthread_p}		\
116      %{pg:-lpthread_p}}		\
117    %{posix:			\
118      %{!p:			\
119        %{!pg:-lposix}}		\
120      %{p:-lposix_p}		\
121      %{pg:-lposix_p}}		\
122    %{shared:-lc}		\
123    %{!shared:			\
124      %{!symbolic:		\
125        %{!p:			\
126 	 %{!pg:-lc}}		\
127        %{p:-lc_p}		\
128        %{pg:-lc_p}}}"
129 #else
130 #define NETBSD_LIB_SPEC		\
131   "%{posix:			\
132      %{!p:			\
133        %{!pg:-lposix}}		\
134      %{p:-lposix_p}		\
135      %{pg:-lposix_p}}		\
136    %{shared:-lc}		\
137    %{!shared:			\
138      %{!symbolic:		\
139        %{!p:			\
140 	 %{!pg:-lc}}		\
141        %{p:-lc_p}		\
142        %{pg:-lc_p}}}"
143 #endif
144 
145 #undef LIB_SPEC
146 #define LIB_SPEC NETBSD_LIB_SPEC
147 
148 #if 0 // XXXMRG
149 #undef STATIC_LIBASAN_LIBS
150 #define STATIC_LIBASAN_LIBS "-lstdc++ -lpthread"
151 #endif
152 
153 /* Pass -cxx-isystem to cc1/cc1plus.  */
154 #define NETBSD_CC1_AND_CC1PLUS_SPEC		\
155   "%{cxx-isystem}"
156 
157 #undef CC1_SPEC
158 #define CC1_SPEC NETBSD_CC1_AND_CC1PLUS_SPEC
159 
160 #undef CC1PLUS_SPEC
161 #define CC1PLUS_SPEC NETBSD_CC1_AND_CC1PLUS_SPEC
162 
163 #undef TARGET_LIBC_HAS_FUNCTION
164 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
165 
166 /* When building shared libraries, the initialization and finalization
167    functions for the library are .init and .fini respectively.  */
168 
169 #define COLLECT_SHARED_INIT_FUNC(STREAM,FUNC)				\
170   do {									\
171     fprintf ((STREAM), "void __init() __asm__ (\".init\");");		\
172     fprintf ((STREAM), "void __init() {\n\t%s();\n}\n", (FUNC));	\
173   } while (0)
174 
175 #define COLLECT_SHARED_FINI_FUNC(STREAM,FUNC)				\
176   do {									\
177     fprintf ((STREAM), "void __fini() __asm__ (\".fini\");");		\
178     fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC));	\
179   } while (0)
180 
181 #undef TARGET_POSIX_IO
182 #define TARGET_POSIX_IO
183 
184 /* Don't assume anything about the header files.  */
185 #undef  NO_IMPLICIT_EXTERN_C
186 #define NO_IMPLICIT_EXTERN_C    1
187 
188 /* Define some types that are the same on all NetBSD platforms,
189    making them agree with <machine/ansi.h>.  */
190 
191 #undef WCHAR_TYPE
192 #define WCHAR_TYPE "int"
193 
194 #undef WCHAR_TYPE_SIZE
195 #define WCHAR_TYPE_SIZE 32
196 
197 #undef WINT_TYPE
198 #define WINT_TYPE "int"
199 
200 #undef LINK_EH_SPEC
201 #define LINK_EH_SPEC "--eh-frame-hdr "
202 
203 /* Use --as-needed -lgcc_s for eh support.  */
204 #ifdef HAVE_LD_AS_NEEDED
205 #define USE_LD_AS_NEEDED 1
206 #endif
207