• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import("//compiler-rt/target.gni")
2import("//llvm/utils/gn/build/buildflags.gni")
3
4declare_args() {
5  # Skip the atomic builtin (should normally be provided by a shared library).
6  compiler_rt_exclude_atomic_builtin = true
7
8  # Compile builtins for baremetal.
9  compiler_rt_baremetal_build = false
10}
11
12static_library("builtins") {
13  output_dir = crt_current_out_dir
14  if (current_os == "mac") {
15    output_name = "clang_rt.osx"
16  } else if (current_os == "ios" && current_cpu == "arm64") {
17    output_name = "clang_rt.ios"
18  } else if (current_os == "ios" && current_cpu == "x64") {
19    output_name = "clang_rt.iossim"
20  } else {
21    output_name = "clang_rt.builtins$crt_current_target_suffix"
22  }
23
24  complete_static_lib = true
25  configs -= [ "//llvm/utils/gn/build:thin_archive" ]
26
27  cflags = [
28    "-fPIC",
29    "-fno-builtin",
30  ]
31  if (current_os != "android") {
32    cflags += [ "-fvisibility=hidden" ]
33  }
34  if (!is_debug) {
35    cflags += [ "-fomit-frame-pointer" ]
36  }
37  cflags_c = [ "-std=c11" ]
38
39  sources = [
40    "absvdi2.c",
41    "absvsi2.c",
42    "absvti2.c",
43    "adddf3.c",
44    "addsf3.c",
45    "addtf3.c",
46    "addvdi3.c",
47    "addvsi3.c",
48    "addvti3.c",
49    "apple_versioning.c",
50    "ashldi3.c",
51    "ashlti3.c",
52    "ashrdi3.c",
53    "ashrti3.c",
54    "bswapdi2.c",
55    "bswapsi2.c",
56    "clzdi2.c",
57    "clzsi2.c",
58    "clzti2.c",
59    "cmpdi2.c",
60    "cmpti2.c",
61    "comparedf2.c",
62    "comparesf2.c",
63    "ctzdi2.c",
64    "ctzsi2.c",
65    "ctzti2.c",
66    "divdc3.c",
67    "divdf3.c",
68    "divdi3.c",
69    "divmoddi4.c",
70    "divmodsi4.c",
71    "divmodti4.c",
72    "divsc3.c",
73    "divsf3.c",
74    "divsi3.c",
75    "divtc3.c",
76    "divtf3.c",
77    "divti3.c",
78    "extendhfsf2.c",
79    "extendsfdf2.c",
80    "ffsdi2.c",
81    "ffssi2.c",
82    "ffsti2.c",
83    "fixdfdi.c",
84    "fixdfsi.c",
85    "fixdfti.c",
86    "fixsfdi.c",
87    "fixsfsi.c",
88    "fixsfti.c",
89    "fixunsdfdi.c",
90    "fixunsdfsi.c",
91    "fixunsdfti.c",
92    "fixunssfdi.c",
93    "fixunssfsi.c",
94    "fixunssfti.c",
95    "floatdidf.c",
96    "floatdisf.c",
97    "floatsidf.c",
98    "floatsisf.c",
99    "floattidf.c",
100    "floattisf.c",
101    "floatundidf.c",
102    "floatundisf.c",
103    "floatunsidf.c",
104    "floatunsisf.c",
105    "floatuntidf.c",
106    "floatuntisf.c",
107    "fp_mode.c",
108    "int_util.c",
109    "lshrdi3.c",
110    "lshrti3.c",
111    "moddi3.c",
112    "modsi3.c",
113    "modti3.c",
114    "muldc3.c",
115    "muldf3.c",
116    "muldi3.c",
117    "mulodi4.c",
118    "mulosi4.c",
119    "muloti4.c",
120    "mulsc3.c",
121    "mulsf3.c",
122    "multf3.c",
123    "multi3.c",
124    "mulvdi3.c",
125    "mulvsi3.c",
126    "mulvti3.c",
127    "negdf2.c",
128    "negdi2.c",
129    "negsf2.c",
130    "negti2.c",
131    "negvdi2.c",
132    "negvsi2.c",
133    "negvti2.c",
134    "os_version_check.c",
135    "paritydi2.c",
136    "paritysi2.c",
137    "parityti2.c",
138    "popcountdi2.c",
139    "popcountsi2.c",
140    "popcountti2.c",
141    "powidf2.c",
142    "powisf2.c",
143    "powitf2.c",
144    "subdf3.c",
145    "subsf3.c",
146    "subtf3.c",
147    "subvdi3.c",
148    "subvsi3.c",
149    "subvti3.c",
150    "trampoline_setup.c",
151    "truncdfhf2.c",
152    "truncdfsf2.c",
153    "truncsfhf2.c",
154    "ucmpdi2.c",
155    "ucmpti2.c",
156    "udivdi3.c",
157    "udivmoddi4.c",
158    "udivmodsi4.c",
159    "udivmodti4.c",
160    "udivsi3.c",
161    "udivti3.c",
162    "umoddi3.c",
163    "umodsi3.c",
164    "umodti3.c",
165
166    # This depends on unwind.h which is present in Clang headers. We should
167    # reconsider this if we ever decide to support building builtins with
168    # other compilers.
169    "gcc_personality_v0.c",
170  ]
171
172  if (current_os != "fuchsia") {
173    sources += [
174      "emutls.c",
175      "enable_execute_stack.c",
176      "eprintf.c",
177    ]
178  }
179
180  if (current_os != "fuchsia" && !compiler_rt_baremetal_build) {
181    sources += [ "clear_cache.c" ]
182  }
183
184  if (current_os == "mac" || current_os == "ios") {
185    sources += [
186      "atomic_flag_clear.c",
187      "atomic_flag_clear_explicit.c",
188      "atomic_flag_test_and_set.c",
189      "atomic_flag_test_and_set_explicit.c",
190      "atomic_signal_fence.c",
191      "atomic_thread_fence.c",
192    ]
193  }
194
195  if ((current_cpu == "x64" && current_os != "win") || current_cpu == "arm64") {
196    # GENERIC_TF_SOURCES
197    sources += [
198      "comparetf2.c",
199      "extenddftf2.c",
200      "extendhftf2.c",
201      "extendsftf2.c",
202      "fixtfdi.c",
203      "fixtfsi.c",
204      "fixtfti.c",
205      "fixunstfdi.c",
206      "fixunstfsi.c",
207      "fixunstfti.c",
208      "floatditf.c",
209      "floatsitf.c",
210      "floattitf.c",
211      "floatunditf.c",
212      "floatunsitf.c",
213      "floatuntitf.c",
214      "multc3.c",
215      "trunctfdf2.c",
216      "trunctfhf2.c",
217      "trunctfsf2.c",
218    ]
219  }
220
221  if (current_cpu == "x86" || current_cpu == "x64") {
222    sources -= [ "fp_mode.c" ]
223    sources += [
224      "cpu_model.c",
225      "divxc3.c",
226      "fixunsxfdi.c",
227      "fixunsxfsi.c",
228      "fixunsxfti.c",
229      "fixxfdi.c",
230      "fixxfti.c",
231      "floatdixf.c",
232      "floattixf.c",
233      "floatundixf.c",
234      "floatuntixf.c",
235      "i386/fp_mode.c",
236      "mulxc3.c",
237      "powixf2.c",
238    ]
239  }
240  if (current_cpu == "x86") {
241    sources -= [
242      "ashldi3.c",
243      "ashrdi3.c",
244      "divdi3.c",
245      "floatdidf.c",
246      "floatdisf.c",
247      "floatdixf.c",
248      "floatundidf.c",
249      "floatundisf.c",
250      "floatundixf.c",
251      "lshrdi3.c",
252      "moddi3.c",
253      "muldi3.c",
254      "udivdi3.c",
255      "umoddi3.c",
256    ]
257    sources += [
258      "i386/ashldi3.S",
259      "i386/ashrdi3.S",
260      "i386/divdi3.S",
261      "i386/floatdidf.S",
262      "i386/floatdisf.S",
263      "i386/floatdixf.S",
264      "i386/floatundidf.S",
265      "i386/floatundisf.S",
266      "i386/floatundixf.S",
267      "i386/lshrdi3.S",
268      "i386/moddi3.S",
269      "i386/muldi3.S",
270      "i386/udivdi3.S",
271      "i386/umoddi3.S",
272    ]
273    if (current_os == "win") {
274      sources += [
275        "i386/chkstk.S",
276        "i386/chkstk2.S",
277      ]
278    }
279  } else if (current_cpu == "x64") {
280    sources -= [
281      "floatdidf.c",
282      "floatdisf.c",
283      "floatdixf.c",
284      "floatundidf.c",
285      "floatundisf.c",
286      "floatundixf.c",
287    ]
288    sources += [
289      "x86_64/floatdidf.c",
290      "x86_64/floatdisf.c",
291      "x86_64/floatdixf.c",
292      "x86_64/floatundidf.S",
293      "x86_64/floatundisf.S",
294      "x86_64/floatundixf.S",
295    ]
296    if (current_os == "win") {
297      sources += [
298        "x86_64/chkstk.S",
299        "x86_64/chkstk2.S",
300      ]
301    }
302  }
303
304  if (current_cpu == "arm") {
305    if (current_os != "mingw") {
306      sources -= [
307        "bswapdi2.c",
308        "bswapsi2.c",
309        "clzdi2.c",
310        "clzsi2.c",
311        "comparesf2.c",
312        "divmodsi4.c",
313        "divsi3.c",
314        "fp_mode.c",
315        "modsi3.c",
316        "udivmodsi4.c",
317        "udivsi3.c",
318        "umodsi3.c",
319      ]
320      sources += [
321        "arm/aeabi_cdcmp.S",
322        "arm/aeabi_cdcmpeq_check_nan.c",
323        "arm/aeabi_cfcmp.S",
324        "arm/aeabi_cfcmpeq_check_nan.c",
325        "arm/aeabi_dcmp.S",
326        "arm/aeabi_div0.c",
327        "arm/aeabi_drsub.c",
328        "arm/aeabi_fcmp.S",
329        "arm/aeabi_frsub.c",
330        "arm/aeabi_idivmod.S",
331        "arm/aeabi_ldivmod.S",
332        "arm/aeabi_memcmp.S",
333        "arm/aeabi_memcpy.S",
334        "arm/aeabi_memmove.S",
335        "arm/aeabi_memset.S",
336        "arm/aeabi_uidivmod.S",
337        "arm/aeabi_uldivmod.S",
338        "arm/bswapdi2.S",
339        "arm/bswapsi2.S",
340        "arm/clzdi2.S",
341        "arm/clzsi2.S",
342        "arm/comparesf2.S",
343        "arm/divmodsi4.S",
344        "arm/divsi3.S",
345        "arm/fp_mode.c",
346        "arm/modsi3.S",
347        "arm/switch16.S",
348        "arm/switch32.S",
349        "arm/switch8.S",
350        "arm/switchu8.S",
351        "arm/sync_fetch_and_add_4.S",
352        "arm/sync_fetch_and_add_8.S",
353        "arm/sync_fetch_and_and_4.S",
354        "arm/sync_fetch_and_and_8.S",
355        "arm/sync_fetch_and_max_4.S",
356        "arm/sync_fetch_and_max_8.S",
357        "arm/sync_fetch_and_min_4.S",
358        "arm/sync_fetch_and_min_8.S",
359        "arm/sync_fetch_and_nand_4.S",
360        "arm/sync_fetch_and_nand_8.S",
361        "arm/sync_fetch_and_or_4.S",
362        "arm/sync_fetch_and_or_8.S",
363        "arm/sync_fetch_and_sub_4.S",
364        "arm/sync_fetch_and_sub_8.S",
365        "arm/sync_fetch_and_umax_4.S",
366        "arm/sync_fetch_and_umax_8.S",
367        "arm/sync_fetch_and_umin_4.S",
368        "arm/sync_fetch_and_umin_8.S",
369        "arm/sync_fetch_and_xor_4.S",
370        "arm/sync_fetch_and_xor_8.S",
371        "arm/sync_synchronize.S",
372        "arm/udivmodsi4.S",
373        "arm/udivsi3.S",
374        "arm/umodsi3.S",
375      ]
376
377      if (current_os == "android") {
378        sources += [
379          "arm/adddf3vfp.S",
380          "arm/addsf3vfp.S",
381          "arm/divdf3vfp.S",
382          "arm/divsf3vfp.S",
383          "arm/eqdf2vfp.S",
384          "arm/eqsf2vfp.S",
385          "arm/extendsfdf2vfp.S",
386          "arm/fixdfsivfp.S",
387          "arm/fixsfsivfp.S",
388          "arm/fixunsdfsivfp.S",
389          "arm/fixunssfsivfp.S",
390          "arm/floatsidfvfp.S",
391          "arm/floatsisfvfp.S",
392          "arm/floatunssidfvfp.S",
393          "arm/floatunssisfvfp.S",
394          "arm/gedf2vfp.S",
395          "arm/gesf2vfp.S",
396          "arm/gtdf2vfp.S",
397          "arm/gtsf2vfp.S",
398          "arm/ledf2vfp.S",
399          "arm/lesf2vfp.S",
400          "arm/ltdf2vfp.S",
401          "arm/ltsf2vfp.S",
402          "arm/muldf3vfp.S",
403          "arm/mulsf3vfp.S",
404          "arm/nedf2vfp.S",
405          "arm/negdf2vfp.S",
406          "arm/negsf2vfp.S",
407          "arm/nesf2vfp.S",
408          "arm/restore_vfp_d8_d15_regs.S",
409          "arm/save_vfp_d8_d15_regs.S",
410          "arm/subdf3vfp.S",
411          "arm/subsf3vfp.S",
412          "arm/truncdfsf2vfp.S",
413          "arm/unorddf2vfp.S",
414          "arm/unordsf2vfp.S",
415        ]
416      }
417    } else {
418      sources += [
419        "arm/aeabi_idivmod.S",
420        "arm/aeabi_ldivmod.S",
421        "arm/aeabi_uidivmod.S",
422        "arm/aeabi_uldivmod.S",
423        "arm/chkstk.S",
424        "mingw_fixfloat.c",
425      ]
426    }
427  }
428
429  if (current_cpu == "arm64") {
430    sources += [ "aarch64/fp_mode.c" ]
431    if (current_os == "mingw") {
432      sources += [ "aarch64/chkstk.S" ]
433    }
434  }
435
436  if (current_cpu == "hexagon") {
437    sources += [
438      "hexagon/common_entry_exit_abi1.S",
439      "hexagon/common_entry_exit_abi2.S",
440      "hexagon/common_entry_exit_legacy.S",
441      "hexagon/dfaddsub.S",
442      "hexagon/dfdiv.S",
443      "hexagon/dffma.S",
444      "hexagon/dfminmax.S",
445      "hexagon/dfmul.S",
446      "hexagon/dfsqrt.S",
447      "hexagon/divdi3.S",
448      "hexagon/divsi3.S",
449      "hexagon/fastmath2_dlib_asm.S",
450      "hexagon/fastmath2_ldlib_asm.S",
451      "hexagon/fastmath_dlib_asm.S",
452      "hexagon/memcpy_forward_vp4cp4n2.S",
453      "hexagon/memcpy_likely_aligned.S",
454      "hexagon/moddi3.S",
455      "hexagon/modsi3.S",
456      "hexagon/sfdiv_opt.S",
457      "hexagon/sfsqrt_opt.S",
458      "hexagon/udivdi3.S",
459      "hexagon/udivmoddi4.S",
460      "hexagon/udivmodsi4.S",
461      "hexagon/udivsi3.S",
462      "hexagon/umoddi3.S",
463      "hexagon/umodsi3.S",
464    ]
465  }
466
467  if (current_cpu == "ppc64") {
468    sources += [
469      "ppc/divtc3.c",
470      "ppc/fixtfdi.c",
471      "ppc/fixtfti.c",
472      "ppc/fixunstfdi.c",
473      "ppc/fixunstfti.c",
474      "ppc/floatditf.c",
475      "ppc/floattitf.c",
476      "ppc/floatunditf.c",
477      "ppc/gcc_qadd.c",
478      "ppc/gcc_qdiv.c",
479      "ppc/gcc_qmul.c",
480      "ppc/gcc_qsub.c",
481      "ppc/multc3.c",
482    ]
483  }
484
485  if (current_cpu == "riscv") {
486    sources += [ "riscv/mulsi3.S" ]
487  }
488
489  if (current_cpu == "riscv64") {
490    sources += [ "riscv/muldi3.S" ]
491  }
492
493  if (current_cpu == "ve") {
494    sources += [
495      "ve/grow_stack.S",
496      "ve/grow_stack_align.S",
497    ]
498  }
499
500  if (!compiler_rt_exclude_atomic_builtin) {
501    sources += [ "atomic.c" ]
502  }
503}
504
505# Currently unused but necessary to make sync_source_lists_from_cmake.py happy.
506source_set("_unused") {
507  sources = [
508    # Thumb1
509    "arm/addsf3.S",
510    "arm/comparesf2.S",
511    "arm/divsi3.S",
512    "arm/udivsi3.S",
513  ]
514}
515