xref: /openbsd/gnu/lib/libcompiler_rt/Makefile (revision 34cf8634)
1*34cf8634Sjca# $OpenBSD: Makefile,v 1.8 2024/02/06 05:07:28 jca Exp $
26f4c386aSpatrick
36f4c386aSpatrick.include <bsd.own.mk>
46f4c386aSpatrick
56f4c386aSpatrick.if ${COMPILER_VERSION:L} != "clang"
66f4c386aSpatrickCC=		clang
76f4c386aSpatrickCXX=		clang++
86f4c386aSpatrick.endif
96f4c386aSpatrick
106f4c386aSpatrick.if ${BUILD_CLANG:L} == "yes"
116f4c386aSpatrick
126f4c386aSpatrickLIB=	compiler_rt
136f4c386aSpatrickNOPIC=
146f4c386aSpatrickNOPROFILE=
156f4c386aSpatrick
166f4c386aSpatrickCFLAGS+=	-fPIC -std=gnu99 -fvisibility=hidden -fno-stack-protector
179da016ebSpatrickCPPFLAGS+=	-I${.CURDIR}/../../llvm/compiler-rt/lib/builtins
186f4c386aSpatrickCPPFLAGS+=	-DVISIBILITY_HIDDEN
196f4c386aSpatrick
206f4c386aSpatrick.if ${MACHINE_ARCH} == "amd64"
216f4c386aSpatrickRTARCH=	x86_64
226f4c386aSpatrick.elif ${MACHINE_ARCH} == "powerpc"
236f4c386aSpatrickRTARCH=	ppc
24c120e349Sjca.elif ${MACHINE_ARCH} == "riscv64"
25c120e349SjcaRTARCH=	riscv
266f4c386aSpatrick.else
276f4c386aSpatrickRTARCH=	${MACHINE_ARCH}
286f4c386aSpatrick.endif
296f4c386aSpatrick
306f4c386aSpatrick.PATH: ${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}
316f4c386aSpatrick.PATH: ${.CURDIR}/../../llvm/compiler-rt/lib/builtins
326f4c386aSpatrick
336f4c386aSpatrickGEN_SRCS=	absvdi2 \
346f4c386aSpatrick		absvsi2 \
356f4c386aSpatrick		absvti2 \
366f4c386aSpatrick		addtf3 \
376f4c386aSpatrick		addvdi3 \
386f4c386aSpatrick		addvsi3 \
396f4c386aSpatrick		addvti3 \
406f4c386aSpatrick		apple_versioning \
416f4c386aSpatrick		ashldi3 \
426f4c386aSpatrick		ashlti3 \
436f4c386aSpatrick		ashrdi3 \
446f4c386aSpatrick		ashrti3 \
456f4c386aSpatrick		atomic \
466f4c386aSpatrick		bswapdi2 \
476f4c386aSpatrick		bswapsi2 \
486f4c386aSpatrick		clear_cache \
496f4c386aSpatrick		clzdi2 \
506f4c386aSpatrick		clzsi2 \
516f4c386aSpatrick		clzti2 \
526f4c386aSpatrick		cmpdi2 \
536f4c386aSpatrick		cmpti2 \
546f4c386aSpatrick		comparedf2 \
556f4c386aSpatrick		comparesf2 \
566f4c386aSpatrick		cpu_model \
576f4c386aSpatrick		ctzdi2 \
586f4c386aSpatrick		ctzsi2 \
596f4c386aSpatrick		ctzti2 \
606f4c386aSpatrick		divdc3 \
616f4c386aSpatrick		divdi3 \
626f4c386aSpatrick		divmoddi4 \
636f4c386aSpatrick		divmodsi4 \
646f4c386aSpatrick		divsc3 \
656f4c386aSpatrick		divtc3 \
666f4c386aSpatrick		divti3 \
676f4c386aSpatrick		divtf3 \
686f4c386aSpatrick		divxc3 \
696f4c386aSpatrick		emutls \
706f4c386aSpatrick		enable_execute_stack \
716f4c386aSpatrick		eprintf \
726f4c386aSpatrick		extendhfsf2 \
736f4c386aSpatrick		ffsdi2 \
746f4c386aSpatrick		ffssi2 \
756f4c386aSpatrick		ffsti2 \
766f4c386aSpatrick		fixdfti \
776f4c386aSpatrick		fixsfti \
786f4c386aSpatrick		fixunsdfsi \
796f4c386aSpatrick		fixunsdfti \
806f4c386aSpatrick		fixunssfsi \
816f4c386aSpatrick		fixunssfti \
826f4c386aSpatrick		fixunsxfdi \
836f4c386aSpatrick		fixunsxfsi \
846f4c386aSpatrick		fixunsxfti \
856f4c386aSpatrick		fixxfdi \
866f4c386aSpatrick		fixxfti \
876f4c386aSpatrick		floattidf \
886f4c386aSpatrick		floattisf \
896f4c386aSpatrick		floattixf \
906f4c386aSpatrick		floatunsidf \
916f4c386aSpatrick		floatunsisf \
926f4c386aSpatrick		floatuntidf \
936f4c386aSpatrick		floatuntisf \
946f4c386aSpatrick		floatuntixf \
956f4c386aSpatrick		fp_mode \
966f4c386aSpatrick		gcc_personality_v0 \
976f4c386aSpatrick		int_util \
986f4c386aSpatrick		lshrdi3 \
996f4c386aSpatrick		lshrti3 \
1006f4c386aSpatrick		moddi3 \
1016f4c386aSpatrick		modsi3 \
1026f4c386aSpatrick		modti3 \
1036f4c386aSpatrick		muldc3 \
1046f4c386aSpatrick		muldi3 \
1056f4c386aSpatrick		mulodi4 \
1066f4c386aSpatrick		mulosi4 \
1076f4c386aSpatrick		muloti4 \
1086f4c386aSpatrick		mulsc3 \
1096f4c386aSpatrick		multi3 \
1106f4c386aSpatrick		multf3 \
1116f4c386aSpatrick		mulvdi3 \
1126f4c386aSpatrick		mulvsi3 \
1136f4c386aSpatrick		mulvti3 \
1146f4c386aSpatrick		mulxc3 \
1156f4c386aSpatrick		negdf2 \
1166f4c386aSpatrick		negdi2 \
1176f4c386aSpatrick		negsf2 \
1186f4c386aSpatrick		negti2 \
1196f4c386aSpatrick		negvdi2 \
1206f4c386aSpatrick		negvsi2 \
1216f4c386aSpatrick		negvti2 \
1226f4c386aSpatrick		paritydi2 \
1236f4c386aSpatrick		paritysi2 \
1246f4c386aSpatrick		parityti2 \
1256f4c386aSpatrick		popcountdi2 \
1266f4c386aSpatrick		popcountsi2 \
1276f4c386aSpatrick		popcountti2 \
1286f4c386aSpatrick		powidf2 \
1296f4c386aSpatrick		powisf2 \
1306f4c386aSpatrick		powitf2 \
1316f4c386aSpatrick		powixf2 \
1326f4c386aSpatrick		subvdi3 \
1336f4c386aSpatrick		subvsi3 \
1346f4c386aSpatrick		subvti3 \
1356f4c386aSpatrick		subtf3 \
1366f4c386aSpatrick		trampoline_setup \
1376f4c386aSpatrick		truncdfhf2 \
1386f4c386aSpatrick		truncsfhf2 \
1396f4c386aSpatrick		ucmpdi2 \
1406f4c386aSpatrick		ucmpti2 \
1416f4c386aSpatrick		udivdi3 \
1426f4c386aSpatrick		udivmoddi4 \
1436f4c386aSpatrick		udivmodsi4 \
1446f4c386aSpatrick		udivmodti4 \
1456f4c386aSpatrick		udivti3 \
1466f4c386aSpatrick		umoddi3 \
1476f4c386aSpatrick		umodsi3 \
1486f4c386aSpatrick		umodti3
1496f4c386aSpatrick
1506f4c386aSpatrick.if ${RTARCH} != "arm"
1516f4c386aSpatrickGEN_SRCS+=	adddf3 \
1526f4c386aSpatrick		addsf3 \
1536f4c386aSpatrick		divdf3 \
1546f4c386aSpatrick		divsf3 \
1556f4c386aSpatrick		divsi3 \
1566f4c386aSpatrick		extendsfdf2 \
1576f4c386aSpatrick		fixdfdi \
1586f4c386aSpatrick		fixdfsi \
1596f4c386aSpatrick		fixsfdi \
1606f4c386aSpatrick		fixsfsi \
1616f4c386aSpatrick		fixunsdfdi \
1626f4c386aSpatrick		fixunssfdi \
1636f4c386aSpatrick		floatsidf \
1646f4c386aSpatrick		floatsisf \
1656f4c386aSpatrick		muldf3 \
1666f4c386aSpatrick		mulsf3 \
1676f4c386aSpatrick		subdf3 \
1686f4c386aSpatrick		subsf3 \
1696f4c386aSpatrick		truncdfsf2 \
1706f4c386aSpatrick		udivsi3
1716f4c386aSpatrick.endif
1726f4c386aSpatrick
1736f4c386aSpatrick.if ${RTARCH} == "i386"
1746f4c386aSpatrickSRCS+=	floatdidf.c \
1756f4c386aSpatrick	floatdisf.c \
1766f4c386aSpatrick	floatdixf.c \
1776f4c386aSpatrick	floatundidf.c \
1786f4c386aSpatrick	floatundisf.c \
1796f4c386aSpatrick	floatundixf.c
1806f4c386aSpatrick.else
1816f4c386aSpatrickGEN_SRCS+=	floatdidf \
1826f4c386aSpatrick		floatdisf \
1836f4c386aSpatrick		floatdixf \
1846f4c386aSpatrick		floatundidf \
1856f4c386aSpatrick		floatundisf \
1866f4c386aSpatrick		floatundixf
1876f4c386aSpatrick.endif
1886f4c386aSpatrick
1896f4c386aSpatrick.for file in ${GEN_SRCS}
1906b8783caSjsg.	if exists(${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}/${file}.S)
1916f4c386aSpatrickSRCS+=	${file}.S
1926f4c386aSpatrick.	else
1936f4c386aSpatrickSRCS+=	${file}.c
1946f4c386aSpatrick.	endif
1956f4c386aSpatrick.endfor
1966f4c386aSpatrick
1976f4c386aSpatrick.if ${RTARCH} == "aarch64"
1986f4c386aSpatrickSRCS+=	comparetf2.c \
1996f4c386aSpatrick	extenddftf2.c \
2006f4c386aSpatrick	extendsftf2.c \
2016f4c386aSpatrick	fixtfdi.c \
2026f4c386aSpatrick	fixtfsi.c \
2036f4c386aSpatrick	fixtfti.c \
2046f4c386aSpatrick	fixunstfdi.c \
2056f4c386aSpatrick	fixunstfsi.c \
2066f4c386aSpatrick	fixunstfti.c \
2076f4c386aSpatrick	floatditf.c \
2086f4c386aSpatrick	floatsitf.c \
2096f4c386aSpatrick	floattitf.c \
2106f4c386aSpatrick	floatunditf.c \
2116f4c386aSpatrick	floatunsitf.c \
2126f4c386aSpatrick	floatuntitf.c \
2136f4c386aSpatrick	multc3.c \
2146f4c386aSpatrick	trunctfdf2.c \
2156f4c386aSpatrick	trunctfsf2.c
2169da016ebSpatrick
2179da016ebSpatrick# Prepare multiple versions of the LSE-helper
2189da016ebSpatrickCPPFLAGS+=-DHAS_ASM_LSE
2199da016ebSpatrick.for pat in cas swp ldadd ldclr ldeor ldset
2209da016ebSpatrick.  for size in 1 2 4 8 16
2219da016ebSpatrick.    for model in 1 2 3 4
2229da016ebSpatrick.      if "${pat}" == "cas" || "${size}" != "16"
2239da016ebSpatrickoutline_atomic_${pat}${size}_${model}.S: Makefile ${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}/lse.S
2249da016ebSpatrick	@echo "#define L_${pat}\n#define SIZE ${size}\n#define MODEL ${model}\n" > $@.tmp
2259da016ebSpatrick	@cat ${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}/lse.S >> $@.tmp
2269da016ebSpatrick	@mv $@.tmp $@
2279da016ebSpatrick
2289da016ebSpatrickSRCS+=	outline_atomic_${pat}${size}_${model}.S
2299da016ebSpatrick.      endif
2309da016ebSpatrick.    endfor
2319da016ebSpatrick.  endfor
2329da016ebSpatrick.endfor
2339da016ebSpatrick
2346f4c386aSpatrick.endif
2356f4c386aSpatrick
2366f4c386aSpatrick.if ${RTARCH} == "arm"
2376f4c386aSpatrickSRCS+=	aeabi_cdcmp.S \
2386f4c386aSpatrick	aeabi_cdcmpeq_check_nan.c \
2396f4c386aSpatrick	aeabi_cfcmp.S \
2406f4c386aSpatrick	aeabi_cfcmpeq_check_nan.c \
2416f4c386aSpatrick	aeabi_dcmp.S \
2426f4c386aSpatrick	aeabi_div0.c \
2436f4c386aSpatrick	aeabi_drsub.c \
2446f4c386aSpatrick	aeabi_fcmp.S \
2456f4c386aSpatrick	aeabi_frsub.c \
2466f4c386aSpatrick	aeabi_ldivmod.S \
2476f4c386aSpatrick	aeabi_memcmp.S \
2486f4c386aSpatrick	aeabi_memcpy.S \
2496f4c386aSpatrick	aeabi_memmove.S \
2506f4c386aSpatrick	aeabi_memset.S \
2516f4c386aSpatrick	aeabi_uldivmod.S \
2526f4c386aSpatrick	switch16.S \
2536f4c386aSpatrick	switch32.S \
2546f4c386aSpatrick	switch8.S \
2556f4c386aSpatrick	switchu8.S \
2566f4c386aSpatrick	sync_fetch_and_add_4.S \
2576f4c386aSpatrick	sync_fetch_and_add_8.S \
2586f4c386aSpatrick	sync_fetch_and_and_4.S \
2596f4c386aSpatrick	sync_fetch_and_and_8.S \
2606f4c386aSpatrick	sync_fetch_and_max_4.S \
2616f4c386aSpatrick	sync_fetch_and_max_8.S \
2626f4c386aSpatrick	sync_fetch_and_min_4.S \
2636f4c386aSpatrick	sync_fetch_and_min_8.S \
2646f4c386aSpatrick	sync_fetch_and_nand_4.S \
2656f4c386aSpatrick	sync_fetch_and_nand_8.S \
2666f4c386aSpatrick	sync_fetch_and_or_4.S \
2676f4c386aSpatrick	sync_fetch_and_or_8.S \
2686f4c386aSpatrick	sync_fetch_and_sub_4.S \
2696f4c386aSpatrick	sync_fetch_and_sub_8.S \
2706f4c386aSpatrick	sync_fetch_and_umax_4.S \
2716f4c386aSpatrick	sync_fetch_and_umax_8.S \
2726f4c386aSpatrick	sync_fetch_and_umin_4.S \
2736f4c386aSpatrick	sync_fetch_and_umin_8.S \
2746f4c386aSpatrick	sync_fetch_and_xor_4.S \
2756f4c386aSpatrick	sync_fetch_and_xor_8.S \
2766f4c386aSpatrick	sync_synchronize.S
2776f4c386aSpatrick.endif
2786f4c386aSpatrick
2796f4c386aSpatrick.if ${RTARCH} == "mips64" || ${RTARCH} == "mips64el"
2806f4c386aSpatrickSRCS+=	comparetf2.c \
2816f4c386aSpatrick	extenddftf2.c \
2826f4c386aSpatrick	extendsftf2.c \
2836f4c386aSpatrick	fixtfdi.c \
2846f4c386aSpatrick	fixtfsi.c \
2856f4c386aSpatrick	fixtfti.c \
2866f4c386aSpatrick	fixunstfdi.c \
2876f4c386aSpatrick	fixunstfsi.c \
2886f4c386aSpatrick	fixunstfti.c \
2896f4c386aSpatrick	floatditf.c \
2906f4c386aSpatrick	floatsitf.c \
2916f4c386aSpatrick	floattitf.c \
2926f4c386aSpatrick	floatunditf.c \
2936f4c386aSpatrick	floatunsitf.c \
2946f4c386aSpatrick	floatuntitf.c \
2956f4c386aSpatrick	multc3.c \
2966f4c386aSpatrick	trunctfdf2.c \
2976f4c386aSpatrick	trunctfsf2.c
2986f4c386aSpatrick.endif
2996f4c386aSpatrick
3006f4c386aSpatrick.if ${RTARCH} == "ppc"
301a6dd968cSkettenis# Omit "double-double" functions since long double is the same as
302a6dd968cSkettenis# double on OpenBSD.
303a6dd968cSkettenisSRCS+=	atomic_lock_free.c
3046f4c386aSpatrick.endif
3056f4c386aSpatrick
306c120e349Sjca.if ${RTARCH} == "riscv"
30712634b43SdrahnSRCS+=	comparetf2.c \
30812634b43Sdrahn	extenddftf2.c \
30912634b43Sdrahn	extendsftf2.c \
31012634b43Sdrahn	fixtfdi.c \
31112634b43Sdrahn	fixtfsi.c \
31212634b43Sdrahn	fixtfti.c \
31312634b43Sdrahn	fixunstfdi.c \
31412634b43Sdrahn	fixunstfsi.c \
31512634b43Sdrahn	fixunstfti.c \
31612634b43Sdrahn	floatditf.c \
31712634b43Sdrahn	floatsitf.c \
31812634b43Sdrahn	floattitf.c \
31912634b43Sdrahn	floatunditf.c \
32012634b43Sdrahn	floatunsitf.c \
32112634b43Sdrahn	floatuntitf.c \
32212634b43Sdrahn	multc3.c \
323*34cf8634Sjca	restore.S \
324*34cf8634Sjca	save.S \
32512634b43Sdrahn	trunctfdf2.c \
32612634b43Sdrahn	trunctfsf2.c
32712634b43Sdrahn.endif
32812634b43Sdrahn
3296f4c386aSpatrick.if ${RTARCH} == "sparc64"
3306f4c386aSpatrickSRCS+=	comparetf2.c \
3316f4c386aSpatrick	extenddftf2.c \
3326f4c386aSpatrick	extendsftf2.c \
3336f4c386aSpatrick	fixtfdi.c \
3346f4c386aSpatrick	fixtfsi.c \
3356f4c386aSpatrick	fixtfti.c \
3366f4c386aSpatrick	fixunstfdi.c \
3376f4c386aSpatrick	fixunstfsi.c \
3386f4c386aSpatrick	fixunstfti.c \
3396f4c386aSpatrick	floatditf.c \
3406f4c386aSpatrick	floatsitf.c \
3416f4c386aSpatrick	floattitf.c \
3426f4c386aSpatrick	floatunditf.c \
3436f4c386aSpatrick	floatunsitf.c \
3446f4c386aSpatrick	floatuntitf.c \
3456f4c386aSpatrick	multc3.c \
3466f4c386aSpatrick	trunctfdf2.c \
3476f4c386aSpatrick	trunctfsf2.c
3486f4c386aSpatrick.endif
3496f4c386aSpatrick
3506f4c386aSpatrick.include <bsd.lib.mk>
3516f4c386aSpatrick
3526f4c386aSpatrick.else
3536f4c386aSpatrickNOPROG=
3546f4c386aSpatrick.include <bsd.prog.mk>
3556f4c386aSpatrick.endif
356