@@ -3,6 +3,7 @@ package builder
3
3
import (
4
4
"os"
5
5
"path/filepath"
6
+ "strings"
6
7
7
8
"github.com/tinygo-org/tinygo/goenv"
8
9
)
@@ -41,91 +42,23 @@ var Picolibc = Library{
41
42
},
42
43
sourceDir : func () string { return filepath .Join (goenv .Get ("TINYGOROOT" ), "lib/picolibc/newlib" ) },
43
44
librarySources : func (target string ) ([]string , error ) {
44
- return picolibcSources , nil
45
+ sources := append ([]string (nil ), picolibcSources ... )
46
+ if ! strings .HasPrefix (target , "avr" ) {
47
+ // Small chips without long jumps can't compile many files (printf,
48
+ // pow, etc). Therefore exclude those source files for those chips.
49
+ // Unfortunately it's difficult to exclude only some chips, so this
50
+ // excludes those files on all AVR chips for now.
51
+ // More information:
52
+ // https://github.com/llvm/llvm-project/issues/67042
53
+ sources = append (sources , picolibcSourcesLarge ... )
54
+ }
55
+ return sources , nil
45
56
},
46
57
}
47
58
48
59
var picolibcSources = []string {
49
60
"../../picolibc-stdio.c" ,
50
61
51
- // srcs_tinystdio
52
- "libc/tinystdio/asprintf.c" ,
53
- "libc/tinystdio/bufio.c" ,
54
- "libc/tinystdio/clearerr.c" ,
55
- "libc/tinystdio/ecvt_r.c" ,
56
- "libc/tinystdio/ecvt.c" ,
57
- "libc/tinystdio/ecvtf_r.c" ,
58
- "libc/tinystdio/ecvtf.c" ,
59
- "libc/tinystdio/fcvt.c" ,
60
- "libc/tinystdio/fcvt_r.c" ,
61
- "libc/tinystdio/fcvtf.c" ,
62
- "libc/tinystdio/fcvtf_r.c" ,
63
- "libc/tinystdio/gcvt.c" ,
64
- "libc/tinystdio/gcvtf.c" ,
65
- "libc/tinystdio/fclose.c" ,
66
- "libc/tinystdio/fdevopen.c" ,
67
- "libc/tinystdio/feof.c" ,
68
- "libc/tinystdio/ferror.c" ,
69
- "libc/tinystdio/fflush.c" ,
70
- "libc/tinystdio/fgetc.c" ,
71
- "libc/tinystdio/fgets.c" ,
72
- "libc/tinystdio/fileno.c" ,
73
- "libc/tinystdio/filestrget.c" ,
74
- "libc/tinystdio/filestrput.c" ,
75
- "libc/tinystdio/filestrputalloc.c" ,
76
- "libc/tinystdio/fmemopen.c" ,
77
- "libc/tinystdio/fprintf.c" ,
78
- "libc/tinystdio/fputc.c" ,
79
- "libc/tinystdio/fputs.c" ,
80
- "libc/tinystdio/fread.c" ,
81
- //"libc/tinystdio/freopen.c", // crashes with AVR, see: https://github.com/picolibc/picolibc/pull/369
82
- "libc/tinystdio/fscanf.c" ,
83
- "libc/tinystdio/fseek.c" ,
84
- "libc/tinystdio/fseeko.c" ,
85
- "libc/tinystdio/ftell.c" ,
86
- "libc/tinystdio/ftello.c" ,
87
- "libc/tinystdio/fwrite.c" ,
88
- "libc/tinystdio/getchar.c" ,
89
- "libc/tinystdio/gets.c" ,
90
- "libc/tinystdio/matchcaseprefix.c" ,
91
- "libc/tinystdio/mktemp.c" ,
92
- "libc/tinystdio/perror.c" ,
93
- "libc/tinystdio/printf.c" ,
94
- "libc/tinystdio/putchar.c" ,
95
- "libc/tinystdio/puts.c" ,
96
- "libc/tinystdio/rewind.c" ,
97
- "libc/tinystdio/scanf.c" ,
98
- "libc/tinystdio/setbuf.c" ,
99
- "libc/tinystdio/setbuffer.c" ,
100
- "libc/tinystdio/setlinebuf.c" ,
101
- "libc/tinystdio/setvbuf.c" ,
102
- "libc/tinystdio/snprintf.c" ,
103
- "libc/tinystdio/sprintf.c" ,
104
- "libc/tinystdio/snprintfd.c" ,
105
- "libc/tinystdio/snprintff.c" ,
106
- "libc/tinystdio/sprintff.c" ,
107
- "libc/tinystdio/sprintfd.c" ,
108
- "libc/tinystdio/sscanf.c" ,
109
- "libc/tinystdio/strfromf.c" ,
110
- "libc/tinystdio/strfromd.c" ,
111
- "libc/tinystdio/strtof.c" ,
112
- "libc/tinystdio/strtof_l.c" ,
113
- "libc/tinystdio/strtod.c" ,
114
- "libc/tinystdio/strtod_l.c" ,
115
- "libc/tinystdio/ungetc.c" ,
116
- "libc/tinystdio/vasprintf.c" ,
117
- "libc/tinystdio/vfiprintf.c" ,
118
- "libc/tinystdio/vfprintf.c" ,
119
- "libc/tinystdio/vfprintff.c" ,
120
- "libc/tinystdio/vfscanf.c" ,
121
- "libc/tinystdio/vfiscanf.c" ,
122
- "libc/tinystdio/vfscanff.c" ,
123
- "libc/tinystdio/vprintf.c" ,
124
- "libc/tinystdio/vscanf.c" ,
125
- "libc/tinystdio/vsscanf.c" ,
126
- "libc/tinystdio/vsnprintf.c" ,
127
- "libc/tinystdio/vsprintf.c" ,
128
-
129
62
"libc/string/bcmp.c" ,
130
63
"libc/string/bcopy.c" ,
131
64
"libc/string/bzero.c" ,
@@ -229,6 +162,87 @@ var picolibcSources = []string{
229
162
"libc/string/wmempcpy.c" ,
230
163
"libc/string/wmemset.c" ,
231
164
"libc/string/xpg_strerror_r.c" ,
165
+ }
166
+
167
+ // Parts of picolibc that are too large for small AVRs.
168
+ var picolibcSourcesLarge = []string {
169
+ // srcs_tinystdio
170
+ "libc/tinystdio/asprintf.c" ,
171
+ "libc/tinystdio/bufio.c" ,
172
+ "libc/tinystdio/clearerr.c" ,
173
+ "libc/tinystdio/ecvt_r.c" ,
174
+ "libc/tinystdio/ecvt.c" ,
175
+ "libc/tinystdio/ecvtf_r.c" ,
176
+ "libc/tinystdio/ecvtf.c" ,
177
+ "libc/tinystdio/fcvt.c" ,
178
+ "libc/tinystdio/fcvt_r.c" ,
179
+ "libc/tinystdio/fcvtf.c" ,
180
+ "libc/tinystdio/fcvtf_r.c" ,
181
+ "libc/tinystdio/gcvt.c" ,
182
+ "libc/tinystdio/gcvtf.c" ,
183
+ "libc/tinystdio/fclose.c" ,
184
+ "libc/tinystdio/fdevopen.c" ,
185
+ "libc/tinystdio/feof.c" ,
186
+ "libc/tinystdio/ferror.c" ,
187
+ "libc/tinystdio/fflush.c" ,
188
+ "libc/tinystdio/fgetc.c" ,
189
+ "libc/tinystdio/fgets.c" ,
190
+ "libc/tinystdio/fileno.c" ,
191
+ "libc/tinystdio/filestrget.c" ,
192
+ "libc/tinystdio/filestrput.c" ,
193
+ "libc/tinystdio/filestrputalloc.c" ,
194
+ "libc/tinystdio/fmemopen.c" ,
195
+ "libc/tinystdio/fprintf.c" ,
196
+ "libc/tinystdio/fputc.c" ,
197
+ "libc/tinystdio/fputs.c" ,
198
+ "libc/tinystdio/fread.c" ,
199
+ //"libc/tinystdio/freopen.c", // crashes with AVR, see: https://github.com/picolibc/picolibc/pull/369
200
+ "libc/tinystdio/fscanf.c" ,
201
+ "libc/tinystdio/fseek.c" ,
202
+ "libc/tinystdio/fseeko.c" ,
203
+ "libc/tinystdio/ftell.c" ,
204
+ "libc/tinystdio/ftello.c" ,
205
+ "libc/tinystdio/fwrite.c" ,
206
+ "libc/tinystdio/getchar.c" ,
207
+ "libc/tinystdio/gets.c" ,
208
+ "libc/tinystdio/matchcaseprefix.c" ,
209
+ "libc/tinystdio/mktemp.c" ,
210
+ "libc/tinystdio/perror.c" ,
211
+ "libc/tinystdio/printf.c" ,
212
+ "libc/tinystdio/putchar.c" ,
213
+ "libc/tinystdio/puts.c" ,
214
+ "libc/tinystdio/rewind.c" ,
215
+ "libc/tinystdio/scanf.c" ,
216
+ "libc/tinystdio/setbuf.c" ,
217
+ "libc/tinystdio/setbuffer.c" ,
218
+ "libc/tinystdio/setlinebuf.c" ,
219
+ "libc/tinystdio/setvbuf.c" ,
220
+ "libc/tinystdio/snprintf.c" ,
221
+ "libc/tinystdio/sprintf.c" ,
222
+ "libc/tinystdio/snprintfd.c" ,
223
+ "libc/tinystdio/snprintff.c" ,
224
+ "libc/tinystdio/sprintff.c" ,
225
+ "libc/tinystdio/sprintfd.c" ,
226
+ "libc/tinystdio/sscanf.c" ,
227
+ "libc/tinystdio/strfromf.c" ,
228
+ "libc/tinystdio/strfromd.c" ,
229
+ "libc/tinystdio/strtof.c" ,
230
+ "libc/tinystdio/strtof_l.c" ,
231
+ "libc/tinystdio/strtod.c" ,
232
+ "libc/tinystdio/strtod_l.c" ,
233
+ "libc/tinystdio/ungetc.c" ,
234
+ "libc/tinystdio/vasprintf.c" ,
235
+ "libc/tinystdio/vfiprintf.c" ,
236
+ "libc/tinystdio/vfprintf.c" ,
237
+ "libc/tinystdio/vfprintff.c" ,
238
+ "libc/tinystdio/vfscanf.c" ,
239
+ "libc/tinystdio/vfiscanf.c" ,
240
+ "libc/tinystdio/vfscanff.c" ,
241
+ "libc/tinystdio/vprintf.c" ,
242
+ "libc/tinystdio/vscanf.c" ,
243
+ "libc/tinystdio/vsscanf.c" ,
244
+ "libc/tinystdio/vsnprintf.c" ,
245
+ "libc/tinystdio/vsprintf.c" ,
232
246
233
247
"libm/common/sf_finite.c" ,
234
248
"libm/common/sf_copysign.c" ,
0 commit comments