• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# This directory contains a large amount of C code which provides
2# generic implementations of the core runtime library along with optimized
3# architecture-specific code in various subdirectories.
4
5if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
6  cmake_minimum_required(VERSION 3.4.3)
7
8  project(CompilerRTBuiltins C ASM)
9  set(COMPILER_RT_STANDALONE_BUILD TRUE)
10  set(COMPILER_RT_BUILTINS_STANDALONE_BUILD TRUE)
11  list(INSERT CMAKE_MODULE_PATH 0
12    "${CMAKE_SOURCE_DIR}/../../cmake"
13    "${CMAKE_SOURCE_DIR}/../../cmake/Modules")
14  include(base-config-ix)
15  include(CompilerRTUtils)
16  if(APPLE)
17    include(CompilerRTDarwinUtils)
18  endif()
19  include(AddCompilerRT)
20endif()
21
22include(builtin-config-ix)
23
24# TODO: Need to add a mechanism for logging errors when builtin source files are
25# added to a sub-directory and not this CMakeLists file.
26set(GENERIC_SOURCES
27  absvdi2.c
28  absvsi2.c
29  absvti2.c
30  adddf3.c
31  addsf3.c
32  addtf3.c
33  addvdi3.c
34  addvsi3.c
35  addvti3.c
36  apple_versioning.c
37  ashldi3.c
38  ashlti3.c
39  ashrdi3.c
40  ashrti3.c
41  # FIXME: atomic.c may only be compiled if host compiler understands _Atomic
42  # atomic.c
43  clear_cache.c
44  clzdi2.c
45  clzsi2.c
46  clzti2.c
47  cmpdi2.c
48  cmpti2.c
49  comparedf2.c
50  comparesf2.c
51  ctzdi2.c
52  ctzsi2.c
53  ctzti2.c
54  divdc3.c
55  divdf3.c
56  divdi3.c
57  divmoddi4.c
58  divmodsi4.c
59  divsc3.c
60  divsf3.c
61  divsi3.c
62  divtc3.c
63  divti3.c
64  divtf3.c
65  divxc3.c
66  enable_execute_stack.c
67  eprintf.c
68  extendsfdf2.c
69  extendhfsf2.c
70  ffsdi2.c
71  ffsti2.c
72  fixdfdi.c
73  fixdfsi.c
74  fixdfti.c
75  fixsfdi.c
76  fixsfsi.c
77  fixsfti.c
78  fixunsdfdi.c
79  fixunsdfsi.c
80  fixunsdfti.c
81  fixunssfdi.c
82  fixunssfsi.c
83  fixunssfti.c
84  fixunsxfdi.c
85  fixunsxfsi.c
86  fixunsxfti.c
87  fixxfdi.c
88  fixxfti.c
89  floatdidf.c
90  floatdisf.c
91  floatdixf.c
92  floatsidf.c
93  floatsisf.c
94  floattidf.c
95  floattisf.c
96  floattixf.c
97  floatundidf.c
98  floatundisf.c
99  floatundixf.c
100  floatunsidf.c
101  floatunsisf.c
102  floatuntidf.c
103  floatuntisf.c
104  floatuntixf.c
105  int_util.c
106  lshrdi3.c
107  lshrti3.c
108  moddi3.c
109  modsi3.c
110  modti3.c
111  muldc3.c
112  muldf3.c
113  muldi3.c
114  mulodi4.c
115  mulosi4.c
116  muloti4.c
117  mulsc3.c
118  mulsf3.c
119  multi3.c
120  multf3.c
121  mulvdi3.c
122  mulvsi3.c
123  mulvti3.c
124  mulxc3.c
125  negdf2.c
126  negdi2.c
127  negsf2.c
128  negti2.c
129  negvdi2.c
130  negvsi2.c
131  negvti2.c
132  paritydi2.c
133  paritysi2.c
134  parityti2.c
135  popcountdi2.c
136  popcountsi2.c
137  popcountti2.c
138  powidf2.c
139  powisf2.c
140  powitf2.c
141  powixf2.c
142  subdf3.c
143  subsf3.c
144  subvdi3.c
145  subvsi3.c
146  subvti3.c
147  subtf3.c
148  trampoline_setup.c
149  truncdfhf2.c
150  truncdfsf2.c
151  truncsfhf2.c
152  ucmpdi2.c
153  ucmpti2.c
154  udivdi3.c
155  udivmoddi4.c
156  udivmodsi4.c
157  udivmodti4.c
158  udivsi3.c
159  udivti3.c
160  umoddi3.c
161  umodsi3.c
162  umodti3.c)
163
164set(MSVC_SOURCES
165 divsc3.c
166 divdc3.c
167 divxc3.c
168 mulsc3.c
169 muldc3.c
170 mulxc3.c)
171
172
173if(APPLE)
174  set(GENERIC_SOURCES
175    ${GENERIC_SOURCES}
176    atomic_flag_clear.c
177    atomic_flag_clear_explicit.c
178    atomic_flag_test_and_set.c
179    atomic_flag_test_and_set_explicit.c
180    atomic_signal_fence.c
181    atomic_thread_fence.c)
182endif()
183
184if(NOT WIN32 OR MINGW)
185  set(GENERIC_SOURCES
186      ${GENERIC_SOURCES}
187      emutls.c)
188endif()
189
190if (HAVE_UNWIND_H)
191  set(GENERIC_SOURCES
192      ${GENERIC_SOURCES}
193      gcc_personality_v0.c)
194endif ()
195
196if (NOT MSVC)
197  set(x86_64_SOURCES
198      x86_64/chkstk.S
199      x86_64/chkstk2.S
200      x86_64/floatdidf.c
201      x86_64/floatdisf.c
202      x86_64/floatdixf.c
203      x86_64/floatundidf.S
204      x86_64/floatundisf.S
205      x86_64/floatundixf.S
206      ${GENERIC_SOURCES})
207  set(x86_64h_SOURCES ${x86_64_SOURCES})
208
209  if (WIN32)
210    set(x86_64_SOURCES
211        ${x86_64_SOURCES}
212        x86_64/chkstk.S
213        x86_64/chkstk2.S)
214  endif()
215
216  set(i386_SOURCES
217      i386/ashldi3.S
218      i386/ashrdi3.S
219      i386/chkstk.S
220      i386/chkstk2.S
221      i386/divdi3.S
222      i386/floatdidf.S
223      i386/floatdisf.S
224      i386/floatdixf.S
225      i386/floatundidf.S
226      i386/floatundisf.S
227      i386/floatundixf.S
228      i386/lshrdi3.S
229      i386/moddi3.S
230      i386/muldi3.S
231      i386/udivdi3.S
232      i386/umoddi3.S
233      ${GENERIC_SOURCES})
234
235  if (WIN32)
236    set(i386_SOURCES
237        ${i386_SOURCES}
238        i386/chkstk.S
239        i386/chkstk2.S)
240  endif()
241
242  set(i686_SOURCES
243      ${i386_SOURCES})
244else () # MSVC
245  # Use C versions of functions when building on MSVC
246  # MSVC's assembler takes Intel syntax, not AT&T syntax.
247  # Also use only MSVC compilable builtin implementations.
248  set(x86_64_SOURCES
249      x86_64/floatdidf.c
250      x86_64/floatdisf.c
251      x86_64/floatdixf.c
252      ${MSVC_SOURCES})
253  set(x86_64h_SOURCES ${x86_64_SOURCES})
254  set(i386_SOURCES ${MSVC_SOURCES})
255  set(i686_SOURCES ${i386_SOURCES})
256endif () # if (NOT MSVC)
257
258set(arm_SOURCES
259  arm/adddf3vfp.S
260  arm/addsf3vfp.S
261  arm/aeabi_cdcmp.S
262  arm/aeabi_cdcmpeq_check_nan.c
263  arm/aeabi_cfcmp.S
264  arm/aeabi_cfcmpeq_check_nan.c
265  arm/aeabi_dcmp.S
266  arm/aeabi_div0.c
267  arm/aeabi_drsub.c
268  arm/aeabi_fcmp.S
269  arm/aeabi_frsub.c
270  arm/aeabi_idivmod.S
271  arm/aeabi_ldivmod.S
272  arm/aeabi_memcmp.S
273  arm/aeabi_memcpy.S
274  arm/aeabi_memmove.S
275  arm/aeabi_memset.S
276  arm/aeabi_uidivmod.S
277  arm/aeabi_uldivmod.S
278  arm/bswapdi2.S
279  arm/bswapsi2.S
280  arm/clzdi2.S
281  arm/clzsi2.S
282  arm/comparesf2.S
283  arm/divdf3vfp.S
284  arm/divmodsi4.S
285  arm/divsf3vfp.S
286  arm/divsi3.S
287  arm/eqdf2vfp.S
288  arm/eqsf2vfp.S
289  arm/extendsfdf2vfp.S
290  arm/fixdfsivfp.S
291  arm/fixsfsivfp.S
292  arm/fixunsdfsivfp.S
293  arm/fixunssfsivfp.S
294  arm/floatsidfvfp.S
295  arm/floatsisfvfp.S
296  arm/floatunssidfvfp.S
297  arm/floatunssisfvfp.S
298  arm/gedf2vfp.S
299  arm/gesf2vfp.S
300  arm/gtdf2vfp.S
301  arm/gtsf2vfp.S
302  arm/ledf2vfp.S
303  arm/lesf2vfp.S
304  arm/ltdf2vfp.S
305  arm/ltsf2vfp.S
306  arm/modsi3.S
307  arm/muldf3vfp.S
308  arm/mulsf3vfp.S
309  arm/nedf2vfp.S
310  arm/negdf2vfp.S
311  arm/negsf2vfp.S
312  arm/nesf2vfp.S
313  arm/restore_vfp_d8_d15_regs.S
314  arm/save_vfp_d8_d15_regs.S
315  arm/subdf3vfp.S
316  arm/subsf3vfp.S
317  arm/switch16.S
318  arm/switch32.S
319  arm/switch8.S
320  arm/switchu8.S
321  arm/sync_fetch_and_add_4.S
322  arm/sync_fetch_and_add_8.S
323  arm/sync_fetch_and_and_4.S
324  arm/sync_fetch_and_and_8.S
325  arm/sync_fetch_and_max_4.S
326  arm/sync_fetch_and_max_8.S
327  arm/sync_fetch_and_min_4.S
328  arm/sync_fetch_and_min_8.S
329  arm/sync_fetch_and_nand_4.S
330  arm/sync_fetch_and_nand_8.S
331  arm/sync_fetch_and_or_4.S
332  arm/sync_fetch_and_or_8.S
333  arm/sync_fetch_and_sub_4.S
334  arm/sync_fetch_and_sub_8.S
335  arm/sync_fetch_and_umax_4.S
336  arm/sync_fetch_and_umax_8.S
337  arm/sync_fetch_and_umin_4.S
338  arm/sync_fetch_and_umin_8.S
339  arm/sync_fetch_and_xor_4.S
340  arm/sync_fetch_and_xor_8.S
341  arm/sync_synchronize.S
342  arm/truncdfsf2vfp.S
343  arm/udivmodsi4.S
344  arm/udivsi3.S
345  arm/umodsi3.S
346  arm/unorddf2vfp.S
347  arm/unordsf2vfp.S
348  ${GENERIC_SOURCES})
349
350set(aarch64_SOURCES
351  comparetf2.c
352  extenddftf2.c
353  extendsftf2.c
354  fixtfdi.c
355  fixtfsi.c
356  fixtfti.c
357  fixunstfdi.c
358  fixunstfsi.c
359  fixunstfti.c
360  floatditf.c
361  floatsitf.c
362  floatunditf.c
363  floatunsitf.c
364  multc3.c
365  trunctfdf2.c
366  trunctfsf2.c
367  ${GENERIC_SOURCES})
368
369set(armhf_SOURCES ${arm_SOURCES})
370set(armv7_SOURCES ${arm_SOURCES})
371set(armv7s_SOURCES ${arm_SOURCES})
372set(armv7k_SOURCES ${arm_SOURCES})
373set(arm64_SOURCES ${aarch64_SOURCES})
374
375# macho_embedded archs
376set(armv6m_SOURCES ${GENERIC_SOURCES})
377set(armv7m_SOURCES ${arm_SOURCES})
378set(armv7em_SOURCES ${arm_SOURCES})
379
380set(mips_SOURCES ${GENERIC_SOURCES})
381set(mipsel_SOURCES ${mips_SOURCES})
382set(mips64_SOURCES ${mips_SOURCES})
383set(mips64el_SOURCES ${mips_SOURCES})
384
385set(wasm32_SOURCES ${GENERIC_SOURCES})
386set(wasm64_SOURCES ${GENERIC_SOURCES})
387
388add_custom_target(builtins)
389set_target_properties(builtins PROPERTIES FOLDER "Compiler-RT Misc")
390
391if (APPLE)
392  add_subdirectory(Darwin-excludes)
393  add_subdirectory(macho_embedded)
394  darwin_add_builtin_libraries(${BUILTIN_SUPPORTED_OS})
395else ()
396  append_string_if(COMPILER_RT_HAS_STD_C99_FLAG -std=c99 maybe_stdc99)
397
398  foreach (arch ${BUILTIN_SUPPORTED_ARCH})
399    if (CAN_TARGET_${arch})
400      # Filter out generic versions of routines that are re-implemented in
401      # architecture specific manner.  This prevents multiple definitions of the
402      # same symbols, making the symbol selection non-deterministic.
403      foreach (_file ${${arch}_SOURCES})
404        if (${_file} MATCHES ${arch}/*)
405          get_filename_component(_name ${_file} NAME)
406          string(REPLACE ".S" ".c" _cname "${_name}")
407          list(REMOVE_ITEM ${arch}_SOURCES ${_cname})
408        endif ()
409      endforeach ()
410
411      add_compiler_rt_runtime(clang_rt.builtins
412                              STATIC
413                              ARCHS ${arch}
414                              SOURCES ${${arch}_SOURCES}
415                              CFLAGS ${maybe_stdc99}
416                              PARENT_TARGET builtins)
417    endif ()
418  endforeach ()
419endif ()
420
421add_dependencies(compiler-rt builtins)
422