]>
Commit | Line | Data |
---|---|---|
8e38461c JM |
1 | /* Definitions for systems using the Linux kernel, with or without |
2 | MMU, using ELF at the compiler level but possibly FLT for final | |
3 | linked executables and shared libraries in some no-MMU cases, and | |
4 | possibly with a choice of libc implementations. | |
aeee4812 | 5 | Copyright (C) 1995-2023 Free Software Foundation, Inc. |
9e2fc7c0 | 6 | Contributed by Eric Youngdale. |
e5e809f4 | 7 | Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org). |
9e2fc7c0 | 8 | |
2a71dcad | 9 | This file is part of GCC. |
9e2fc7c0 | 10 | |
2a71dcad | 11 | GCC is free software; you can redistribute it and/or modify |
9e2fc7c0 | 12 | it under the terms of the GNU General Public License as published by |
2f83c7d6 | 13 | the Free Software Foundation; either version 3, or (at your option) |
9e2fc7c0 RK |
14 | any later version. |
15 | ||
2a71dcad | 16 | GCC is distributed in the hope that it will be useful, |
9e2fc7c0 RK |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | GNU General Public License for more details. | |
20 | ||
748086b7 JJ |
21 | Under Section 7 of GPL version 3, you are granted additional |
22 | permissions described in the GCC Runtime Library Exception, version | |
23 | 3.1, as published by the Free Software Foundation. | |
24 | ||
25 | You should have received a copy of the GNU General Public License and | |
26 | a copy of the GCC Runtime Library Exception along with this program; | |
27 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
2f83c7d6 | 28 | <http://www.gnu.org/licenses/>. */ |
9e2fc7c0 | 29 | |
74c70253 | 30 | /* C libraries supported on Linux. */ |
b5a54c03 | 31 | #ifdef SINGLE_LIBC |
2c31a8be JJ |
32 | #define OPTION_GLIBC_P(opts) (DEFAULT_LIBC == LIBC_GLIBC) |
33 | #define OPTION_UCLIBC_P(opts) (DEFAULT_LIBC == LIBC_UCLIBC) | |
34 | #define OPTION_BIONIC_P(opts) (DEFAULT_LIBC == LIBC_BIONIC) | |
35 | #undef OPTION_MUSL_P | |
36 | #define OPTION_MUSL_P(opts) (DEFAULT_LIBC == LIBC_MUSL) | |
b5a54c03 | 37 | #else |
2c31a8be JJ |
38 | #define OPTION_GLIBC_P(opts) ((opts)->x_linux_libc == LIBC_GLIBC) |
39 | #define OPTION_UCLIBC_P(opts) ((opts)->x_linux_libc == LIBC_UCLIBC) | |
40 | #define OPTION_BIONIC_P(opts) ((opts)->x_linux_libc == LIBC_BIONIC) | |
41 | #undef OPTION_MUSL_P | |
42 | #define OPTION_MUSL_P(opts) ((opts)->x_linux_libc == LIBC_MUSL) | |
b5a54c03 | 43 | #endif |
2c31a8be JJ |
44 | #define OPTION_GLIBC OPTION_GLIBC_P (&global_options) |
45 | #define OPTION_UCLIBC OPTION_UCLIBC_P (&global_options) | |
46 | #define OPTION_BIONIC OPTION_BIONIC_P (&global_options) | |
47 | #undef OPTION_MUSL | |
48 | #define OPTION_MUSL OPTION_MUSL_P (&global_options) | |
74c70253 | 49 | |
107fd1c1 | 50 | #define GNU_USER_TARGET_OS_CPP_BUILTINS() \ |
26b0ad13 | 51 | do { \ |
74c70253 MK |
52 | if (OPTION_GLIBC) \ |
53 | builtin_define ("__gnu_linux__"); \ | |
26b0ad13 KG |
54 | builtin_define_std ("linux"); \ |
55 | builtin_define_std ("unix"); \ | |
56 | builtin_assert ("system=linux"); \ | |
57 | builtin_assert ("system=unix"); \ | |
58 | builtin_assert ("system=posix"); \ | |
59 | } while (0) | |
60 | ||
464aea98 | 61 | /* Determine which dynamic linker to use depending on whether GLIBC or |
755658a5 GR |
62 | uClibc or Bionic or musl is the default C library and whether |
63 | -muclibc or -mglibc or -mbionic or -mmusl has been passed to change | |
64 | the default. */ | |
74c70253 | 65 | |
755658a5 GR |
66 | #define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \ |
67 | "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}" | |
74c70253 MK |
68 | |
69 | #if DEFAULT_LIBC == LIBC_GLIBC | |
755658a5 GR |
70 | #define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ |
71 | CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M) | |
74c70253 | 72 | #elif DEFAULT_LIBC == LIBC_UCLIBC |
755658a5 GR |
73 | #define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ |
74 | CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M) | |
74c70253 | 75 | #elif DEFAULT_LIBC == LIBC_BIONIC |
755658a5 GR |
76 | #define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ |
77 | CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M) | |
78 | #elif DEFAULT_LIBC == LIBC_MUSL | |
79 | #define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ | |
80 | CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B) | |
464aea98 | 81 | #else |
74c70253 MK |
82 | #error "Unsupported DEFAULT_LIBC" |
83 | #endif /* DEFAULT_LIBC */ | |
464aea98 | 84 | |
7bd85ce0 JM |
85 | /* For most targets the following definitions suffice; |
86 | GLIBC_DYNAMIC_LINKER must be defined for each target using them, or | |
87 | GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets | |
88 | supporting both 32-bit and 64-bit compilation. */ | |
464aea98 | 89 | #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" |
7bd85ce0 JM |
90 | #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" |
91 | #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" | |
f0ea7581 | 92 | #define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0" |
74c70253 MK |
93 | #define BIONIC_DYNAMIC_LINKER "/system/bin/linker" |
94 | #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" | |
95 | #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" | |
f0ea7581 | 96 | #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32" |
755658a5 GR |
97 | /* Should be redefined for each target that supports musl. */ |
98 | #define MUSL_DYNAMIC_LINKER "/dev/null" | |
99 | #define MUSL_DYNAMIC_LINKER32 "/dev/null" | |
100 | #define MUSL_DYNAMIC_LINKER64 "/dev/null" | |
101 | #define MUSL_DYNAMIC_LINKERX32 "/dev/null" | |
74c70253 | 102 | |
107fd1c1 | 103 | #define GNU_USER_DYNAMIC_LINKER \ |
74c70253 | 104 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ |
755658a5 | 105 | BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) |
107fd1c1 | 106 | #define GNU_USER_DYNAMIC_LINKER32 \ |
74c70253 | 107 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \ |
755658a5 | 108 | BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) |
107fd1c1 | 109 | #define GNU_USER_DYNAMIC_LINKER64 \ |
74c70253 | 110 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \ |
755658a5 | 111 | BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) |
f0ea7581 L |
112 | #define GNU_USER_DYNAMIC_LINKERX32 \ |
113 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \ | |
755658a5 | 114 | BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32) |
464aea98 | 115 | |
4bd5abca SM |
116 | /* Whether we have Bionic libc runtime */ |
117 | #undef TARGET_HAS_BIONIC | |
118 | #define TARGET_HAS_BIONIC (OPTION_BIONIC) | |
d33d9e47 | 119 | |
755658a5 | 120 | /* musl avoids problematic includes by rearranging the include directories. |
e53b6e56 | 121 | * Unfortunately, this is mostly duplicated from cppdefault.cc */ |
755658a5 GR |
122 | #if DEFAULT_LIBC == LIBC_MUSL |
123 | #define INCLUDE_DEFAULTS_MUSL_GPP \ | |
124 | { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \ | |
125 | GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \ | |
126 | { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \ | |
127 | GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \ | |
128 | { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \ | |
129 | GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, | |
130 | ||
131 | #ifdef LOCAL_INCLUDE_DIR | |
132 | #define INCLUDE_DEFAULTS_MUSL_LOCAL \ | |
133 | { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \ | |
134 | { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, | |
135 | #else | |
136 | #define INCLUDE_DEFAULTS_MUSL_LOCAL | |
137 | #endif | |
138 | ||
139 | #ifdef PREFIX_INCLUDE_DIR | |
140 | #define INCLUDE_DEFAULTS_MUSL_PREFIX \ | |
141 | { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0}, | |
142 | #else | |
143 | #define INCLUDE_DEFAULTS_MUSL_PREFIX | |
144 | #endif | |
145 | ||
146 | #ifdef CROSS_INCLUDE_DIR | |
147 | #define INCLUDE_DEFAULTS_MUSL_CROSS \ | |
148 | { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0}, | |
149 | #else | |
150 | #define INCLUDE_DEFAULTS_MUSL_CROSS | |
151 | #endif | |
152 | ||
153 | #ifdef TOOL_INCLUDE_DIR | |
154 | #define INCLUDE_DEFAULTS_MUSL_TOOL \ | |
155 | { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0}, | |
156 | #else | |
157 | #define INCLUDE_DEFAULTS_MUSL_TOOL | |
158 | #endif | |
159 | ||
160 | #ifdef NATIVE_SYSTEM_HEADER_DIR | |
161 | #define INCLUDE_DEFAULTS_MUSL_NATIVE \ | |
162 | { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ | |
163 | { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, | |
164 | #else | |
165 | #define INCLUDE_DEFAULTS_MUSL_NATIVE | |
166 | #endif | |
167 | ||
168 | #if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) | |
169 | # undef INCLUDE_DEFAULTS_MUSL_LOCAL | |
170 | # define INCLUDE_DEFAULTS_MUSL_LOCAL | |
171 | # undef INCLUDE_DEFAULTS_MUSL_NATIVE | |
172 | # define INCLUDE_DEFAULTS_MUSL_NATIVE | |
173 | #else | |
174 | # undef INCLUDE_DEFAULTS_MUSL_CROSS | |
175 | # define INCLUDE_DEFAULTS_MUSL_CROSS | |
176 | #endif | |
177 | ||
178 | #undef INCLUDE_DEFAULTS | |
179 | #define INCLUDE_DEFAULTS \ | |
180 | { \ | |
181 | INCLUDE_DEFAULTS_MUSL_GPP \ | |
59010ede | 182 | INCLUDE_DEFAULTS_MUSL_LOCAL \ |
755658a5 GR |
183 | INCLUDE_DEFAULTS_MUSL_PREFIX \ |
184 | INCLUDE_DEFAULTS_MUSL_CROSS \ | |
185 | INCLUDE_DEFAULTS_MUSL_TOOL \ | |
186 | INCLUDE_DEFAULTS_MUSL_NATIVE \ | |
187 | { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ | |
188 | { 0, 0, 0, 0, 0, 0 } \ | |
189 | } | |
190 | #endif | |
191 | ||
3e9310f4 MK |
192 | #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ |
193 | /* This is a *uclinux* target. We don't define below macros to normal linux | |
194 | versions, because doing so would require *uclinux* targets to include | |
e53b6e56 | 195 | linux.cc, linux-protos.h, linux.opt, etc. We could, alternatively, add |
3e9310f4 MK |
196 | these files to *uclinux* targets, but that would only pollute option list |
197 | (add -mglibc, etc.) without adding any useful support. */ | |
198 | ||
199 | /* Define TARGET_LIBC_HAS_FUNCTION for *uclinux* targets to | |
200 | no_c99_libc_has_function, because uclibc does not, normally, have | |
201 | c99 runtime. If, in special cases, uclibc does have c99 runtime, | |
202 | this should be defined to a new hook. Also please note that for targets | |
203 | like *-linux-uclibc that similar check will also need to be added to | |
204 | linux_libc_has_function. */ | |
205 | # undef TARGET_LIBC_HAS_FUNCTION | |
206 | # define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function | |
207 | ||
208 | #else /* !uClinux, i.e., normal Linux */ | |
209 | ||
d33d9e47 AI |
210 | /* Determine what functions are present at the runtime; |
211 | this includes full c99 runtime and sincos. */ | |
3e9310f4 MK |
212 | # undef TARGET_LIBC_HAS_FUNCTION |
213 | # define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function | |
214 | ||
215 | #endif |