summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2023-07-02 20:43:01 -0400
committerSolomon Peachy <pizza@shaftnet.org>2024-06-18 08:15:47 -0400
commit73f40d8a2385543464d79d4461ab68eb56783d26 (patch)
tree903d5b1eecc88ad8cf2acc6681eb8b91ddf8fafe
parent7b12cc39270c41459ffe98659d9899d02d8bf56b (diff)
downloadrockbox-73f40d8a2385543464d79d4461ab68eb56783d26.tar.gz
rockbox-73f40d8a2385543464d79d4461ab68eb56783d26.zip
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
-rw-r--r--apps/plugins/plugins.make12
-rw-r--r--lib/rbcodec/codecs/codecs.make7
-rw-r--r--lib/rbcodec/codecs/lib/libcodec.make5
-rwxr-xr-xtools/configure8
4 files changed, 31 insertions, 1 deletions
diff --git a/apps/plugins/plugins.make b/apps/plugins/plugins.make
index b430bd2792..4a126f812c 100644
--- a/apps/plugins/plugins.make
+++ b/apps/plugins/plugins.make
@@ -37,6 +37,12 @@ PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
37PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o) 37PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
38PLUGINLIB_OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PLUGINLIB_OBJ)) 38PLUGINLIB_OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PLUGINLIB_OBJ))
39 39
40ifdef USE_LTO
41# We do NOT want LTO on the GCC support file.
42$(BUILDDIR)/apps/plugins/lib/gcc-support.o: PLUGINFLAGS += -fno-lto
43$(BUILDDIR)/apps/plugins/plugin_crt0.o: PLUGINFLAGS += -fno-lto
44endif
45
40### build data / rules 46### build data / rules
41ifndef APP_TYPE 47ifndef APP_TYPE
42CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h 48CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
@@ -147,6 +153,12 @@ else
147endif 153endif
148PLUGINLDFLAGS += $(GLOBAL_LDOPTS) 154PLUGINLDFLAGS += $(GLOBAL_LDOPTS)
149 155
156ifdef USE_LTO
157 PLUGINFLAGS += -flto -fno-builtin -ffreestanding
158 PLUGINLDFLAGS += -flto -fno-builtin -ffreestanding
159 PLUGINLDFLAGS += -e plugin_start
160endif
161
150$(BUILDDIR)/%.rock: 162$(BUILDDIR)/%.rock:
151 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \ 163 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
152 $(filter %.o, $^) \ 164 $(filter %.o, $^) \
diff --git a/lib/rbcodec/codecs/codecs.make b/lib/rbcodec/codecs/codecs.make
index 27ba73ab3c..83dc784ee3 100644
--- a/lib/rbcodec/codecs/codecs.make
+++ b/lib/rbcodec/codecs/codecs.make
@@ -33,6 +33,13 @@ else
33endif 33endif
34CODECLDFLAGS += $(GLOBAL_LDOPTS) 34CODECLDFLAGS += $(GLOBAL_LDOPTS)
35 35
36ifdef USE_LTO
37 CODECLDFLAGS += -flto -fno-builtin -ffreestanding
38 CODECFLAGS += -flto -fno-builtin -ffreestanding
39 CODECLDFLAGS += -e __header
40endif
41
42
36# the codec libraries 43# the codec libraries
37include $(RBCODECLIB_DIR)/codecs/demac/libdemac.make 44include $(RBCODECLIB_DIR)/codecs/demac/libdemac.make
38include $(RBCODECLIB_DIR)/codecs/liba52/liba52.make 45include $(RBCODECLIB_DIR)/codecs/liba52/liba52.make
diff --git a/lib/rbcodec/codecs/lib/libcodec.make b/lib/rbcodec/codecs/lib/libcodec.make
index 0788dd6705..b197464528 100644
--- a/lib/rbcodec/codecs/lib/libcodec.make
+++ b/lib/rbcodec/codecs/lib/libcodec.make
@@ -23,6 +23,11 @@ ifneq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim)
23 CODECLIBFLAGS += -ffunction-sections 23 CODECLIBFLAGS += -ffunction-sections
24endif 24endif
25 25
26ifdef USE_LTO
27# We do NOT want LTO on the GCC support file
28$(CODECDIR)/lib/codeclib.o: CODECLIBFLAGS += -fno-lto
29endif
30
26$(CODECDIR)/lib/%.o: $(RBCODECLIB_DIR)/codecs/lib/%.c 31$(CODECDIR)/lib/%.o: $(RBCODECLIB_DIR)/codecs/lib/%.c
27 $(SILENT)mkdir -p $(dir $@) 32 $(SILENT)mkdir -p $(dir $@)
28 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \ 33 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \
diff --git a/tools/configure b/tools/configure
index c58ce164ac..bf96bf0058 100755
--- a/tools/configure
+++ b/tools/configure
@@ -945,13 +945,14 @@ whichadvanced () {
945 echo "" 945 echo ""
946 printf "Enter your developer options (press only enter when done)\n\ 946 printf "Enter your developer options (press only enter when done)\n\
947(D)EBUG, (L)ogf, Boot(c)hart, (S)imulator, (P)rofiling, (V)oice, (U)SB Serial, (W)in32 crosscompile,\n\ 947(D)EBUG, (L)ogf, Boot(c)hart, (S)imulator, (P)rofiling, (V)oice, (U)SB Serial, (W)in32 crosscompile,\n\
948Win(6)4 crosscompile, (T)est plugins, (O)mit plugins, S(m)all C lib, Logf to Ser(i)al port:" 948Win(6)4 crosscompile, (T)est plugins, (O)mit plugins, S(m)all C lib, Logf to Ser(i)al port, LTO (B)uild "
949 if [ "$modelname" = "iaudiom5" ]; then 949 if [ "$modelname" = "iaudiom5" ]; then
950 printf ", (F)M radio MOD" 950 printf ", (F)M radio MOD"
951 fi 951 fi
952 if [ "$modelname" = "iriverh120" ]; then 952 if [ "$modelname" = "iriverh120" ]; then
953 printf ", (R)TC MOD" 953 printf ", (R)TC MOD"
954 fi 954 fi
955 printf ":"
955 echo "" 956 echo ""
956 fi 957 fi
957 958
@@ -1043,6 +1044,10 @@ Win(6)4 crosscompile, (T)est plugins, (O)mit plugins, S(m)all C lib, Logf to Ser
1043 win32crosscompile="yes" 1044 win32crosscompile="yes"
1044 win64="yes" 1045 win64="yes"
1045 ;; 1046 ;;
1047 [Bb])
1048 echo "LTO build enabled"
1049 LTO_ARG="export USE_LTO=y"
1050 ;;
1046 "") # Match enter press when finished with advanced options 1051 "") # Match enter press when finished with advanced options
1047 cont=0 1052 cont=0
1048 ;; 1053 ;;
@@ -4806,6 +4811,7 @@ export ANDROID_PLATFORM_VERSION=${ANDROID_PLATFORM_VERSION}
4806export TOOLSET=${toolset} 4811export TOOLSET=${toolset}
4807export PIPER_MODEL_DIR=${PIPER_MODEL_DIR} 4812export PIPER_MODEL_DIR=${PIPER_MODEL_DIR}
4808$CCACHE_ARG 4813$CCACHE_ARG
4814$LTO_ARG
4809 4815
4810CONFIGURE_OPTIONS=${cmdline} 4816CONFIGURE_OPTIONS=${cmdline}
4811 4817