1.include <bsd.compiler.mk> 2 3CRTARCH= ${MACHINE_CPUARCH:C/amd64/x86_64/:C/powerpc/ppc/} 4 5CRTSRC= ${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins 6 7.PATH: ${CRTSRC}/${CRTARCH} 8.PATH: ${CRTSRC} 9 10SRCF+= absvdi2 11SRCF+= absvsi2 12SRCF+= absvti2 13SRCF+= addvdi3 14SRCF+= addvsi3 15SRCF+= addvti3 16SRCF+= apple_versioning 17SRCF+= ashldi3 18SRCF+= ashlti3 19SRCF+= ashrdi3 20SRCF+= ashrti3 21SRCF+= bswapdi2 22SRCF+= bswapsi2 23SRCF+= clear_cache 24SRCF+= clzdi2 25SRCF+= clzsi2 26SRCF+= clzti2 27SRCF+= cmpdi2 28SRCF+= cmpti2 29SRCF+= ctzdi2 30SRCF+= ctzsi2 31SRCF+= ctzti2 32SRCF+= divdc3 33SRCF+= divdi3 34SRCF+= divmoddi4 35SRCF+= divmodsi4 36SRCF+= divmodti4 37SRCF+= divsc3 38SRCF+= divsi3 39SRCF+= divti3 40SRCF+= enable_execute_stack 41SRCF+= extendhfsf2 42SRCF+= ffsdi2 43SRCF+= ffssi2 44SRCF+= ffsti2 45SRCF+= fixdfdi 46SRCF+= fixdfti 47SRCF+= fixsfdi 48SRCF+= fixsfti 49SRCF+= fixunsdfdi 50SRCF+= fixunsdfsi 51SRCF+= fixunsdfti 52SRCF+= fixunssfdi 53SRCF+= fixunssfsi 54SRCF+= fixunssfti 55SRCF+= floattidf 56SRCF+= floattisf 57SRCF+= floatunsidf 58SRCF+= floatunsisf 59SRCF+= floatuntidf 60SRCF+= floatuntisf 61SRCF+= int_util 62SRCF+= lshrdi3 63SRCF+= lshrti3 64SRCF+= moddi3 65SRCF+= modsi3 66SRCF+= modti3 67SRCF+= muldc3 68SRCF+= muldi3 69SRCF+= mulodi4 70SRCF+= mulosi4 71SRCF+= muloti4 72SRCF+= mulsc3 73SRCF+= multi3 74SRCF+= mulvdi3 75SRCF+= mulvsi3 76SRCF+= mulvti3 77SRCF+= negdf2 78SRCF+= negdi2 79SRCF+= negsf2 80SRCF+= negti2 81SRCF+= negvdi2 82SRCF+= negvsi2 83SRCF+= negvti2 84SRCF+= paritydi2 85SRCF+= paritysi2 86SRCF+= parityti2 87SRCF+= popcountdi2 88SRCF+= popcountsi2 89SRCF+= popcountti2 90SRCF+= powidf2 91SRCF+= powisf2 92SRCF+= subvdi3 93SRCF+= subvsi3 94SRCF+= subvti3 95SRCF+= trampoline_setup 96SRCF+= truncdfhf2 97SRCF+= truncsfhf2 98SRCF+= ucmpdi2 99SRCF+= ucmpti2 100SRCF+= udivdi3 101SRCF+= udivmoddi4 102SRCF+= udivmodsi4 103SRCF+= udivmodti4 104SRCF+= udivsi3 105SRCF+= udivti3 106SRCF+= umoddi3 107SRCF+= umodsi3 108SRCF+= umodti3 109 110# Enable compiler-rt's atomic implementation only for clang, as it uses clang 111# specific builtins, and gcc packages usually come with their own libatomic. 112# Exclude arm which has its own implementations of atomic functions, below. 113.if "${COMPILER_TYPE}" == "clang" && ${MACHINE_CPUARCH} != "arm" 114SRCF+= atomic 115.endif 116 117# Avoid using SSE2 instructions on i386, if unsupported. 118.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2) 119SRCS+= floatdidf.c 120SRCS+= floatdisf.c 121SRCS+= floatundidf.c 122SRCS+= floatundisf.c 123.else 124SRCF+= floatdidf 125SRCF+= floatdisf 126SRCF+= floatundidf 127SRCF+= floatundisf 128.endif 129 130# 131# 80-bit long double functions, only used on x86. 132# 133.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 134SRCF+= divxc3 135SRCF+= extendxftf2 136SRCF+= fixxfdi 137SRCF+= fixxfti 138SRCF+= fixunsxfdi 139SRCF+= fixunsxfsi 140SRCF+= fixunsxfti 141SRCF+= floattixf 142SRCF+= floatuntixf 143SRCF+= mulxc3 144SRCF+= powixf2 145SRCF+= trunctfxf2 146 147# Avoid using SSE2 instructions on i386, if unsupported. 148.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2) 149SRCS+= floatdixf.c 150SRCS+= floatundixf.c 151.else 152SRCF+= floatdixf 153SRCF+= floatundixf 154.endif 155.endif 156 157# __cpu_model support, only used on aarch64 and x86 158.if ${MACHINE_CPUARCH} == "aarch64" 159SRCS+= cpu_model/aarch64.c 160.elif ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 161SRCS+= cpu_model/x86.c 162.endif 163 164# The fp_mode implementation for amd64 and i386 is shared, while other 165# architectures use the regular approach. 166.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 167SRCS+= i386/fp_mode.c 168.else 169SRCF+= fp_mode 170.endif 171 172# 173# 128-bit quad precision long double support, 174# only used on some architectures. 175# 176.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ 177 ${MACHINE_CPUARCH} == "riscv" 178SRCF+= addtf3 179SRCF+= comparetf2 180SRCF+= divtc3 181SRCF+= divtf3 182SRCF+= extenddftf2 183SRCF+= extendhftf2 184SRCF+= extendsftf2 185SRCF+= fixtfdi 186SRCF+= fixtfsi 187SRCF+= fixtfti 188SRCF+= fixunstfdi 189SRCF+= fixunstfsi 190SRCF+= fixunstfti 191SRCF+= floatditf 192SRCF+= floatsitf 193SRCF+= floattitf 194SRCF+= floatunditf 195SRCF+= floatunsitf 196SRCF+= floatuntitf 197SRCF+= multc3 198SRCF+= multf3 199SRCF+= powitf2 200SRCF+= subtf3 201SRCF+= trunctfdf2 202SRCF+= trunctfhf2 203SRCF+= trunctfsf2 204.endif 205 206# These are already shipped by libc.a on some architectures. 207.if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "riscv" 208SRCF+= adddf3 209SRCF+= addsf3 210SRCF+= divdf3 211SRCF+= divsf3 212SRCF+= extendsfdf2 213SRCF+= fixdfsi 214SRCF+= fixsfsi 215SRCF+= floatsidf 216SRCF+= floatsisf 217SRCF+= muldf3 218SRCF+= mulsf3 219SRCF+= subdf3 220SRCF+= subsf3 221SRCF+= truncdfsf2 222.endif 223 224.if ${MACHINE_CPUARCH} != "arm" 225SRCF+= comparedf2 226SRCF+= comparesf2 227.endif 228 229# Helper to reduce complexity of _Float16 and __bf16 statements below. 230.if ${MACHINE_CPUARCH} == "aarch64" || \ 231 ${MACHINE_CPUARCH} == "amd64" || \ 232 ${MACHINE_CPUARCH} == "arm" || \ 233 (${MACHINE_CPUARCH} == "i386" && !empty(MACHINE_CPU:Msse2)) 234CRT_COMMON_F16_ARCH=t 235.endif 236 237# 238# _Float16 support, only on some architectures, and with certain compiler 239# versions. 240# 241.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \ 242 (defined(CRT_COMMON_F16_ARCH) || ${MACHINE_CPUARCH} == "riscv")) || \ 243 ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120000) && \ 244 (defined(CRT_COMMON_F16_ARCH))) 245CFLAGS+= -DCOMPILER_RT_HAS_FLOAT16 246.endif 247 248# 249# __bf16 support, only on some architectures, and with certain compiler 250# versions. 251# 252.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \ 253 (defined(CRT_COMMON_F16_ARCH))) || \ 254 ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000) && \ 255 ${MACHINE_CPUARCH} == "riscv") || \ 256 ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 130000) && \ 257 (defined(CRT_COMMON_F16_ARCH))) 258CFLAGS+= -DCOMPILER_RT_HAS_BFLOAT16 259SRCF+= truncdfbf2 260SRCF+= truncsfbf2 261.endif 262 263# FreeBSD-specific atomic intrinsics. 264.if ${MACHINE_CPUARCH} == "arm" 265.PATH: ${SRCTOP}/sys/arm/arm 266 267SRCF+= stdatomic 268CFLAGS+= -DEMIT_SYNC_ATOMICS 269.endif 270 271.for file in ${SRCF} 272.if ${MACHINE_CPUARCH} == "arm" && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \ 273 && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S) 274SRCS+= ${file}vfp.S 275. elif exists(${CRTSRC}/${CRTARCH}/${file}.S) 276SRCS+= ${file}.S 277. else 278SRCS+= ${file}.c 279. endif 280.endfor 281 282.if ${MACHINE_CPUARCH} == "arm" 283SRCS+= aeabi_div0.c 284SRCS+= aeabi_idivmod.S 285SRCS+= aeabi_ldivmod.S 286SRCS+= aeabi_memcmp.S 287SRCS+= aeabi_memcpy.S 288SRCS+= aeabi_memmove.S 289SRCS+= aeabi_memset.S 290SRCS+= aeabi_uidivmod.S 291SRCS+= aeabi_uldivmod.S 292SRCS+= switch16.S 293SRCS+= switch32.S 294SRCS+= switch8.S 295SRCS+= switchu8.S 296SRCS+= sync_synchronize.S 297.endif 298