Skip to content

Commit 55f7d21

Browse files
aykevldeadprogram
authored andcommitted
builtins: add GENERIC_TF_SOURCES
This addes GENERIC_TF_SOURCES, which contains long double floating point builtins (80 bit, 128 bit, etc). This is needed for full printf support.
1 parent 841abb0 commit 55f7d21

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

builder/builtins.go

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package builder
33
import (
44
"os"
55
"path/filepath"
6-
"strings"
76

7+
"github.com/tinygo-org/tinygo/compileopts"
88
"github.com/tinygo-org/tinygo/goenv"
99
)
1010

@@ -132,6 +132,38 @@ var genericBuiltins = []string{
132132
"umodti3.c",
133133
}
134134

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+
135167
var aeabiBuiltins = []string{
136168
"arm/aeabi_cdcmp.S",
137169
"arm/aeabi_cdcmpeq_check_nan.c",
@@ -190,11 +222,13 @@ var libCompilerRT = Library{
190222
},
191223
librarySources: func(target string) ([]string, error) {
192224
builtins := append([]string{}, genericBuiltins...) // copy genericBuiltins
193-
if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") {
225+
switch compileopts.CanonicalArchName(target) {
226+
case "arm":
194227
builtins = append(builtins, aeabiBuiltins...)
195-
}
196-
if strings.HasPrefix(target, "avr") {
228+
case "avr":
197229
builtins = append(builtins, avrBuiltins...)
230+
case "x86_64", "aarch64", "riscv64": // any 64-bit arch
231+
builtins = append(builtins, genericBuiltins128...)
198232
}
199233
return builtins, nil
200234
},

0 commit comments

Comments
 (0)