Skip to content

Commit 4d77633

Browse files
committed
Separate translate object control from LTO
1 parent 8d55919 commit 4d77633

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

ports/broadcom/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
107107
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
108108

109109
# BCM CLFAGS
110-
CFLAGS += -ffreestanding -nostartfiles -DMICROPY_HW_MCU_NAME="\"$(CHIP_VARIANT)\""
110+
CFLAGS += -nostartfiles -DMICROPY_HW_MCU_NAME="\"$(CHIP_VARIANT)\""
111111

112112

113113
OPTIMIZATION_FLAGS ?= -O3

ports/cxd56/mpconfigport.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ USB_HIGHSPEED = 1
33
# Number of USB endpoint pairs.
44
USB_NUM_ENDPOINT_PAIRS = 6
55

6+
CIRCUITPY_TRANSLATE_OBJECT = 1
7+
68
# Longints can be implemented as mpz, as longlong, or not
79
LONGINT_IMPL = MPZ
810

py/circuitpy_defns.mk

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ BASE_CFLAGS = \
5151
-DCIRCUITPY_SOFTWARE_SAFE_MODE=0x0ADABEEF \
5252
-DCIRCUITPY_CANARY_WORD=0xADAF00 \
5353
-DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
54-
-DCIRCUITPY_BOARD_ID="\"$(BOARD)\""
54+
-DCIRCUITPY_BOARD_ID="\"$(BOARD)\"" \
55+
--param max-inline-insns-single=500
5556

5657
# Use these flags to debug build times and header includes.
5758
# -ftime-report
@@ -73,6 +74,16 @@ else
7374
CFLAGS += -DCIRCUITPY_LTO=0
7475
endif
7576

77+
# Produce an object file for translate.c instead of including it in a header.
78+
# The header version can be optimized on non-LTO builds *if* inlining is allowed
79+
# otherwise, it blows up the binary sizes with tons of translate copies.
80+
ifeq ($(CIRCUITPY_LTO), 0)
81+
CIRCUITPY_TRANSLATE_OBJECT ?= 0
82+
else
83+
CIRCUITPY_TRANSLATE_OBJECT ?= 1
84+
endif
85+
CFLAGS += -DCIRCUITPY_TRANSLATE_OBJECT=$(CIRCUITPY_TRANSLATE_OBJECT)
86+
7687
###
7788
# Handle frozen modules.
7889

supervisor/shared/translate/translate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,6 @@ char *decompress(const compressed_string_t *compressed, char *decompressed) {
135135
return decompressed;
136136
}
137137

138-
#if CIRCUITPY_LTO == 1
138+
#if CIRCUITPY_TRANSLATE_OBJECT == 1
139139
#include "supervisor/shared/translate/translate_impl.h"
140140
#endif

supervisor/shared/translate/translate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
// that the build process will optimize this away and replace it with the
4444
// appropriate compressed data for each call site.
4545

46-
#if CIRCUITPY_LTO == 0
46+
#if CIRCUITPY_TRANSLATE_OBJECT == 0
4747
// Without LTO, we need to include a copy of this function in each compilation
4848
// unit so that the compile stage can do the optimization. Otherwise the linker
4949
// will leave this as a giant function and have each call site call into it.

supervisor/shared/translate/translate_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#include "supervisor/shared/translate/compressed_string.h"
3434

35-
#if CIRCUITPY_LTO == 0
35+
#if CIRCUITPY_TRANSLATE_OBJECT == 0
3636
static
3737
#endif
3838
inline

0 commit comments

Comments
 (0)