1# Compute the Clang version from the LLVM version. 2# FIXME: We should be able to reuse CLANG_VERSION variable calculated 3# in Clang cmake files, instead of copying the rules here. 4string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION 5 ${PACKAGE_VERSION}) 6 7# Call add_clang_runtime_static_library(<target_library>) to make 8# sure that static <target_library> is built in the directory 9# where Clang driver expects to find it. 10if (APPLE) 11 set(CLANG_RUNTIME_LIB_DIR 12 ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/lib/darwin) 13elseif (UNIX) 14 # Assume Linux. 15 set(CLANG_RUNTIME_LIB_DIR 16 ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/lib/linux) 17endif() 18function(add_clang_runtime_static_library) 19 set_target_properties(${ARGN} PROPERTIES 20 ARCHIVE_OUTPUT_DIRECTORY ${CLANG_RUNTIME_LIB_DIR}) 21endfunction() 22function(add_clang_runtime_shared_library) 23 set_target_properties(${ARGN} PROPERTIES 24 LIBRARY_OUTPUT_DIRECTORY ${CLANG_RUNTIME_LIB_DIR}) 25endfunction() 26 27# First, add the subdirectories which contain feature-based runtime libraries 28# and several convenience helper libraries. 29add_subdirectory(asan) 30add_subdirectory(interception) 31add_subdirectory(sanitizer_common) 32 33# FIXME: Add support for tsan library. 34# FIXME: Add support for the profile library. 35 36# The top-level lib directory contains a large amount of C code which provides 37# generic implementations of the core runtime library along with optimized 38# architecture-specific code in various subdirectories. 39 40set(GENERIC_SOURCES 41 absvdi2.c 42 absvsi2.c 43 absvti2.c 44 adddf3.c 45 addsf3.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 clear_cache.c 55 clzdi2.c 56 clzsi2.c 57 clzti2.c 58 cmpdi2.c 59 cmpti2.c 60 comparedf2.c 61 comparesf2.c 62 ctzdi2.c 63 ctzsi2.c 64 ctzti2.c 65 divdc3.c 66 divdf3.c 67 divdi3.c 68 divmoddi4.c 69 divmodsi4.c 70 divsc3.c 71 divsf3.c 72 divsi3.c 73 divti3.c 74 divxc3.c 75 enable_execute_stack.c 76 eprintf.c 77 extendsfdf2.c 78 ffsdi2.c 79 ffsti2.c 80 fixdfdi.c 81 fixdfsi.c 82 fixdfti.c 83 fixsfdi.c 84 fixsfsi.c 85 fixsfti.c 86 fixunsdfdi.c 87 fixunsdfsi.c 88 fixunsdfti.c 89 fixunssfdi.c 90 fixunssfsi.c 91 fixunssfti.c 92 fixunsxfdi.c 93 fixunsxfsi.c 94 fixunsxfti.c 95 fixxfdi.c 96 fixxfti.c 97 floatdidf.c 98 floatdisf.c 99 floatdixf.c 100 floatsidf.c 101 floatsisf.c 102 floattidf.c 103 floattisf.c 104 floattixf.c 105 floatundidf.c 106 floatundisf.c 107 floatundixf.c 108 floatunsidf.c 109 floatunsisf.c 110 floatuntidf.c 111 floatuntisf.c 112 floatuntixf.c 113 gcc_personality_v0.c 114 int_util.c 115 lshrdi3.c 116 lshrti3.c 117 moddi3.c 118 modsi3.c 119 modti3.c 120 muldc3.c 121 muldf3.c 122 muldi3.c 123 mulodi4.c 124 mulosi4.c 125 muloti4.c 126 mulsc3.c 127 mulsf3.c 128 multi3.c 129 mulvdi3.c 130 mulvsi3.c 131 mulvti3.c 132 mulxc3.c 133 negdf2.c 134 negdi2.c 135 negsf2.c 136 negti2.c 137 negvdi2.c 138 negvsi2.c 139 negvti2.c 140 paritydi2.c 141 paritysi2.c 142 parityti2.c 143 popcountdi2.c 144 popcountsi2.c 145 popcountti2.c 146 powidf2.c 147 powisf2.c 148 powitf2.c 149 powixf2.c 150 subdf3.c 151 subsf3.c 152 subvdi3.c 153 subvsi3.c 154 subvti3.c 155 trampoline_setup.c 156 truncdfsf2.c 157 ucmpdi2.c 158 ucmpti2.c 159 udivdi3.c 160 udivmoddi4.c 161 udivmodsi4.c 162 udivmodti4.c 163 udivsi3.c 164 udivti3.c 165 umoddi3.c 166 umodsi3.c 167 umodti3.c 168 ) 169 170if(CAN_TARGET_X86_64) 171 add_library(clang_rt.x86_64 STATIC 172 x86_64/floatdidf.c 173 x86_64/floatdisf.c 174 x86_64/floatdixf.c 175 x86_64/floatundidf.S 176 x86_64/floatundisf.S 177 x86_64/floatundixf.S 178 ${GENERIC_SOURCES} 179 ) 180 set_target_properties(clang_rt.x86_64 PROPERTIES COMPILE_FLAGS "-std=c99 ${TARGET_X86_64_CFLAGS}") 181endif() 182if(CAN_TARGET_I386) 183 add_library(clang_rt.i386 STATIC 184 i386/ashldi3.S 185 i386/ashrdi3.S 186 i386/divdi3.S 187 i386/floatdidf.S 188 i386/floatdisf.S 189 i386/floatdixf.S 190 i386/floatundidf.S 191 i386/floatundisf.S 192 i386/floatundixf.S 193 i386/lshrdi3.S 194 i386/moddi3.S 195 i386/muldi3.S 196 i386/udivdi3.S 197 i386/umoddi3.S 198 ${GENERIC_SOURCES} 199 ) 200 set_target_properties(clang_rt.i386 PROPERTIES COMPILE_FLAGS "-std=c99 ${TARGET_I386_CFLAGS}") 201endif() 202