@@ -24,6 +24,16 @@ LIBBUILTIN += compiler-rt
24
24
25
25
COMPILER_RT_VERSION=$(CONFIG_COMPILER_RT_VERSION)
26
26
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
+
27
37
ifeq ($(wildcard compiler-rt/compiler-rt/lib),)
28
38
compiler-rt-$(COMPILER_RT_VERSION).src.tar.xz:
29
39
$(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
34
44
$(call DELDIR, $<)
35
45
36
46
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
+
37
54
endif
38
55
56
+ distclean::
57
+ $(call DELDIR, $(BINDIR)/compiler-rt)
58
+
39
59
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/include
40
60
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins
61
+ FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH}
41
62
FLAGS += -Wno-shift-count-negative -Wno-constant-conversion -Wshift-count-overflow
42
63
FLAGS += -Wno-undef -Wno-incompatible-pointer-types -Wno-visibility -Wno-macro-redefined
43
64
44
65
################# Builtin Library #################
45
66
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)
88
70
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))
128
75
endif
129
76
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 #################
151
78
152
79
ifeq ($(CONFIG_COMPILER_RT_PROFILE),y)
153
-
154
- # Include paths
155
80
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile
156
-
157
- # Suppress specific warnings
158
81
FLAGS += -Wno-cleardeprecated-pragma -Wno-deprecated-pragma -Wno-incompatible-pointer-types
159
82
FLAGS += -Wno-shadow -Wno-strict-prototypes -Wno-undef -Wno-unknown-warning-option
160
-
161
- # Define compiler-specific macros
162
83
FLAGS += -DCOMPILER_RT_HAS_UNAME
163
-
164
- # Disable code coverage analysis for the library
165
84
FLAGS += -fno-profile-generate
166
85
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
180
89
endif
181
90
182
- FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins/${ARCH}
183
-
184
91
AFLAGS += $(FLAGS)
185
92
CFLAGS += $(FLAGS)
186
93
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