8000 Shrink non-FULL builds (SAMDs mostly) · unwiredben/circuitpython@eca9304 · GitHub
[go: up one dir, main page]

Skip to content

Commit eca9304

Browse files
committed
Shrink non-FULL builds (SAMDs mostly)
* Use 0 bytes for QSTR hash. Fixes adafruit#10151 * Update libgcc used on SAMD21 to 14.2. Reduces test build by over 100 bytes. * Turn off 'd' typecode support on non-full builds.
1 parent ef8501e commit eca9304

File tree

7 files changed

+23
-1
lines changed

7 files changed

+23
-1
lines changed

ports/atmel-samd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ CFLAGS += \
117117
-msoft-float \
118118
-mfloat-abi=soft \
119119
-DSAMD21
120-
LIBS := libs/libgcc-12.1.0-Os-v6-m-nofp.a -lc
120+
LIBS := libs/libgcc-14.2.0-Os-v6-m-nofp.a -lc
121121
else
122122
LIBS := -lgcc -lc
123123
endif

ports/atmel-samd/boards/adafruit_trrs_trinkey_m0/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@
4040
// no PA29
4141
#define IGNORE_PIN_PA30 1
4242
#define IGNORE_PIN_PA31 1
43+
44+
// A couple Learn examples do `array.array('d', ...)` so enable it.
45+
#define MICROPY_PY_DOUBLE_TYPECODE 1
Binary file not shown.
Binary file not shown.

py/binary.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,10 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) {
289289
#if MICROPY_PY_BUILTINS_FLOAT
290290
case 'f':
291291
return mp_obj_new_float_from_f(((float *)p)[index]);
292+
#if MICROPY_PY_DOUBLE_TYPECODE
292293
case 'd':
293294
return mp_obj_new_float_from_d(((double *)p)[index]);
295+
#endif
294296
#endif
295297
// CIRCUITPY-CHANGE: non-standard typecodes can be turned off
296298
#if MICROPY_NONSTANDARD_TYPECODES
@@ -367,13 +369,15 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
367369
float f;
368370
} fpu = {val};
369371
return mp_obj_new_float_from_f(fpu.f);
372+
#if MICROPY_PY_DOUBLE_TYPECODE
370373
} else if (val_type == 'd') {
371374
union {
372375
uint64_t i;
373376
double f;
374377
} fpu = {val};
375378
return mp_obj_new_float_from_d(fpu.f);
376379
#endif
380+
#endif
377381
} else if (is_signed(val_type)) {
378382
if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) {
379383
return mp_obj_new_int((mp_int_t)val);
@@ -445,6 +449,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
445449
val = fp_sp.i;
446450
break;
447451
}
452+
#if MICROPY_PY_DOUBLE_TYPECODE
448453
case 'd': {
449454
union {
450455
uint64_t i64;
@@ -463,6 +468,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
463468
break;
464469
}
465470
#endif
471+
#endif
466472
default: {
467473
// CIRCUITPY-CHANGE: add overflow checks
468474
bool signed_type = is_signed(val_type);
@@ -501,10 +507,12 @@ void mp_binary_set_val_array(char typecode, void *p, size_t index, mp_obj_t val_
501507
case 'f':
502508
((float *)p)[index] = mp_obj_get_float_to_f(val_in);
503509
break;
510+
#if MICROPY_PY_DOUBLE_TYPECODE
504511
case 'd':
505512
((double *)p)[index] = mp_obj_get_float_to_d(val_in);
506513
break;
507514
#endif
515+
#endif
508516
// CIRCUITPY-CHANGE: non-standard typecodes can be turned off
509517
#if MICROPY_NONSTANDARD_TYPECODES
510518
// Extension to CPython: array of objects
@@ -574,9 +582,11 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, size_t index, mp_i
574582
case 'f':
575583
((float *)p)[index] = (float)val;
576584
break;
585+
#if MICROPY_PY_DOUBLE_TYPECODE
577586
case 'd':
578587
((double *)p)[index] = (double)val;
579588
break;
589+
#endif
580590
#endif
581591
// CIRCUITPY-CHANGE: non-standard typecodes can be turned off
582592
#if MICROPY_NONSTANDARD_TYPECODES

py/circuitpy_mpconfig.h

Lines changed: 5 additions & 0 deletions
Ori 6D4E ginal file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ extern void common_hal_mcu_enable_interrupts(void);
7070
#define MICROPY_ERROR_REPORTING (CIRCUITPY_FULL_BUILD ? MICROPY_ERROR_REPORTING_NORMAL : MICROPY_ERROR_REPORTING_TERSE)
7171
#define MICROPY_FLOAT_HIGH_QUALITY_HASH (0)
7272
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
73+
#define MICROPY_PY_DOUBLE_TYPECODE (CIRCUITPY_FULL_BUILD ? 1 : 0)
7374
#define MICROPY_GC_ALLOC_THRESHOLD (0)
7475
#define MICROPY_GC_SPLIT_HEAP (1)
7576
#define MICROPY_GC_SPLIT_HEAP_AUTO (1)
@@ -141,7 +142,11 @@ extern void common_hal_mcu_enable_interrupts(void);
141142
#define MICROPY_PY_UCTYPES (0)
142143
#define MICROPY_PY___FILE__ (1)
143144

145+
#if CIRCUITPY_FULL_BUILD
144146
#define MICROPY_QSTR_BYTES_IN_HASH (1)
147+
#else
148+
#define MICROPY_QSTR_BYTES_IN_HASH (0)
149+
#endif
145150
#define MICROPY_REPL_AUTO_INDENT (1)
146151
#define MICROPY_REPL_EVENT_DRIVEN (0)
147152
#define MICROPY_STACK_CHECK (1)

py/mpconfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,10 @@ typedef double mp_float_t;
881881
#define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
882882
#endif
883883

884+
#ifndef MICROPY_PY_DOUBLE_TYPECODE
885+
#define MICROPY_PY_DOUBLE_TYPECODE (MICROPY_PY_BUILTINS_FLOAT)
886+
#endif
887+
884888
// Whether to use the native _Float16 for 16-bit float support
885889
#ifndef MICROPY_FLOAT_USE_NATIVE_FLT16
886890
#ifdef __FLT16_MAX__

0 commit comments

Comments
 (0)
0