xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/netbsd.h (revision f3cfa6f6ce31685c6c4a758bc430e69eb99f50a4)
1 /* Base configuration file for all NetBSD targets.
2    Copyright (C) 1997-2016 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-6"
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:			\
123      %{!p:			\
124        %{!pg:-lc}}		\
125      %{p:-lc_p}			\
126        %{pg:-lc_p}}		\
127    %{!shared:			\
128      %{!symbolic:		\
129        %{!p:			\
130 	 %{!pg:-lc}}		\
131        %{p:-lc_p}		\
132        %{pg:-lc_p}}}"
133 #else
134 #define NETBSD_LIB_SPEC		\
135   "%{posix:			\
136      %{!p:			\
137        %{!pg:-lposix}}		\
138      %{p:-lposix_p}		\
139      %{pg:-lposix_p}}		\
140    %{shared:			\
141      %{!p:			\
142        %{!pg:-lc}}		\
143      %{p:-lc_p}			\
144        %{pg:-lc_p}}		\
145    %{!shared:			\
146      %{!symbolic:		\
147        %{!p:			\
148 	 %{!pg:-lc}}		\
149        %{p:-lc_p}		\
150        %{pg:-lc_p}}}"
151 #endif
152 
153 #undef LIB_SPEC
154 #define LIB_SPEC NETBSD_LIB_SPEC
155 
156 #define LIBSTDCXX_PROFILE "stdc++_p"
157 #define MATH_LIBRARY_PROFILE "m_p"
158 
159 #if 0 // XXXMRG
160 #undef STATIC_LIBASAN_LIBS
161 #define STATIC_LIBASAN_LIBS "-lstdc++ -lpthread"
162 #endif
163 
164 /* Pass -cxx-isystem to cc1/cc1plus.  */
165 #define NETBSD_CC1_AND_CC1PLUS_SPEC		\
166   "%{cxx-isystem}"
167 
168 #undef CC1_SPEC
169 #define CC1_SPEC NETBSD_CC1_AND_CC1PLUS_SPEC
170 
171 #undef CC1PLUS_SPEC
172 #define CC1PLUS_SPEC NETBSD_CC1_AND_CC1PLUS_SPEC
173 
174 #undef TARGET_LIBC_HAS_FUNCTION
175 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
176 
177 /* When building shared libraries, the initialization and finalization
178    functions for the library are .init and .fini respectively.  */
179 
180 #define COLLECT_SHARED_INIT_FUNC(STREAM,FUNC)				\
181   do {									\
182     fprintf ((STREAM), "void __init() __asm__ (\".init\");");		\
183     fprintf ((STREAM), "void __init() {\n\t%s();\n}\n", (FUNC));	\
184   } while (0)
185 
186 #define COLLECT_SHARED_FINI_FUNC(STREAM,FUNC)				\
187   do {									\
188     fprintf ((STREAM), "void __fini() __asm__ (\".fini\");");		\
189     fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC));	\
190   } while (0)
191 
192 #undef TARGET_POSIX_IO
193 #define TARGET_POSIX_IO
194 
195 /* Don't assume anything about the header files.  */
196 #undef  NO_IMPLICIT_EXTERN_C
197 #define NO_IMPLICIT_EXTERN_C    1
198 
199 /* Define some types that are the same on all NetBSD platforms,
200    making them agree with <machine/ansi.h>.  */
201 
202 #undef WCHAR_TYPE
203 #define WCHAR_TYPE "int"
204 
205 #undef WCHAR_TYPE_SIZE
206 #define WCHAR_TYPE_SIZE 32
207 
208 #undef WINT_TYPE
209 #define WINT_TYPE "int"
210 
211 #undef LINK_EH_SPEC
212 #define LINK_EH_SPEC "--eh-frame-hdr "
213 
214 /* Use --as-needed -lgcc_s for eh support.  */
215 #ifdef HAVE_LD_AS_NEEDED
216 #define USE_LD_AS_NEEDED 1
217 #endif
218