@@ -3,8 +3,8 @@ package builder
3
3
import (
4
4
"os"
5
5
"path/filepath"
6
- "strings"
7
6
7
+ "github.com/tinygo-org/tinygo/compileopts"
8
8
"github.com/tinygo-org/tinygo/goenv"
9
9
)
10
10
@@ -132,6 +132,38 @@ var genericBuiltins = []string{
132
132
"umodti3.c" ,
133
133
}
134
134
135
+ // These are the GENERIC_TF_SOURCES as of LLVM 18.
136
+ // They are not needed on all platforms (32-bit platforms usually don't need
137
+ // these) but they seem to compile fine so it's easier to include them.
138
+ var genericBuiltins128 = []string {
139
+ "addtf3.c" ,
140
+ "comparetf2.c" ,
141
+ "divtc3.c" ,
142
+ "divtf3.c" ,
143
+ "extenddftf2.c" ,
144
+ "extendhftf2.c" ,
145
+ "extendsftf2.c" ,
146
+ "fixtfdi.c" ,
147
+ "fixtfsi.c" ,
148
+ "fixtfti.c" ,
149
+ "fixunstfdi.c" ,
150
+ "fixunstfsi.c" ,
151
+ "fixunstfti.c" ,
152
+ "floatditf.c" ,
153
+ "floatsitf.c" ,
154
+ "floattitf.c" ,
155
+ "floatunditf.c" ,
156
+ "floatunsitf.c" ,
157
+ "floatuntitf.c" ,
158
+ "multc3.c" ,
159
+ "multf3.c" ,
160
+ "powitf2.c" ,
161
+ "subtf3.c" ,
162
+ "trunctfdf2.c" ,
163
+ "trunctfhf2.c" ,
164
+ "trunctfsf2.c" ,
165
+ }
166
+
135
167
var aeabiBuiltins = []string {
136
168
"arm/aeabi_cdcmp.S" ,
137
169
"arm/aeabi_cdcmpeq_check_nan.c" ,
@@ -190,11 +222,13 @@ var libCompilerRT = Library{
190
222
},
191
223
librarySources : func (target string ) ([]string , error ) {
192
224
builtins := append ([]string {}, genericBuiltins ... ) // copy genericBuiltins
193
- if strings .HasPrefix (target , "arm" ) || strings .HasPrefix (target , "thumb" ) {
225
+ switch compileopts .CanonicalArchName (target ) {
226
+ case "arm" :
194
227
builtins = append (builtins , aeabiBuiltins ... )
195
- }
196
- if strings .HasPrefix (target , "avr" ) {
228
+ case "avr" :
197
229
builtins = append (builtins , avrBuiltins ... )
230
+ case "x86_64" , "aarch64" , "riscv64" : // any 64-bit arch
231
+ builtins = append (builtins , genericBuiltins128 ... )
198
232
}
199
233
return builtins , nil
200
234
},
0 commit comments