xref: /openbsd/gnu/lib/libcompiler_rt/Makefile (revision 34cf8634)
1# $OpenBSD: Makefile,v 1.8 2024/02/06 05:07:28 jca Exp $
2
3.include <bsd.own.mk>
4
5.if ${COMPILER_VERSION:L} != "clang"
6CC=		clang
7CXX=		clang++
8.endif
9
10.if ${BUILD_CLANG:L} == "yes"
11
12LIB=	compiler_rt
13NOPIC=
14NOPROFILE=
15
16CFLAGS+=	-fPIC -std=gnu99 -fvisibility=hidden -fno-stack-protector
17CPPFLAGS+=	-I${.CURDIR}/../../llvm/compiler-rt/lib/builtins
18CPPFLAGS+=	-DVISIBILITY_HIDDEN
19
20.if ${MACHINE_ARCH} == "amd64"
21RTARCH=	x86_64
22.elif ${MACHINE_ARCH} == "powerpc"
23RTARCH=	ppc
24.elif ${MACHINE_ARCH} == "riscv64"
25RTARCH=	riscv
26.else
27RTARCH=	${MACHINE_ARCH}
28.endif
29
30.PATH: ${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}
31.PATH: ${.CURDIR}/../../llvm/compiler-rt/lib/builtins
32
33GEN_SRCS=	absvdi2 \
34		absvsi2 \
35		absvti2 \
36		addtf3 \
37		addvdi3 \
38		addvsi3 \
39		addvti3 \
40		apple_versioning \
41		ashldi3 \
42		ashlti3 \
43		ashrdi3 \
44		ashrti3 \
45		atomic \
46		bswapdi2 \
47		bswapsi2 \
48		clear_cache \
49		clzdi2 \
50		clzsi2 \
51		clzti2 \
52		cmpdi2 \
53		cmpti2 \
54		comparedf2 \
55		comparesf2 \
56		cpu_model \
57		ctzdi2 \
58		ctzsi2 \
59		ctzti2 \
60		divdc3 \
61		divdi3 \
62		divmoddi4 \
63		divmodsi4 \
64		divsc3 \
65		divtc3 \
66		divti3 \
67		divtf3 \
68		divxc3 \
69		emutls \
70		enable_execute_stack \
71		eprintf \
72		extendhfsf2 \
73		ffsdi2 \
74		ffssi2 \
75		ffsti2 \
76		fixdfti \
77		fixsfti \
78		fixunsdfsi \
79		fixunsdfti \
80		fixunssfsi \
81		fixunssfti \
82		fixunsxfdi \
83		fixunsxfsi \
84		fixunsxfti \
85		fixxfdi \
86		fixxfti \
87		floattidf \
88		floattisf \
89		floattixf \
90		floatunsidf \
91		floatunsisf \
92		floatuntidf \
93		floatuntisf \
94		floatuntixf \
95		fp_mode \
96		gcc_personality_v0 \
97		int_util \
98		lshrdi3 \
99		lshrti3 \
100		moddi3 \
101		modsi3 \
102		modti3 \
103		muldc3 \
104		muldi3 \
105		mulodi4 \
106		mulosi4 \
107		muloti4 \
108		mulsc3 \
109		multi3 \
110		multf3 \
111		mulvdi3 \
112		mulvsi3 \
113		mulvti3 \
114		mulxc3 \
115		negdf2 \
116		negdi2 \
117		negsf2 \
118		negti2 \
119		negvdi2 \
120		negvsi2 \
121		negvti2 \
122		paritydi2 \
123		paritysi2 \
124		parityti2 \
125		popcountdi2 \
126		popcountsi2 \
127		popcountti2 \
128		powidf2 \
129		powisf2 \
130		powitf2 \
131		powixf2 \
132		subvdi3 \
133		subvsi3 \
134		subvti3 \
135		subtf3 \
136		trampoline_setup \
137		truncdfhf2 \
138		truncsfhf2 \
139		ucmpdi2 \
140		ucmpti2 \
141		udivdi3 \
142		udivmoddi4 \
143		udivmodsi4 \
144		udivmodti4 \
145		udivti3 \
146		umoddi3 \
147		umodsi3 \
148		umodti3
149
150.if ${RTARCH} != "arm"
151GEN_SRCS+=	adddf3 \
152		addsf3 \
153		divdf3 \
154		divsf3 \
155		divsi3 \
156		extendsfdf2 \
157		fixdfdi \
158		fixdfsi \
159		fixsfdi \
160		fixsfsi \
161		fixunsdfdi \
162		fixunssfdi \
163		floatsidf \
164		floatsisf \
165		muldf3 \
166		mulsf3 \
167		subdf3 \
168		subsf3 \
169		truncdfsf2 \
170		udivsi3
171.endif
172
173.if ${RTARCH} == "i386"
174SRCS+=	floatdidf.c \
175	floatdisf.c \
176	floatdixf.c \
177	floatundidf.c \
178	floatundisf.c \
179	floatundixf.c
180.else
181GEN_SRCS+=	floatdidf \
182		floatdisf \
183		floatdixf \
184		floatundidf \
185		floatundisf \
186		floatundixf
187.endif
188
189.for file in ${GEN_SRCS}
190.	if exists(${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}/${file}.S)
191SRCS+=	${file}.S
192.	else
193SRCS+=	${file}.c
194.	endif
195.endfor
196
197.if ${RTARCH} == "aarch64"
198SRCS+=	comparetf2.c \
199	extenddftf2.c \
200	extendsftf2.c \
201	fixtfdi.c \
202	fixtfsi.c \
203	fixtfti.c \
204	fixunstfdi.c \
205	fixunstfsi.c \
206	fixunstfti.c \
207	floatditf.c \
208	floatsitf.c \
209	floattitf.c \
210	floatunditf.c \
211	floatunsitf.c \
212	floatuntitf.c \
213	multc3.c \
214	trunctfdf2.c \
215	trunctfsf2.c
216
217# Prepare multiple versions of the LSE-helper
218CPPFLAGS+=-DHAS_ASM_LSE
219.for pat in cas swp ldadd ldclr ldeor ldset
220.  for size in 1 2 4 8 16
221.    for model in 1 2 3 4
222.      if "${pat}" == "cas" || "${size}" != "16"
223outline_atomic_${pat}${size}_${model}.S: Makefile ${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}/lse.S
224	@echo "#define L_${pat}\n#define SIZE ${size}\n#define MODEL ${model}\n" > $@.tmp
225	@cat ${.CURDIR}/../../llvm/compiler-rt/lib/builtins/${RTARCH}/lse.S >> $@.tmp
226	@mv $@.tmp $@
227
228SRCS+=	outline_atomic_${pat}${size}_${model}.S
229.      endif
230.    endfor
231.  endfor
232.endfor
233
234.endif
235
236.if ${RTARCH} == "arm"
237SRCS+=	aeabi_cdcmp.S \
238	aeabi_cdcmpeq_check_nan.c \
239	aeabi_cfcmp.S \
240	aeabi_cfcmpeq_check_nan.c \
241	aeabi_dcmp.S \
242	aeabi_div0.c \
243	aeabi_drsub.c \
244	aeabi_fcmp.S \
245	aeabi_frsub.c \
246	aeabi_ldivmod.S \
247	aeabi_memcmp.S \
248	aeabi_memcpy.S \
249	aeabi_memmove.S \
250	aeabi_memset.S \
251	aeabi_uldivmod.S \
252	switch16.S \
253	switch32.S \
254	switch8.S \
255	switchu8.S \
256	sync_fetch_and_add_4.S \
257	sync_fetch_and_add_8.S \
258	sync_fetch_and_and_4.S \
259	sync_fetch_and_and_8.S \
260	sync_fetch_and_max_4.S \
261	sync_fetch_and_max_8.S \
262	sync_fetch_and_min_4.S \
263	sync_fetch_and_min_8.S \
264	sync_fetch_and_nand_4.S \
265	sync_fetch_and_nand_8.S \
266	sync_fetch_and_or_4.S \
267	sync_fetch_and_or_8.S \
268	sync_fetch_and_sub_4.S \
269	sync_fetch_and_sub_8.S \
270	sync_fetch_and_umax_4.S \
271	sync_fetch_and_umax_8.S \
272	sync_fetch_and_umin_4.S \
273	sync_fetch_and_umin_8.S \
274	sync_fetch_and_xor_4.S \
275	sync_fetch_and_xor_8.S \
276	sync_synchronize.S
277.endif
278
279.if ${RTARCH} == "mips64" || ${RTARCH} == "mips64el"
280SRCS+=	comparetf2.c \
281	extenddftf2.c \
282	extendsftf2.c \
283	fixtfdi.c \
284	fixtfsi.c \
285	fixtfti.c \
286	fixunstfdi.c \
287	fixunstfsi.c \
288	fixunstfti.c \
289	floatditf.c \
290	floatsitf.c \
291	floattitf.c \
292	floatunditf.c \
293	floatunsitf.c \
294	floatuntitf.c \
295	multc3.c \
296	trunctfdf2.c \
297	trunctfsf2.c
298.endif
299
300.if ${RTARCH} == "ppc"
301# Omit "double-double" functions since long double is the same as
302# double on OpenBSD.
303SRCS+=	atomic_lock_free.c
304.endif
305
306.if ${RTARCH} == "riscv"
307SRCS+=	comparetf2.c \
308	extenddftf2.c \
309	extendsftf2.c \
310	fixtfdi.c \
311	fixtfsi.c \
312	fixtfti.c \
313	fixunstfdi.c \
314	fixunstfsi.c \
315	fixunstfti.c \
316	floatditf.c \
317	floatsitf.c \
318	floattitf.c \
319	floatunditf.c \
320	floatunsitf.c \
321	floatuntitf.c \
322	multc3.c \
323	restore.S \
324	save.S \
325	trunctfdf2.c \
326	trunctfsf2.c
327.endif
328
329.if ${RTARCH} == "sparc64"
330SRCS+=	comparetf2.c \
331	extenddftf2.c \
332	extendsftf2.c \
333	fixtfdi.c \
334	fixtfsi.c \
335	fixtfti.c \
336	fixunstfdi.c \
337	fixunstfsi.c \
338	fixunstfti.c \
339	floatditf.c \
340	floatsitf.c \
341	floattitf.c \
342	floatunditf.c \
343	floatunsitf.c \
344	floatuntitf.c \
345	multc3.c \
346	trunctfdf2.c \
347	trunctfsf2.c
348.endif
349
350.include <bsd.lib.mk>
351
352.else
353NOPROG=
354.include <bsd.prog.mk>
355.endif
356