build: Experimental LTO support, phase one

* Only codecs and plugins are enabled
 * Only native builds (so far)
 * Only tested on xDuoo X3 (MIPS, monochrome)
 * opus & speex generate some warnings
 * Significant compile time impact

Change-Id: I519b0d179631a54b2103cd67225bd5ec6ad3bd2f
This commit is contained in:
Solomon Peachy 2023-07-02 20:43:01 -04:00
parent 7b12cc3927
commit 73f40d8a23
4 changed files with 31 additions and 1 deletions

View file

@ -37,6 +37,12 @@ PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
PLUGINLIB_OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PLUGINLIB_OBJ))
ifdef USE_LTO
# We do NOT want LTO on the GCC support file.
$(BUILDDIR)/apps/plugins/lib/gcc-support.o: PLUGINFLAGS += -fno-lto
$(BUILDDIR)/apps/plugins/plugin_crt0.o: PLUGINFLAGS += -fno-lto
endif
### build data / rules
ifndef APP_TYPE
CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
@ -147,6 +153,12 @@ else
endif
PLUGINLDFLAGS += $(GLOBAL_LDOPTS)
ifdef USE_LTO
PLUGINFLAGS += -flto -fno-builtin -ffreestanding
PLUGINLDFLAGS += -flto -fno-builtin -ffreestanding
PLUGINLDFLAGS += -e plugin_start
endif
$(BUILDDIR)/%.rock:
$(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
$(filter %.o, $^) \