Fix build on sparc64-linux-gnu.
[official-gcc.git] / gcc / config / vxworks.h
blob2c4c79643de4cd01adf960b621b65c02eee78e67
1 /* Common VxWorks target definitions for GNU compiler.
2 Copyright (C) 1999-2018 Free Software Foundation, Inc.
3 Contributed by Wind River Systems.
4 Rewritten by CodeSourcery, LLC.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 /* Assert that we are targeting VxWorks. */
23 #undef TARGET_VXWORKS
24 #define TARGET_VXWORKS 1
26 /* In kernel mode, VxWorks provides all the libraries itself, as well as
27 the functionality of startup files, etc. In RTP mode, it behaves more
28 like a traditional Unix, with more external files. Most of our specs
29 must be aware of the difference. */
31 /* We look for the VxWorks header files using the environment
32 variables that are set in VxWorks to indicate the location of the
33 system header files. We use -idirafter so that the GCC's own
34 header-file directories (containing <stddef.h>, etc.) come before
35 the VxWorks system header directories. */
37 /* Since we provide a default -isystem, expand -isystem on the command
38 line early. */
39 #if TARGET_VXWORKS7
41 #undef VXWORKS_ADDITIONAL_CPP_SPEC
42 #define VXWORKS_ADDITIONAL_CPP_SPEC \
43 "%{!nostdinc: \
44 %{isystem*} \
45 %{mrtp: -idirafter %:getenv(VSB_DIR /h) \
46 -idirafter %:getenv(VSB_DIR /share/h) \
47 -idirafter %:getenv(VSB_DIR /usr/h/public) \
48 -idirafter %:getenv(VSB_DIR /usr/h) \
49 ;: -idirafter %:getenv(VSB_DIR /h) \
50 -idirafter %:getenv(VSB_DIR /share/h) \
51 -idirafter %:getenv(VSB_DIR /krnl/h/system) \
52 -idirafter %:getenv(VSB_DIR /krnl/h/public)}}"
54 #else /* TARGET_VXWORKS7 */
56 #undef VXWORKS_ADDITIONAL_CPP_SPEC
57 #define VXWORKS_ADDITIONAL_CPP_SPEC \
58 "%{!nostdinc: \
59 %{isystem*} \
60 %{mrtp: -idirafter %:getenv(WIND_USR /h) \
61 -idirafter %:getenv(WIND_USR /h/wrn/coreip) \
62 ;: -idirafter %:getenv(WIND_BASE /target/h) \
63 -idirafter %:getenv(WIND_BASE /target/h/wrn/coreip) \
64 }}"
66 #endif
68 /* For VxWorks static rtps, the system provides libc_internal.a, a superset of
69 libgcc.a that we need to use e.g. to satisfy references to __init and
70 __fini. We still want our libgcc to prevail for symbols it would provide
71 (e.g. register save entry points), so re-place it here between libraries
72 that might reference it and libc_internal.
74 In addition, some versions of VxWorks rely on explicit extra libraries for
75 system calls and the set of base network libraries of common use varies
76 across architectures. The default settings defined here might be redefined
77 by target specific port configuration files. */
79 #define VXWORKS_SYSCALL_LIBS_RTP
81 #define VXWORKS_NET_LIBS_RTP "-lnet -ldsi"
83 #define VXWORKS_LIBS_RTP \
84 VXWORKS_SYSCALL_LIBS_RTP " " VXWORKS_NET_LIBS_RTP " -lc -lgcc -lc_internal"
86 /* On Vx6 and previous, the libraries to pick up depends on the architecture,
87 so cannot be defined for all archs at once. On Vx7, a VSB is always needed
88 and its structure is fixed and does not depend on the arch. We can thus
89 tell gcc where to look for when linking with RTP libraries. Use
90 STARTFILE_PREFIX_SPEC for this, instead of explicit -L options in LIB_SPEC,
91 so they survive -nodefaultlibs. */
93 /* On Vx7 RTP, we need to drag the __tls__ symbol to trigger initialization of
94 tlsLib, responsible for TLS support by the OS. */
96 #if TARGET_VXWORKS7
97 #undef STARTFILE_PREFIX_SPEC
98 #define STARTFILE_PREFIX_SPEC "%:getenv(VSB_DIR /usr/lib/common)"
99 #define TLS_SYM "-u __tls__"
100 #else
101 #define TLS_SYM ""
102 #endif
104 #undef VXWORKS_LIB_SPEC
105 #define VXWORKS_LIB_SPEC \
106 "%{mrtp:%{shared:-u " USER_LABEL_PREFIX "__init -u " USER_LABEL_PREFIX "__fini} \
107 %{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \
108 " TLS_SYM " \
109 --start-group " VXWORKS_LIBS_RTP " --end-group}}"
111 /* The no-op spec for "-shared" below is present because otherwise GCC
112 will treat it as an unrecognized option. */
113 #undef VXWORKS_LINK_SPEC
114 #define VXWORKS_LINK_SPEC \
115 "%{!mrtp:-r} \
116 %{!shared: \
117 %{mrtp:-q %{h*} \
118 %{R*} %{!T*: %(link_start) } \
119 %(link_target) %(link_os)}} \
120 %{v:-v} \
121 %{shared:-shared} \
122 %{Bstatic:-Bstatic} \
123 %{Bdynamic:-Bdynamic} \
124 %{!Xbind-lazy:-z now} \
125 %{Xbind-now:%{Xbind-lazy: \
126 %e-Xbind-now and -Xbind-lazy are incompatible}} \
127 %{mrtp:%{!shared:%{!non-static:-static} \
128 %{non-static:--force-dynamic --export-dynamic}}}"
130 #undef VXWORKS_LIBGCC_SPEC
131 #define VXWORKS_LIBGCC_SPEC "-lgcc"
133 #undef VXWORKS_STARTFILE_SPEC
134 #define VXWORKS_STARTFILE_SPEC "%{mrtp:%{!shared:-l:crt0.o}}"
135 #define VXWORKS_ENDFILE_SPEC ""
137 /* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE. */
139 #define VXWORKS_HAVE_TLS (TARGET_VXWORKS7 && TARGET_VXWORKS_RTP)
141 #undef VXWORKS_OVERRIDE_OPTIONS
142 #define VXWORKS_OVERRIDE_OPTIONS vxworks_override_options ()
143 extern void vxworks_override_options (void);
145 /* RTPs support prioritized constructors and destructors: the
146 implementation relies on numbered .ctors* sections. If the compiler
147 was built with --enable-initfini-array, we assume the user uses a
148 linker script that sorts and merges the .init_array.* sections
149 appropriately. */
150 #define SUPPORTS_INIT_PRIORITY \
151 (TARGET_VXWORKS_RTP || HAVE_INITFINI_ARRAY_SUPPORT)
153 #if !HAVE_INITFINI_ARRAY_SUPPORT
154 /* VxWorks requires special handling of constructors and destructors.
155 All VxWorks configurations must use these functions. */
156 #undef TARGET_ASM_CONSTRUCTOR
157 #define TARGET_ASM_CONSTRUCTOR vxworks_asm_out_constructor
158 #undef TARGET_ASM_DESTRUCTOR
159 #define TARGET_ASM_DESTRUCTOR vxworks_asm_out_destructor
160 extern void vxworks_asm_out_constructor (rtx symbol, int priority);
161 extern void vxworks_asm_out_destructor (rtx symbol, int priority);
162 #endif
164 /* Override the vxworks-dummy.h definitions. TARGET_VXWORKS_RTP
165 is defined by vxworks.opt. */
166 #undef VXWORKS_GOTT_BASE
167 #define VXWORKS_GOTT_BASE "__GOTT_BASE__"
168 #undef VXWORKS_GOTT_INDEX
169 #define VXWORKS_GOTT_INDEX "__GOTT_INDEX__"
171 #undef PTRDIFF_TYPE
172 #define PTRDIFF_TYPE (TARGET_VXWORKS64 ? "long int" : "int")
174 #undef SIZE_TYPE
175 #define SIZE_TYPE (TARGET_VXWORKS64 ? "long unsigned int" : "unsigned int")
177 #undef TARGET_LIBC_HAS_FUNCTION
178 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
180 /* Both kernels and RTPs have the facilities required by this macro. */
181 #define TARGET_POSIX_IO
183 /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS. */
185 /* The VxWorks personality we rely on, controlling which sections of system
186 headers files we trigger. This might be redefined on targets where the
187 base VxWorks environment doesn't come with a GNU toolchain. */
189 #define VXWORKS_PERSONALITY "gnu"
191 #define VXWORKS_OS_CPP_BUILTINS() \
192 do \
194 builtin_define ("__vxworks"); \
195 builtin_define ("__VXWORKS__"); \
196 builtin_assert ("system=unix"); \
197 if (TARGET_VXWORKS_RTP) \
198 builtin_define ("__RTP__"); \
199 else \
200 builtin_define ("_WRS_KERNEL"); \
201 builtin_define ("TOOL_FAMILY=" VXWORKS_PERSONALITY); \
202 builtin_define ("TOOL=" VXWORKS_PERSONALITY); \
203 if (TARGET_VXWORKS7) \
205 builtin_define ("_VSB_CONFIG_FILE=<config/vsbConfig.h>"); \
207 /* _ALLOW_KEYWORD_MACROS is needed on VxWorks 7 to \
208 prevent compilation failures triggered by our \
209 definition of "inline" in ansidecl when "inline" \
210 is not a keyword. */ \
211 if (!flag_isoc99 && !c_dialect_cxx()) \
212 builtin_define ("_ALLOW_KEYWORD_MACROS"); \
215 while (0)
217 #define VXWORKS_KIND VXWORKS_KIND_NORMAL
219 /* The diab linker does not handle .gnu_attribute sections. */
220 #undef HAVE_AS_GNU_ATTRIBUTE
222 /* We provide our own version of __clear_cache in libgcc, using a separate C
223 file to facilitate #inclusion of VxWorks header files. */
224 #undef CLEAR_INSN_CACHE
225 #define CLEAR_INSN_CACHE 1
227 /* Default dwarf control values, for non-gdb debuggers that come with
228 VxWorks. */
230 #undef VXWORKS_DWARF_VERSION_DEFAULT
231 #define VXWORKS_DWARF_VERSION_DEFAULT (TARGET_VXWORKS7 ? 4 : 2)
233 #undef DWARF_GNAT_ENCODINGS_DEFAULT
234 #define DWARF_GNAT_ENCODINGS_DEFAULT \
235 (TARGET_VXWORKS7 ? DWARF_GNAT_ENCODINGS_MINIMAL : DWARF_GNAT_ENCODINGS_ALL)