Separate translate object control from LTO

This commit is contained in:
Scott Shawcroft 2022-05-31 12:18:05 -07:00
parent 8d559196ed
commit 4d776339ad
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
6 changed files with 18 additions and 5 deletions

View File

@ -107,7 +107,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
# BCM CLFAGS
CFLAGS += -ffreestanding -nostartfiles -DMICROPY_HW_MCU_NAME="\"$(CHIP_VARIANT)\""
CFLAGS += -nostartfiles -DMICROPY_HW_MCU_NAME="\"$(CHIP_VARIANT)\""
OPTIMIZATION_FLAGS ?= -O3

View File

@ -3,6 +3,8 @@ USB_HIGHSPEED = 1
# Number of USB endpoint pairs.
USB_NUM_ENDPOINT_PAIRS = 6
CIRCUITPY_TRANSLATE_OBJECT = 1
# Longints can be implemented as mpz, as longlong, or not
LONGINT_IMPL = MPZ

View File

@ -51,7 +51,8 @@ BASE_CFLAGS = \
-DCIRCUITPY_SOFTWARE_SAFE_MODE=0x0ADABEEF \
-DCIRCUITPY_CANARY_WORD=0xADAF00 \
-DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
-DCIRCUITPY_BOARD_ID="\"$(BOARD)\""
-DCIRCUITPY_BOARD_ID="\"$(BOARD)\"" \
--param max-inline-insns-single=500
# Use these flags to debug build times and header includes.
# -ftime-report
@ -73,6 +74,16 @@ else
CFLAGS += -DCIRCUITPY_LTO=0
endif
# Produce an object file for translate.c instead of including it in a header.
# The header version can be optimized on non-LTO builds *if* inlining is allowed
# otherwise, it blows up the binary sizes with tons of translate copies.
ifeq ($(CIRCUITPY_LTO), 0)
CIRCUITPY_TRANSLATE_OBJECT ?= 0
else
CIRCUITPY_TRANSLATE_OBJECT ?= 1
endif
CFLAGS += -DCIRCUITPY_TRANSLATE_OBJECT=$(CIRCUITPY_TRANSLATE_OBJECT)
###
# Handle frozen modules.

View File

@ -135,6 +135,6 @@ char *decompress(const compressed_string_t *compressed, char *decompressed) {
return decompressed;
}
#if CIRCUITPY_LTO == 1
#if CIRCUITPY_TRANSLATE_OBJECT == 1
#include "supervisor/shared/translate/translate_impl.h"
#endif

View File

@ -43,7 +43,7 @@
// that the build process will optimize this away and replace it with the
// appropriate compressed data for each call site.
#if CIRCUITPY_LTO == 0
#if CIRCUITPY_TRANSLATE_OBJECT == 0
// Without LTO, we need to include a copy of this function in each compilation
// unit so that the compile stage can do the optimization. Otherwise the linker
// will leave this as a giant function and have each call site call into it.

View File

@ -32,7 +32,7 @@
#include "supervisor/shared/translate/compressed_string.h"
#if CIRCUITPY_LTO == 0
#if CIRCUITPY_TRANSLATE_OBJECT == 0
static
#endif
inline