]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/sparc/linux64.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / sparc / linux64.h
CommitLineData
956d6950 1/* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
7adcbafe 2 Copyright (C) 1996-2022 Free Software Foundation, Inc.
bfe87013
DE
3 Contributed by David S. Miller (davem@caip.rutgers.edu)
4
de0a398e 5This file is part of GCC.
bfe87013 6
de0a398e 7GCC is free software; you can redistribute it and/or modify
bfe87013 8it under the terms of the GNU General Public License as published by
2f83c7d6 9the Free Software Foundation; either version 3, or (at your option)
bfe87013
DE
10any later version.
11
de0a398e 12GCC is distributed in the hope that it will be useful,
bfe87013
DE
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
2f83c7d6
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
bfe87013 20
5f7ca34b
DM
21#define TARGET_OS_CPP_BUILTINS() \
22 do \
23 { \
107fd1c1 24 GNU_USER_TARGET_OS_CPP_BUILTINS(); \
5f7ca34b
DM
25 if (TARGET_ARCH64) \
26 builtin_define ("_LONGLONG"); \
27 if (TARGET_ARCH32 \
28 && TARGET_LONG_DOUBLE_128) \
29 builtin_define ("__LONG_DOUBLE_128__"); \
30 } \
9b8466f4
NB
31 while (0)
32
034e3eb0
EB
33/* On Linux, the combination sparc64-* --with-cpu=v8 is supported and
34 selects a 32-bit compiler. */
35#if defined(TARGET_64BIT_DEFAULT) && TARGET_CPU_DEFAULT >= TARGET_CPU_v9
345a6161
DM
36#undef TARGET_DEFAULT
37#define TARGET_DEFAULT \
4f4f4f54
DM
38 (MASK_V9 + MASK_PTR64 + MASK_64BIT + MASK_STACK_BIAS + \
39 MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
345a6161
DM
40#endif
41
5f7ca34b
DM
42/* This must be v9a not just v9 because by default we enable
43 -mvis. */
44#undef ASM_CPU64_DEFAULT_SPEC
45#define ASM_CPU64_DEFAULT_SPEC "-Av9a"
bfe87013 46
5f7ca34b 47#undef ENDFILE_SPEC
5bbcd587 48#define ENDFILE_SPEC \
87891d5e
ST
49 GNU_USER_TARGET_ENDFILE_SPEC \
50 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
345a6161 51
a0a301fc
DE
52/* The default code model. */
53#undef SPARC_DEFAULT_CMODEL
be3f1ff5 54#define SPARC_DEFAULT_CMODEL CM_MEDLOW
bfe87013 55
bfe87013 56#undef WCHAR_TYPE
247cfc5c
JJ
57#define WCHAR_TYPE "int"
58
bfe87013 59#undef WCHAR_TYPE_SIZE
247cfc5c
JJ
60#define WCHAR_TYPE_SIZE 32
61
ba31d94e 62/* Define for support of TFmode long double.
56149abc 63 SPARC ABI says that long double is 4 words. */
a0a301fc 64#undef LONG_DOUBLE_TYPE_SIZE
4710d3eb
JJ
65#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
66
a0a301fc
DE
67#undef CPP_SUBTARGET_SPEC
68#define CPP_SUBTARGET_SPEC "\
bfe87013 69%{posix:-D_POSIX_SOURCE} \
afc96791 70%{pthread:-D_REENTRANT} \
bfe87013 71"
afc96791 72
956d6950 73/* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
bfe87013
DE
74 for the special GCC options -static and -shared, which allow us to
75 link things in one of these three modes by applying the appropriate
83c2a9ef 76 combinations of options at link-time.
bfe87013
DE
77
78 When the -shared link option is used a final link is not being
79 done. */
80
7bd85ce0
JM
81#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
82#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
7bd85ce0 83
345a6161
DM
84#ifdef SPARC_BI_ARCH
85
86#undef SUBTARGET_EXTRA_SPECS
87#define SUBTARGET_EXTRA_SPECS \
88 { "link_arch32", LINK_ARCH32_SPEC }, \
89 { "link_arch64", LINK_ARCH64_SPEC }, \
90 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
91 { "link_arch", LINK_ARCH_SPEC },
7bd85ce0 92
36e0c0a5 93#define LINK_ARCH32_SPEC "-m elf32_sparc %{shared:-shared} \
345a6161 94 %{!shared: \
dabadc52
JM
95 %{!static: \
96 %{rdynamic:-export-dynamic} \
107fd1c1 97 -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
dabadc52 98 %{static:-static}} \
345a6161
DM
99"
100
36e0c0a5 101#define LINK_ARCH64_SPEC "-m elf64_sparc %{shared:-shared} \
345a6161 102 %{!shared: \
dabadc52
JM
103 %{!static: \
104 %{rdynamic:-export-dynamic} \
107fd1c1 105 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
dabadc52 106 %{static:-static}} \
345a6161
DM
107"
108
109#define LINK_ARCH_SPEC "\
110%{m32:%(link_arch32)} \
111%{m64:%(link_arch64)} \
112%{!m32:%{!m64:%(link_arch_default)}} \
113"
114
115#define LINK_ARCH_DEFAULT_SPEC \
116(DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
117
bfe87013 118#undef LINK_SPEC
345a6161
DM
119#define LINK_SPEC "\
120%(link_arch) \
e95b1e6a 121%{!mno-relax:%{!r:-relax}} \
345a6161
DM
122"
123
0913b2d6
DM
124/* -mcpu=native handling only makes sense with compiler running on
125 a SPARC chip. */
a0bd60d1 126#if defined(__sparc__) && defined(__linux__)
0913b2d6
DM
127extern const char *host_detect_local_cpu (int argc, const char **argv);
128# define EXTRA_SPEC_FUNCTIONS \
129 { "local_cpu_detect", host_detect_local_cpu },
130
131# define MCPU_MTUNE_NATIVE_SPECS \
132 " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \
133 " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
134#else
135# define MCPU_MTUNE_NATIVE_SPECS ""
136#endif
137
138#define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
139
381a3c75
EB
140/* -fsanitize=address is currently only supported for 32-bit. */
141#define ASAN_REJECT_SPEC \
142 "%{!%:sanitize(thread):%e-fsanitize=address is not supported in this configuration}"
143
34c5627c 144#undef ASAN_CC1_SPEC
381a3c75
EB
145#if DEFAULT_ARCH32_P
146#define ASAN_CC1_SPEC \
147 "%{%:sanitize(address):-funwind-tables %{m64:" ASAN_REJECT_SPEC "}}"
148#else
149#define ASAN_CC1_SPEC \
150 "%{%:sanitize(address):-funwind-tables %{!m32:" ASAN_REJECT_SPEC "}}"
151#endif
34c5627c
EB
152
153#undef CC1_SPEC
345a6161 154#if DEFAULT_ARCH32_P
34c5627c
EB
155#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC \
156"%{m32:%{m64:%emay not use both -m32 and -m64}} \
4710d3eb 157%{m64:-mptr64 -mstack-bias -mlong-double-128 \
3a7b4385 158 %{!mcpu*:-mcpu=ultrasparc} \
34c5627c 159 %{!mno-vis:%{!mcpu=v9:-mvis}}}"
345a6161 160#else
34c5627c
EB
161#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC \
162"%{m32:%{m64:%emay not use both -m32 and -m64}} \
4710d3eb 163%{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
3a7b4385 164 %{!mcpu*:-mcpu=cypress}} \
d377a5fb
DM
165%{mv8plus:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
166 %{!mcpu*:-mcpu=v9}} \
9ce13279 167%{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
34c5627c 168%{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}}"
345a6161
DM
169#endif
170
942e0f44 171/* Support for a compile-time default CPU, et cetera. The rules are:
31177ef2
JM
172 --with-cpu is ignored if -mcpu is specified; likewise --with-cpu-32
173 and --with-cpu-64.
174 --with-tune is ignored if -mtune is specified; likewise --with-tune-32
175 and --with-tune-64.
942e0f44
JJ
176 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
177 are specified.
178 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
179 here, otherwise say -mcpu=v7 would be passed even when -m64.
31177ef2
JM
180 CC1_SPEC above takes care of this instead.
181
182 Note that the order of the cpu* and tune* options matters: the
183 config.gcc file always sets with_cpu to some value, even if the
184 user didn't use --with-cpu when invoking the configure script.
185 This value is based on the target name. Therefore we have to make
186 sure that --with-cpu-32 takes precedence to --with-cpu in < v9
187 systems, and that --with-cpu-64 takes precedence to --with-cpu in
188 >= v9 systems. As for the tune* options, in some platforms
189 config.gcc also sets a default value for it if the user didn't use
190 --with-tune when invoking the configure script. */
942e0f44
JJ
191#undef OPTION_DEFAULT_SPECS
192#if DEFAULT_ARCH32_P
193#define OPTION_DEFAULT_SPECS \
31177ef2
JM
194 {"cpu_32", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
195 {"cpu_64", "%{m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
942e0f44 196 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
31177ef2
JM
197 {"tune_32", "%{!m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
198 {"tune_64", "%{m64:%{!mtune=*:-mtune=%(VALUE)}}" }, \
942e0f44 199 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
c6869789 200 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
942e0f44
JJ
201#else
202#define OPTION_DEFAULT_SPECS \
31177ef2
JM
203 {"cpu_32", "%{m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
204 {"cpu_64", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
942e0f44 205 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
31177ef2
JM
206 {"tune_32", "%{m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
207 {"tune_64", "%{!m32:%{!mtune=*:-mtune=%(VALUE)}}" }, \
942e0f44 208 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
c6869789 209 {"float", "%{!msoft-float:%{!mhard-float:%{!mfpu:%{!mno-fpu:-m%(VALUE)-float}}}}" }
942e0f44
JJ
210#endif
211
345a6161
DM
212#if DEFAULT_ARCH32_P
213#define MULTILIB_DEFAULTS { "m32" }
214#else
215#define MULTILIB_DEFAULTS { "m64" }
216#endif
217
218#else /* !SPARC_BI_ARCH */
219
220#undef LINK_SPEC
c71cfaaf 221#define LINK_SPEC "-m elf64_sparc -Y P,%R/usr/lib64 %{shared:-shared} \
bfe87013 222 %{!shared: \
dabadc52
JM
223 %{!static: \
224 %{rdynamic:-export-dynamic} \
107fd1c1 225 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
dabadc52 226 %{static:-static}} \
e95b1e6a 227%{!mno-relax:%{!r:-relax}} \
bfe87013
DE
228"
229
345a6161
DM
230#endif /* !SPARC_BI_ARCH */
231
12eb1a9c 232/* It's safe to pass -s always, even if -g is not used. */
bfe87013
DE
233#undef ASM_SPEC
234#define ASM_SPEC "\
1141be7e 235-s \
428b3812 236%{" FPIE_OR_FPIC_SPEC ":-K PIC} \
40ea67af 237%{!.c:%{findirect-dispatch:-K PIC}} \
e95b1e6a 238%(asm_cpu) %(asm_arch) %(asm_relax)"
bfe87013 239
bfe87013
DE
240#undef ASM_OUTPUT_ALIGNED_LOCAL
241#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
242do { \
243 fputs ("\t.local\t", (FILE)); \
244 assemble_name ((FILE), (NAME)); \
245 putc ('\n', (FILE)); \
246 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
247} while (0)
248
249#undef COMMON_ASM_OP
471b6f1b 250#define COMMON_ASM_OP "\t.common\t"
bfe87013 251
59f96879
RH
252#undef LOCAL_LABEL_PREFIX
253#define LOCAL_LABEL_PREFIX "."
254
bfe87013
DE
255/* DWARF bits. */
256
257/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
d6a7951f 258 Obviously the Dwarf2 folks haven't tried to actually build systems
bfe87013
DE
259 with their spec. On a 64-bit system, only 64-bit relocs become
260 RELATIVE relocations. */
261
262/* #define DWARF_OFFSET_SIZE PTR_SIZE */
275b60d6 263
45dcc026
JJ
264#undef DITF_CONVERSION_LIBFUNCS
265#define DITF_CONVERSION_LIBFUNCS 1
f7e0e539 266\f
5751a10b
JJ
267#ifdef HAVE_AS_TLS
268#undef TARGET_SUN_TLS
269#undef TARGET_GNU_TLS
270#define TARGET_SUN_TLS 0
271#define TARGET_GNU_TLS 1
272#endif
273\f
7a31a340
DM
274/* We use GNU ld so undefine this so that attribute((init_priority)) works. */
275#undef CTORS_SECTION_ASM_OP
276#undef DTORS_SECTION_ASM_OP
db430d26 277
260c8ba3
EB
278/* Static stack checking is supported by means of probes. */
279#define STACK_CHECK_STATIC_BUILTIN 1
280
5e77eb53
EB
281#undef NEED_INDICATE_EXEC_STACK
282#define NEED_INDICATE_EXEC_STACK 1
8ec11fe9
JJ
283
284#ifdef TARGET_LIBC_PROVIDES_SSP
285/* sparc glibc provides __stack_chk_guard in [%g7 + 0x14],
286 sparc64 glibc provides it at [%g7 + 0x28]. */
287#define TARGET_THREAD_SSP_OFFSET (TARGET_ARCH64 ? 0x28 : 0x14)
288#endif
7269aee7
AH
289
290/* Define if long doubles should be mangled as 'g'. */
291#define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING
cc44abe6
DM
292
293/* We use glibc _mcount for profiling. */
b61eacd6 294#undef NO_PROFILE_COUNTERS
cc44abe6 295#define NO_PROFILE_COUNTERS 1