Skip to content

Commit 4ba941e

Browse files
W-M-Rxiaoxiang781216
authored andcommitted
libbuiltin: Simplify makefile writing
Create a separate bin folder to place the generated .o files Signed-off-by: wangmingrong1 <[email protected]>
1 parent d0680fd commit 4ba941e

File tree

2 files changed

+37
-139
lines changed

2 files changed

+37
-139
lines changed

libs/libbuiltin/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020

2121
include $(TOPDIR)/Make.defs
2222

23-
ifeq ($(CONFIG_BUILTIN_COMPILER_RT),y)
24-
include compiler-rt/Make.defs
25-
endif
26-
2723
BIN ?= libbuiltin$(LIBEXT)
2824
BINDIR ?= bin
2925

3026
KBIN = libkbuiltin$(LIBEXT)
3127
KBINDIR = kbin
3228

29+
ifeq ($(CONFIG_BUILTIN_COMPILER_RT),y)
30+
include compiler-rt/Make.defs
31+
endif
32+
3333
AOBJS = $(addprefix $(BINDIR)$(DELIM), $(ASRCS:.S=$(OBJEXT)))
3434
COBJS = $(addprefix $(BINDIR)$(DELIM), $(CSRCS:.c=$(OBJEXT)))
3535
CXXOBJS = $(addprefix $(BINDIR)$(DELIM), $(CXXSRCS:.cxx=$(OBJEXT)))
@@ -79,7 +79,7 @@ clean:
7979
$(Q) $(MAKE) -C bin clean
8080
$(Q) $(MAKE) -C kbin clean
8181

82-
distclean: clean
82+
distclean:: clean
8383
$(Q) $(MAKE) -C bin distclean
8484
$(Q) $(MAKE) -C kbin distclean
8585
$(call DELFILE, .depend)

libs/libbuiltin/compiler-rt/Make.defs

Lines changed: 32 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ LIBBUILTIN += compiler-rt
2424

2525
COMPILER_RT_VERSION=$(CONFIG_COMPILER_RT_VERSION)
2626

27+
ifeq ($(CONFIG_ARCH_ARM),y)
28+
ARCH = arm
29+
else ifeq ($(CONFIG_ARCH_RISCV),y)
30+
ARCH = riscv
31+
else ifeq ($(CONFIG_ARCH_X86_64),y)
32+
ARCH = x86_64
33+
else ifeq ($(CONFIG_ARCH_ARM64),y)
34+
ARCH = aarch64
35+
endif
36+
2737
ifeq ($(wildcard compiler-rt/compiler-rt/lib),)
2838
compiler-rt-$(COMPILER_RT_VERSION).src.tar.xz:
2939
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(COMPILER_RT_VERSION),$@)
@@ -34,162 +44,50 @@ compiler-rt/compiler-rt: compiler-rt-$(COMPILER_RT_VERSION).src.tar.xz
3444
$(call DELDIR, $<)
3545

3646
compiler-rt: compiler-rt/compiler-rt
47+
$(Q) mkdir $(BINDIR)/compiler-rt \
48+
$(BINDIR)/compiler-rt/compiler-rt \
49+
$(BINDIR)/compiler-rt/compiler-rt/lib \
50+
$(BINDIR)/compiler-rt/compiler-rt/lib/builtins \
51+
$(BINDIR)/compiler-rt/compiler-rt/lib/builtins/$(ARCH) \
52+
$(BINDIR)/compiler-rt/compiler-rt/lib/profile
53+
3754
endif
3855

56+
distclean::
57+
$(call DELDIR, $(BINDIR)/compiler-rt)
58+
3959
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/include
4060
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins
61+
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH}
4162
FLAGS += -Wno-shift-count-negative -Wno-constant-conversion -Wshift-count-overflow
4263
FLAGS += -Wno-undef -Wno-incompatible-pointer-types -Wno-visibility -Wno-macro-redefined
4364

4465
################# Builtin Library #################
4566

