1//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16//
17
18//=====================================================================
19// Static Library: libcompiler_rt-extras
20//=====================================================================
21
22cc_library_static {
23    name: "libcompiler_rt-extras",
24    host_supported: true,
25    clang: true,
26    // The following list contains functions that are not available in libgcc.a, so
27    // we potentially need them when using a Clang-built component (e.g., -ftrapv
28    // with 64-bit integer multiplies. See http://llvm.org/bugs/show_bug.cgi?id=14469.)
29    srcs: ["lib/builtins/mulodi4.c"],
30    sanitize: ["never"],
31    stl: "none",
32
33    cflags: [
34        "-Wno-unused-parameter",
35        "-Werror",
36    ],
37
38    arch: {
39        mips: {
40            srcs: ["lib/builtins/clear_cache.c"],
41        },
42        mips64: {
43            srcs: ["lib/builtins/clear_cache.c"],
44        },
45    },
46
47    target: {
48        windows: {
49            enabled: true,
50        },
51    },
52}
53
54// Don't build compiler-rt without clang
55// ANDROIDMK TRANSLATION ERROR: unsupported directive
56// ifneq ($(WITHOUT_TARGET_CLANG), true)
57//=====================================================================
58// Device and Host Static Library: libcompiler_rt
59//=====================================================================
60
61cc_library {
62    name: "libcompiler_rt",
63    host_supported: true,
64    // The following list contains platform-independent functionalities.
65    //
66    // Skip apple_versioning.c since it is unused.
67    // Skip atomic.c since it needs to be built separately according to the docs.
68    srcs: [
69        "lib/builtins/absvdi2.c",
70        "lib/builtins/absvsi2.c",
71        "lib/builtins/absvti2.c",
72        "lib/builtins/adddf3.c",
73        "lib/builtins/addsf3.c",
74        "lib/builtins/addtf3.c",
75        "lib/builtins/addvdi3.c",
76        "lib/builtins/addvsi3.c",
77        "lib/builtins/addvti3.c",
78        "lib/builtins/ashldi3.c",
79        "lib/builtins/ashlti3.c",
80        "lib/builtins/ashrdi3.c",
81        "lib/builtins/ashrti3.c",
82        "lib/builtins/clear_cache.c",
83        "lib/builtins/clzdi2.c",
84        "lib/builtins/clzsi2.c",
85        "lib/builtins/clzti2.c",
86        "lib/builtins/cmpdi2.c",
87        "lib/builtins/cmpti2.c",
88        "lib/builtins/comparedf2.c",
89        "lib/builtins/comparesf2.c",
90        "lib/builtins/comparetf2.c",
91        "lib/builtins/ctzdi2.c",
92        "lib/builtins/ctzsi2.c",
93        "lib/builtins/ctzti2.c",
94        "lib/builtins/divdc3.c",
95        "lib/builtins/divdf3.c",
96        "lib/builtins/divdi3.c",
97        "lib/builtins/divmoddi4.c",
98        "lib/builtins/divmodsi4.c",
99        "lib/builtins/divsc3.c",
100        "lib/builtins/divsf3.c",
101        "lib/builtins/divsi3.c",
102        "lib/builtins/divtf3.c",
103        "lib/builtins/divti3.c",
104        "lib/builtins/divxc3.c",
105        "lib/builtins/eprintf.c",
106        "lib/builtins/extenddftf2.c",
107        "lib/builtins/extendhfsf2.c",
108        "lib/builtins/extendsfdf2.c",
109        "lib/builtins/extendsftf2.c",
110        "lib/builtins/ffsdi2.c",
111        "lib/builtins/ffsti2.c",
112        "lib/builtins/fixdfdi.c",
113        "lib/builtins/fixdfsi.c",
114        "lib/builtins/fixdfti.c",
115        "lib/builtins/fixsfdi.c",
116        "lib/builtins/fixsfsi.c",
117        "lib/builtins/fixsfti.c",
118        "lib/builtins/fixtfdi.c",
119        "lib/builtins/fixtfsi.c",
120        "lib/builtins/fixtfti.c",
121        "lib/builtins/fixunsdfdi.c",
122        "lib/builtins/fixunsdfsi.c",
123        "lib/builtins/fixunsdfti.c",
124        "lib/builtins/fixunssfdi.c",
125        "lib/builtins/fixunssfsi.c",
126        "lib/builtins/fixunssfti.c",
127        "lib/builtins/fixunstfdi.c",
128        "lib/builtins/fixunstfsi.c",
129        "lib/builtins/fixunstfti.c",
130        "lib/builtins/fixunsxfdi.c",
131        "lib/builtins/fixunsxfsi.c",
132        "lib/builtins/fixunsxfti.c",
133        "lib/builtins/fixxfdi.c",
134        "lib/builtins/fixxfti.c",
135        "lib/builtins/floatdidf.c",
136        "lib/builtins/floatdisf.c",
137        "lib/builtins/floatdixf.c",
138        "lib/builtins/floatsidf.c",
139        "lib/builtins/floatsisf.c",
140        "lib/builtins/floatsitf.c",
141        "lib/builtins/floattidf.c",
142        "lib/builtins/floattisf.c",
143        "lib/builtins/floattixf.c",
144        "lib/builtins/floatundidf.c",
145        "lib/builtins/floatundisf.c",
146        "lib/builtins/floatundixf.c",
147        "lib/builtins/floatunsidf.c",
148        "lib/builtins/floatunsisf.c",
149        "lib/builtins/floatunsitf.c",
150        "lib/builtins/floatuntidf.c",
151        "lib/builtins/floatuntisf.c",
152        "lib/builtins/floatuntixf.c",
153        "lib/builtins/gcc_personality_v0.c",
154        "lib/builtins/int_util.c",
155        "lib/builtins/lshrdi3.c",
156        "lib/builtins/lshrti3.c",
157        "lib/builtins/moddi3.c",
158        "lib/builtins/modsi3.c",
159        "lib/builtins/modti3.c",
160        "lib/builtins/muldc3.c",
161        "lib/builtins/muldf3.c",
162        "lib/builtins/muldi3.c",
163        "lib/builtins/mulodi4.c",
164        "lib/builtins/mulosi4.c",
165        "lib/builtins/muloti4.c",
166        "lib/builtins/mulsc3.c",
167        "lib/builtins/mulsf3.c",
168        "lib/builtins/multf3.c",
169        "lib/builtins/multi3.c",
170        "lib/builtins/mulvdi3.c",
171        "lib/builtins/mulvsi3.c",
172        "lib/builtins/mulvti3.c",
173        "lib/builtins/mulxc3.c",
174        "lib/builtins/negdf2.c",
175        "lib/builtins/negdi2.c",
176        "lib/builtins/negsf2.c",
177        "lib/builtins/negti2.c",
178        "lib/builtins/negvdi2.c",
179        "lib/builtins/negvsi2.c",
180        "lib/builtins/negvti2.c",
181        "lib/builtins/paritydi2.c",
182        "lib/builtins/paritysi2.c",
183        "lib/builtins/parityti2.c",
184        "lib/builtins/popcountdi2.c",
185        "lib/builtins/popcountsi2.c",
186        "lib/builtins/popcountti2.c",
187        "lib/builtins/powidf2.c",
188        "lib/builtins/powisf2.c",
189        "lib/builtins/powitf2.c",
190        "lib/builtins/powixf2.c",
191        "lib/builtins/subdf3.c",
192        "lib/builtins/subsf3.c",
193        "lib/builtins/subtf3.c",
194        "lib/builtins/subvdi3.c",
195        "lib/builtins/subvsi3.c",
196        "lib/builtins/subvti3.c",
197        "lib/builtins/trampoline_setup.c",
198        "lib/builtins/truncdfhf2.c",
199        "lib/builtins/truncdfsf2.c",
200        "lib/builtins/truncsfhf2.c",
201        "lib/builtins/trunctfdf2.c",
202        "lib/builtins/trunctfsf2.c",
203        "lib/builtins/ucmpdi2.c",
204        "lib/builtins/ucmpti2.c",
205        "lib/builtins/udivdi3.c",
206        "lib/builtins/udivmoddi4.c",
207        "lib/builtins/udivmodsi4.c",
208        "lib/builtins/udivmodti4.c",
209        "lib/builtins/udivsi3.c",
210        "lib/builtins/udivti3.c",
211        "lib/builtins/umoddi3.c",
212        "lib/builtins/umodsi3.c",
213        "lib/builtins/umodti3.c",
214    ],
215
216    cflags: [
217        "-Wno-unused-parameter",
218        "-Werror",
219    ],
220
221    arch: {
222        arm: {
223            cflags: ["-D__ARM_EABI__"],
224            srcs: [
225                "lib/builtins/arm/aeabi_dcmp.S",
226                "lib/builtins/arm/aeabi_div0.c",
227                "lib/builtins/arm/aeabi_fcmp.S",
228                "lib/builtins/arm/aeabi_idivmod.S",
229                "lib/builtins/arm/aeabi_ldivmod.S",
230                "lib/builtins/arm/aeabi_memcmp.S",
231                "lib/builtins/arm/aeabi_memcpy.S",
232                "lib/builtins/arm/aeabi_memmove.S",
233                "lib/builtins/arm/aeabi_memset.S",
234                "lib/builtins/arm/aeabi_uidivmod.S",
235                "lib/builtins/arm/aeabi_uldivmod.S",
236                "lib/builtins/arm/comparesf2.S",
237                "lib/builtins/arm/divmodsi4.S",
238                "lib/builtins/arm/divsi3.S",
239                "lib/builtins/arm/modsi3.S",
240                "lib/builtins/arm/udivmodsi4.S",
241                "lib/builtins/arm/udivsi3.S",
242                "lib/builtins/arm/umodsi3.S",
243                "lib/builtins/arm/adddf3vfp.S",
244                "lib/builtins/arm/addsf3vfp.S",
245                "lib/builtins/arm/divdf3vfp.S",
246                "lib/builtins/arm/divsf3vfp.S",
247                "lib/builtins/arm/eqdf2vfp.S",
248                "lib/builtins/arm/eqsf2vfp.S",
249                "lib/builtins/arm/extendsfdf2vfp.S",
250                "lib/builtins/arm/fixdfsivfp.S",
251                "lib/builtins/arm/fixsfsivfp.S",
252                "lib/builtins/arm/fixunsdfsivfp.S",
253                "lib/builtins/arm/fixunssfsivfp.S",
254                "lib/builtins/arm/floatsidfvfp.S",
255                "lib/builtins/arm/floatsisfvfp.S",
256                "lib/builtins/arm/floatunssidfvfp.S",
257                "lib/builtins/arm/floatunssisfvfp.S",
258                "lib/builtins/arm/gedf2vfp.S",
259                "lib/builtins/arm/gesf2vfp.S",
260                "lib/builtins/arm/gtdf2vfp.S",
261                "lib/builtins/arm/gtsf2vfp.S",
262                "lib/builtins/arm/ledf2vfp.S",
263                "lib/builtins/arm/lesf2vfp.S",
264                "lib/builtins/arm/ltdf2vfp.S",
265                "lib/builtins/arm/ltsf2vfp.S",
266                "lib/builtins/arm/muldf3vfp.S",
267                "lib/builtins/arm/mulsf3vfp.S",
268                "lib/builtins/arm/nedf2vfp.S",
269                "lib/builtins/arm/negdf2vfp.S",
270                "lib/builtins/arm/negsf2vfp.S",
271                "lib/builtins/arm/nesf2vfp.S",
272                "lib/builtins/arm/subdf3vfp.S",
273                "lib/builtins/arm/subsf3vfp.S",
274                "lib/builtins/arm/truncdfsf2vfp.S",
275                "lib/builtins/arm/unorddf2vfp.S",
276                "lib/builtins/arm/unordsf2vfp.S",
277            ],
278            exclude_srcs: [
279                "lib/builtins/comparesf2.c",
280                "lib/builtins/divmodsi4.c",
281                "lib/builtins/divsi3.c",
282                "lib/builtins/modsi3.c",
283                "lib/builtins/udivmodsi4.c",
284                "lib/builtins/udivsi3.c",
285                "lib/builtins/umodsi3.c",
286            ],
287        },
288        mips64: {
289            cflags: [
290                "-DCRT_HAS_128BIT",
291            ],
292        },
293        x86: {
294            srcs: [
295                "lib/builtins/i386/ashldi3.S",
296                "lib/builtins/i386/ashrdi3.S",
297                "lib/builtins/i386/divdi3.S",
298                "lib/builtins/i386/floatdidf.S",
299                "lib/builtins/i386/floatdisf.S",
300                "lib/builtins/i386/floatdixf.S",
301                "lib/builtins/i386/floatundidf.S",
302                "lib/builtins/i386/floatundisf.S",
303                "lib/builtins/i386/floatundixf.S",
304                "lib/builtins/i386/lshrdi3.S",
305                "lib/builtins/i386/moddi3.S",
306                "lib/builtins/i386/muldi3.S",
307                "lib/builtins/i386/udivdi3.S",
308                "lib/builtins/i386/umoddi3.S",
309            ],
310            exclude_srcs: [
311                "lib/builtins/ashldi3.c",
312                "lib/builtins/ashrdi3.c",
313                "lib/builtins/divdi3.c",
314                "lib/builtins/floatdidf.c",
315                "lib/builtins/floatdisf.c",
316                "lib/builtins/floatdixf.c",
317                "lib/builtins/floatundidf.c",
318                "lib/builtins/floatundisf.c",
319                "lib/builtins/floatundixf.c",
320                "lib/builtins/lshrdi3.c",
321                "lib/builtins/moddi3.c",
322                "lib/builtins/muldi3.c",
323                "lib/builtins/udivdi3.c",
324                "lib/builtins/umoddi3.c",
325            ],
326        },
327        x86_64: {
328            srcs: [
329                "lib/builtins/x86_64/floatundixf.S",
330                "lib/builtins/x86_64/floatdisf.c",
331                "lib/builtins/x86_64/floatdidf.c",
332                "lib/builtins/x86_64/floatdixf.c",
333                "lib/builtins/x86_64/floatundisf.S",
334                "lib/builtins/x86_64/floatundidf.S",
335            ],
336            exclude_srcs: [
337                "lib/builtins/floatundixf.c",
338                "lib/builtins/floatdisf.c",
339                "lib/builtins/floatdidf.c",
340                "lib/builtins/floatdixf.c",
341                "lib/builtins/floatundisf.c",
342                "lib/builtins/floatundidf.c",
343            ],
344        },
345    },
346
347    target: {
348        not_windows: {
349            // Only build enable_execute_stack.c on non-Windows hosts.
350            srcs: ["lib/builtins/enable_execute_stack.c"],
351            host_ldlibs: [
352                "-lpthread",
353                "-lc",
354                "-lm",
355            ],
356        },
357        android: {
358            srcs: ["lib/builtins/enable_execute_stack.c"],
359            shared_libs: ["libdl", "liblog"],
360            static_libs: ["liblzma"],
361        },
362        android_arm: {
363            static_libs: ["libunwind_llvm"],
364            ldflags: ["-Wl,--exclude-libs,libunwind_llvm.a"],
365        },
366        android_arm64: {
367            // b/26968262 liblzma needs to be after libunwindbacktrace
368            static_libs: ["libunwindbacktrace","liblzma"],
369            ldflags: ["-Wl,--exclude-libs,libunwindbacktrace.a"],
370        },
371        android_mips: {
372            // b/26968262 liblzma needs to be after libunwindbacktrace
373            static_libs: ["libunwindbacktrace","liblzma"],
374            ldflags: ["-Wl,--exclude-libs,libunwindbacktrace.a"],
375        },
376        android_mips64: {
377            // b/26968262 liblzma needs to be after libunwindbacktrace
378            static_libs: ["libunwindbacktrace","liblzma"],
379            ldflags: ["-Wl,--exclude-libs,libunwindbacktrace.a"],
380        },
381        android_x86: {
382            // b/26968262 liblzma needs to be after libunwindbacktrace
383            static_libs: ["libunwindbacktrace","liblzma"],
384            ldflags: ["-Wl,--exclude-libs,libunwindbacktrace.a"],
385        },
386        android_x86_64: {
387            srcs: ["lib/builtins/ppc/floatditf.c"],
388            // b/26968262 liblzma needs to be after libunwindbacktrace
389            static_libs: ["libunwindbacktrace","liblzma"],
390            ldflags: ["-Wl,--exclude-libs,libunwindbacktrace.a"],
391        },
392        linux: {
393            static_libs: ["libunwindbacktrace"],
394        },
395        windows: {
396            static_libs: ["libunwindbacktrace"],
397        },
398    },
399
400    asflags: ["-integrated-as"],
401    clang: true,
402    no_libgcc: true,
403
404    sanitize: ["never"],
405    stl: "none",
406}
407
408// Build asan, lsan, etc.
409// ANDROIDMK TRANSLATION ERROR: unsupported include
410// include $(call all-makefiles-under,$(LOCAL_PATH)/lib)
411// ANDROIDMK TRANSLATION ERROR: unsupported directive
412// endif
413