]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/aix.h
aix.h (LIBSTDCXX_STATIC): Remove -lstdc++.
[thirdparty/gcc.git] / gcc / config / rs6000 / aix.h
1 /* Definitions of target machine for GNU compiler,
2 for IBM RS/6000 POWER running AIX.
3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 3, or (at your
11 option) any later version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
17
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/>. */
21
22 /* Yes! We are AIX! */
23 #define DEFAULT_ABI ABI_AIX
24 #undef TARGET_AIX
25 #define TARGET_AIX 1
26
27 /* AIX always has a TOC. */
28 #define TARGET_NO_TOC 0
29 #define TARGET_TOC 1
30 #define FIXED_R2 1
31
32 /* AIX allows r13 to be used in 32-bit mode. */
33 #define FIXED_R13 0
34
35 /* 32-bit and 64-bit AIX stack boundary is 128. */
36 #undef STACK_BOUNDARY
37 #define STACK_BOUNDARY 128
38
39 #undef TARGET_IEEEQUAD
40 #define TARGET_IEEEQUAD 0
41
42 /* The AIX linker will discard static constructors in object files before
43 collect has a chance to see them, so scan the object files directly. */
44 #define COLLECT_EXPORT_LIST
45
46 /* Handle #pragma weak and #pragma pack. */
47 #define HANDLE_SYSV_PRAGMA 1
48
49 /* This is the only version of nm that collect2 can work with. */
50 #define REAL_NM_FILE_NAME "/usr/ucb/nm"
51
52 #define USER_LABEL_PREFIX ""
53
54 /* Don't turn -B into -L if the argument specifies a relative file name. */
55 #define RELATIVE_PREFIX_NOT_LINKDIR
56
57 /* Because of the above, we must have gcc search itself to find libgcc.a. */
58 #define LINK_LIBGCC_SPECIAL_1
59
60 #define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \
61 -brename:malloc,__wrap_malloc -brename:__real_malloc,malloc \
62 -brename:free,__wrap_free -brename:__real_free,free \
63 -brename:calloc,__wrap_calloc -brename:__real_calloc,calloc \
64 -brename:realloc,__wrap_realloc -brename:__real_realloc,realloc \
65 -brename:mmap,__wrap_mmap -brename:__real_mmap,mmap \
66 -brename:munmap,__wrap_munmap -brename:__real_munmap,munmap \
67 -brename:alloca,__wrap_alloca -brename:__real_alloca,alloca \
68 } %{fmudflapth: \
69 -brename:pthread_create,__wrap_pthread_create \
70 -brename:__real_pthread_create,pthread_create \
71 -brename:pthread_join,__wrap_pthread_join \
72 -brename:__real_pthread_join,pthread_join \
73 -brename:pthread_exit,__wrap_pthread_exit \
74 -brename:__real_pthread_exit,pthread_exit \
75 }} %{fmudflap|fmudflapth: \
76 -brename:main,__wrap_main -brename:__real_main,main \
77 }"
78
79 #define MFLIB_SPEC " %{fmudflap: -lmudflap \
80 %{static:%(link_gcc_c_sequence) -lmudflap}} \
81 %{fmudflapth: -lmudflapth -lpthread \
82 %{static:%(link_gcc_c_sequence) -lmudflapth}} "
83
84 /* Names to predefine in the preprocessor for this target machine. */
85 #define TARGET_OS_AIX_CPP_BUILTINS() \
86 do \
87 { \
88 builtin_define ("_IBMR2"); \
89 builtin_define ("_POWER"); \
90 builtin_define ("_AIX"); \
91 builtin_define ("_AIX32"); \
92 builtin_define ("_AIX41"); \
93 builtin_define ("_LONG_LONG"); \
94 if (TARGET_LONG_DOUBLE_128) \
95 builtin_define ("__LONGDOUBLE128"); \
96 builtin_assert ("system=unix"); \
97 builtin_assert ("system=aix"); \
98 } \
99 while (0)
100
101 /* Define appropriate architecture macros for preprocessor depending on
102 target switches. */
103
104 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\
105 %{ansi: -D_ANSI_C_SOURCE}"
106
107 #define CC1_SPEC "%(cc1_cpu)"
108
109 #undef ASM_DEFAULT_SPEC
110 #define ASM_DEFAULT_SPEC ""
111
112 /* Tell the assembler to assume that all undefined names are external.
113
114 Don't do this until the fixed IBM assembler is more generally available.
115 When this becomes permanently defined, the ASM_OUTPUT_EXTERNAL,
116 ASM_OUTPUT_EXTERNAL_LIBCALL, and RS6000_OUTPUT_BASENAME macros will no
117 longer be needed. Also, the extern declaration of mcount in
118 rs6000_xcoff_file_start will no longer be needed. */
119
120 /* #define ASM_SPEC "-u %(asm_cpu)" */
121
122 /* Default location of syscalls.exp under AIX */
123 #define LINK_SYSCALLS_SPEC "-bI:%R/lib/syscalls.exp"
124
125 /* Default location of libg.exp under AIX */
126 #define LINK_LIBG_SPEC "-bexport:%R/usr/lib/libg.exp"
127
128 /* Define the options for the binder: Start text at 512, align all segments
129 to 512 bytes, and warn if there is text relocation.
130
131 The -bhalt:4 option supposedly changes the level at which ld will abort,
132 but it also suppresses warnings about multiply defined symbols and is
133 used by the AIX cc command. So we use it here.
134
135 -bnodelcsect undoes a poor choice of default relating to multiply-defined
136 csects. See AIX documentation for more information about this.
137
138 -bM:SRE tells the linker that the output file is Shared REusable. Note
139 that to actually build a shared library you will also need to specify an
140 export list with the -Wl,-bE option. */
141
142 #define LINK_SPEC "-T512 -H512 %{!r:-btextro} -bhalt:4 -bnodelcsect\
143 %{static:-bnso %(link_syscalls) } \
144 %{!shared:%{g*: %(link_libg) }} %{shared:-bM:SRE}"
145
146 /* Profiled library versions are used by linking with special directories. */
147 #define LIB_SPEC "%{pg:-L%R/lib/profiled -L%R/usr/lib/profiled}\
148 %{p:-L%R/lib/profiled -L%R/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc"
149
150 /* Static linking with shared libstdc++ requires libsupc++ as well. */
151 #define LIBSTDCXX_STATIC "-lsupc++"
152
153 /* This now supports a natural alignment mode. */
154 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */
155 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
156 ((TARGET_ALIGN_NATURAL == 0 \
157 && TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode) \
158 ? MIN ((COMPUTED), 32) \
159 : (COMPUTED))
160
161 /* AIX increases natural record alignment to doubleword if the first
162 field is an FP double while the FP fields remain word aligned. */
163 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
164 ((TREE_CODE (STRUCT) == RECORD_TYPE \
165 || TREE_CODE (STRUCT) == UNION_TYPE \
166 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
167 && TARGET_ALIGN_NATURAL == 0 \
168 ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
169 : MAX ((COMPUTED), (SPECIFIED)))
170
171 /* The AIX ABI isn't explicit on whether aggregates smaller than a
172 word/doubleword should be padded upward or downward. One could
173 reasonably assume that they follow the normal rules for structure
174 layout treating the parameter area as any other block of memory,
175 then map the reg param area to registers, i.e., pad upward, which
176 is the way IBM Compilers for AIX behave.
177 Setting both of the following defines results in this behavior. */
178 #define AGGREGATE_PADDING_FIXED 1
179 #define AGGREGATES_PAD_UPWARD_ALWAYS 1
180
181 /* Specify padding for the last element of a block move between
182 registers and memory. FIRST is nonzero if this is the only
183 element. */
184 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
185 (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
186
187 /* Indicate that jump tables go in the text section. */
188
189 #define JUMP_TABLES_IN_TEXT_SECTION 1
190
191 /* Define any extra SPECS that the compiler needs to generate. */
192 #undef SUBTARGET_EXTRA_SPECS
193 #define SUBTARGET_EXTRA_SPECS \
194 { "link_syscalls", LINK_SYSCALLS_SPEC }, \
195 { "link_libg", LINK_LIBG_SPEC }
196
197 /* Define cutoff for using external functions to save floating point. */
198 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63)
199 /* And similarly for general purpose registers. */
200 #define GP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 32)
201
202 /* __throw will restore its own return address to be the same as the
203 return address of the function that the throw is being made to.
204 This is unfortunate, because we want to check the original
205 return address to see if we need to restore the TOC.
206 So we have to squirrel it away with this. */
207 #define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init ()
208
209 /* If the current unwind info (FS) does not contain explicit info
210 saving R2, then we have to do a minor amount of code reading to
211 figure out if it was saved. The big problem here is that the
212 code that does the save/restore is generated by the linker, so
213 we have no good way to determine at compile time what to do. */
214
215 #define R_LR 65
216
217 #ifdef __64BIT__
218 #define MD_FROB_UPDATE_CONTEXT(CTX, FS) \
219 do { \
220 if ((FS)->regs.reg[2].how == REG_UNSAVED) \
221 { \
222 unsigned int *insn \
223 = (unsigned int *) \
224 _Unwind_GetGR ((CTX), R_LR); \
225 if (*insn == 0xE8410028) \
226 _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40); \
227 } \
228 } while (0)
229 #else
230 #define MD_FROB_UPDATE_CONTEXT(CTX, FS) \
231 do { \
232 if ((FS)->regs.reg[2].how == REG_UNSAVED) \
233 { \
234 unsigned int *insn \
235 = (unsigned int *) \
236 _Unwind_GetGR ((CTX), R_LR); \
237 if (*insn == 0x80410014) \
238 _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 20); \
239 } \
240 } while (0)
241 #endif
242
243 #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL)
244
245 /* Print subsidiary information on the compiler version in use. */
246 #define TARGET_VERSION ;
247
248 /* No version of AIX fully supports AltiVec or 64-bit instructions in
249 32-bit mode. */
250 #define OS_MISSING_POWERPC64 1
251 #define OS_MISSING_ALTIVEC 1
252
253 /* WINT_TYPE */
254 #define WINT_TYPE "int"