build: Allow LTO to work globally, not just codecs/plugins

IMPORTANT: There is no guarantee this will compile cleanly much less
_work_ on any given target.  This is purely to enable future hackery.

Change-Id: Ib58f21b717719fd4325622b446a60779406ae035
This commit is contained in:
Solomon Peachy 2024-11-24 08:23:38 -05:00
parent 200529532b
commit bdf1690cb2
4 changed files with 10 additions and 5 deletions

View file

@ -154,8 +154,8 @@ endif
PLUGINLDFLAGS += $(GLOBAL_LDOPTS)
ifdef USE_LTO
PLUGINFLAGS += -flto -fno-builtin -ffreestanding
PLUGINLDFLAGS += -flto -fno-builtin -ffreestanding
PLUGINFLAGS += -fno-builtin -ffreestanding
PLUGINLDFLAGS += -fno-builtin -ffreestanding
PLUGINLDFLAGS += -e plugin_start
endif

View file

@ -47,6 +47,11 @@ $(BUILDDIR)/sysfont.o: $(SYSFONTX) $(BUILDDIR)/sysfont.h
$(call PRINTS,CONVBDF $(subst $(ROOTDIR)/,,$<))$(TOOLSDIR)/convbdf -l $(MAXCHAR) -c -o $(BUILDDIR)/sysfont.c $<
$(call PRINTS,CC $(subst $(ROOTDIR)/,,$(BUILDDIR)/sysfont.c))$(CC) $(CFLAGS) -c $(BUILDDIR)/sysfont.c -o $@
ifdef USE_LTO
$(BUILDDIR)/firmware/asm/%.o: CFLAGS += -fno-lto
$(BUILDDIR)/firmware/kernel/%.o: CFLAGS += -fno-lto
endif
# GNU make (at least) has a bug/feature that exported variable are not available
# in the shell function (but are in recipe). Thus we need to explicitely pass
# the VERSION environement variable

View file

@ -34,8 +34,8 @@ endif
CODECLDFLAGS += $(GLOBAL_LDOPTS)
ifdef USE_LTO
CODECLDFLAGS += -flto -fno-builtin -ffreestanding
CODECFLAGS += -flto -fno-builtin -ffreestanding
CODECLDFLAGS += -fno-builtin -ffreestanding
CODECFLAGS += -fno-builtin -ffreestanding
CODECLDFLAGS += -e __header
endif

2
tools/configure vendored
View file

@ -1079,7 +1079,7 @@ S(m)all C lib, Logf to Ser(i)al port, LTO Build(X), (E)rror on warnings"
[Xx])
echo "LTO build enabled"
LTO_ARG="export USE_LTO=y"
# GCCOPTS="$GCCOPTS -flto"
GCCOPTS="$GCCOPTS -flto"
;;
[Ee])
echo "Treating all warnings as errors"