46-
# Files related to arithmetic operations
47-
CSRCS += absvdi2.c absvsi2.c absvti2.c adddf3.c addtf3.c addvdi3.c addvsi3.c addvti3.c \
48-
muldc3.c muldf3.c mulodi4.c mulosi4.c muloti4.c mulsc3.c mulsf3.c multc3.c multf3.c \
49-
multi3.c mulvdi3.c mulvsi3.c mulvti3.c mulxc3.c negdf2.c negdi2.c negsf2.c negti2.c \
50-
negvdi2.c negvsi2.c negvti2.c subdf3.c subsf3.c subtf3.c subvdi3.c subvsi3.c subvti3.c
51-
52-
# Floating point processing related files
53-
CSRCS += floatdidf.c floatdisf.c floatditf.c floatdixf.c floatsidf.c floatsisf.c floatsitf.c \
54-
floattidf.c floattisf.c floattitf.c floattixf.c floatunditf.c \
55-
floatunsidf.c floatunsisf.c floatunsitf.c floatuntidf.c floatuntisf.c \
56-
floatuntitf.c floatuntixf.c
57-
58-
# Convert and expand related files
59-
CSRCS += fixtfdi.c fixtfsi.c fixtfti.c fixunsdfdi.c fixunsdfsi.c fixunsdfti.c fixunssfdi.c \
60-
fixunssfsi.c fixunssfti.c fixunstfdi.c fixunstfsi.c fixunstfti.c fixunsxfdi.c fixunsxfsi.c \
61-
fixunsxfti.c fixxfdi.c fixxfti.c extenddftf2.c extendhfsf2.c extendhftf2.c extendsfdf2.c \
62-
extendsftf2.c truncdfhf2.c truncdfsf2.c truncsfhf2.c \
63-
trunctfdf2.c trunctfhf2.c trunctfsf2.c
64-
65-
ifeq ($(CONFIG_COMPILER_RT_HAS_BFLOAT16),y)
66-
CSRCS += truncdfbf2.c truncsfbf2.c
67-
endif
68-
69-
# Bit manipulation related files
70-
CSRCS += ashldi3.c ashlti3.c ashrdi3.c ashrti3.c \
71-
clzti2.c ctzdi2.c ctzsi2.c ctzti2.c lshrdi3.c lshrti3.c popcountdi2.c popcountsi2.c \
72-
popcountti2.c paritydi2.c paritysi2.c parityti2.c
73-
74-
# Files related to division and modulo operations
75-
CSRCS += divdc3.c divdf3.c divdi3.c divmoddi4.c divmodti4.c divsc3.c divsf3.c \
76-
divtc3.c divtf3.c divti3.c divxc3.c moddi3.c modti3.c udivdi3.c udivmoddi4.c \
77-
udivmodti4.c udivti3.c umoddi3.c umodti3.c
78-
79-
# Files related to atomic operations
80-
CSRCS += atomic.c atomic_flag_clear.c atomic_flag_clear_explicit.c atomic_flag_test_and_set.c \
81-
atomic_flag_test_and_set_explicit.c atomic_signal_fence.c atomic_thread_fence.c
82-
83-
# Other function related files
84-
CSRCS += apple_versioning.c clear_cache.c cmpdi2.c cmpti2.c comparedf2.c comparetf2.c \
85-
cpu_model.c emutls.c enable_execute_stack.c eprintf.c fp_mode.c gcc_personality_v0.c \
86-
int_util.c os_version_check.c trampoline_setup.c ucmpdi2.c ucmpti2.c powidf2.c powisf2.c \
87-
powitf2.c powixf2.c
67+
CSRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/*.c)
68+
ASRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/$(ARCH)/*.S)
69+
CSRCS += $(wildcard compiler-rt/compiler-rt/lib/builtins/$(ARCH)/*.c)
8870

89-
# Bit manipulation related arch
90-
ifeq ($(CONFIG_ARCH_ARM),y)
91-
ARCH = arm
92-
# Arithmetic Operations
93-
ASRCS += adddf3vfp.S addsf3.S addsf3vfp.S divmodsi4.S divsi3.S modsi3.S subdf3vfp.S subsf3vfp.S \
94-
muldf3vfp.S mulsf3vfp.S negdf2vfp.S negsf2vfp.S
95-
96-
# Floating-Point Operations
97-
ASRCS += comparesf2.S eqdf2vfp.S eqsf2vfp.S extendsfdf2vfp.S fixdfsivfp.S fixsfsivfp.S \
98-
fixunsdfsivfp.S fixunssfsivfp.S floatsidfvfp.S floatsisfvfp.S floatunssidfvfp.S \
99-
floatunssisfvfp.S gedf2vfp.S gesf2vfp.S gtdf2vfp.S gtsf2vfp.S ledf2vfp.S lesf2vfp.S \
100-
ltdf2vfp.S ltsf2vfp.S nedf2vfp.S nesf2vfp.S truncdfsf2vfp.S unorddf2vfp.S unordsf2vfp.S
101-
102-
# Synchronization Operations
103-
ASRCS += sync_fetch_and_add_4.S sync_fetch_and_add_8.S sync_fetch_and_and_4.S sync_fetch_and_and_8.S \
104-
sync_fetch_and_max_4.S sync_fetch_and_max_8.S sync_fetch_and_min_4.S sync_fetch_and_min_8.S \
105-
sync_fetch_and_nand_4.S sync_fetch_and_nand_8.S sync_fetch_and_or_4.S sync_fetch_and_or_8.S \
106-
sync_fetch_and_sub_4.S sync_fetch_and_sub_8.S sync_fetch_and_umax_4.S sync_fetch_and_umax_8.S \
107-
sync_fetch_and_umin_4.S sync_fetch_and_umin_8.S sync_fetch_and_xor_4.S sync_fetch_and_xor_8.S \
108-
sync_synchronize.S
109-
# Memory Operations
110-
ASRCS += aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S restore_vfp_d8_d15_regs.S \
111-
save_vfp_d8_d15_regs.S
112-
113-
# Division and Modulus Operations
114-
ASRCS += aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S udivmodsi4.S udivsi3.S umodsi3.S
115-
116-
# Bitwise and Other Operations
117-
ASRCS += bswapdi2.S bswapsi2.S chkstk.S clzdi2.S clzsi2.S
118-
119-
# Branch and Control Flow
120-
ASRCS += switch16.S switch32.S switch8.S switchu8.S
121-
122-
CSRCS += aeabi_cdcmpeq_check_nan.c aeabi_cfcmpeq_check_nan.c aeabi_div0.c aeabi_drsub.c aeabi_frsub.c
123-
else
124-
CSRCS += addsf3.c divsi3.c modsi3.c
125-
CSRCS += bswapdi2.c bswapsi2.c clzdi2.c clzsi2.c
126-
CSRCS += divmodsi4.c udivmodsi4.c udivsi3.c umodsi3.c
127-
CSRCS += comparesf2.c
71+
ifeq ($(CONFIG_COMPILER_RT_HAS_BFLOAT16),)
72+
BFLOAT16_SRCS := compiler-rt/compiler-rt/lib/builtins/truncdfbf2.c
73+
BFLOAT16_SRCS += compiler-rt/compiler-rt/lib/builtins/truncsfbf2.c
74+
CSRCS := $(filter-out $(BFLOAT16_SRCS), $(CSRCS))
12875
endif
12976

130-
ifeq ($(CONFIG_ARCH_ARM64),y)
131-
ARCH = aarch64
132-
ASRCS += chkstk.S lse.S
133-
CSRCS += fp_mode.c
134-
endif
135-
136-
ifeq ($(CONFIG_ARCH_RISCV),y)
137-
ARCH = riscv
138-
ASRCS += muldi3.S mulsi3.S restore.S save.S
139-
CSRCS += fp_mode.c
140-
else
141-
CSRCS += muldi3.c
142-
endif
143-
144-
ifeq ($(CONFIG_ARCH_X86_64),y)
145-
ARCH = x86_64
146-
ASRCS += chkstk2.S chkstk.S floatundidf.S floatundisf.S floatundixf.S
147-
CSRCS += floatdidf.c floatdisf.c floatdixf.c
148-
else
149-
CSRCS += floatundidf.c floatundisf.c floatundixf.c
150-
endif
77+
################# Profile Library #################
15178

15279
ifeq ($(CONFIG_COMPILER_RT_PROFILE),y)
153-
154-
# Include paths
15580
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile
156-
157-
# Suppress specific warnings
15881
FLAGS += -Wno-cleardeprecated-pragma -Wno-deprecated-pragma -Wno-incompatible-pointer-types
15982
FLAGS += -Wno-shadow -Wno-strict-prototypes -Wno-undef -Wno-unknown-warning-option
160-
161-
# Define compiler-specific macros
16283
FLAGS += -DCOMPILER_RT_HAS_UNAME
163-
164-
# Disable code coverage analysis for the library
16584
FLAGS += -fno-profile-generate
16685

167-
# Profile support source files
168-
CSRCS += GCDAProfiling.c InstrProfilingBuffer.c InstrProfiling.c InstrProfilingFile.c InstrProfilingInternal.c
169-
CSRCS += InstrProfilingMerge.c InstrProfilingMergeFile.c InstrProfilingNameVar.c
170-
CSRCS += InstrProfilingUtil.c InstrProfilingValue.c InstrProfilingVersionVar.c InstrProfilingWriter.c
171-
CPPSRCS += InstrProfilingRuntime.cpp
172-
173-
# Profile platform support
174-
CSRCS += InstrProfilingPlatform.c
175-
176-
# Dependency and search paths
177-
DEPPATH += --dep-path compiler-rt/compiler-rt/lib/profile
178-
VPATH += :compiler-rt/compiler-rt/lib/profile
179-
86+
CSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.c)
87+
CPPSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.cpp)
88+
CSRCS += compiler-rt/InstrProfilingPlatform.c
18089
endif
18190

182-
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH}
183-
18491
AFLAGS += $(FLAGS)
18592
CFLAGS += $(FLAGS)
18693
CXXFLAGS += $(FLAGS)
187-
188-
DEPPATH += --dep-path compiler-rt/compiler-rt/lib/builtins/${ARCH}
189-
VPATH += :compiler-rt/compiler-rt/lib/builtins/${ARCH}
190-
191-
DEPPATH += --dep-path compiler-rt/compiler-rt/lib/builtins
192-
VPATH += :compiler-rt/compiler-rt/lib/builtins
193-
194-
DEPPATH += --dep-path compiler-rt
195-
VPATH += :compiler-rt

0 commit comments

Comments
 (0)