Added support for link-time-optimizations.

This commit is contained in:
LoRd_MuldeR 2020-11-01 22:46:25 +01:00
parent 0fbc7f1fb9
commit e105feb651
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
2 changed files with 7 additions and 3 deletions

View File

@ -5,6 +5,7 @@
DEBUG ?= 0
ASAN ?= 0
STATIC ?= 0
FLTO ?= 0
FPGO ?= 0
STRIP ?= 0
MARCH ?= native
@ -33,11 +34,13 @@ else ifeq ($(ASAN),1)
else
CONFIG :=
CFLAGS += -O3 -DNDEBUG
ifneq ($(FLTO),0)
CFLAGS += -flto -fuse-linker-plugin
endif
ifneq ($(FPGO),0)
CFLAGS += -fprofile-$(FPGO)
endif
endif
MACHINE := $(shell $(CC) -dumpmachine)

View File

@ -1,5 +1,6 @@
#!/bin/bash
set -e
readonly USE_LTO=1
PLATFORM="$(uname -a)"
unset SUFFIX
@ -23,7 +24,7 @@ printf "\033[1;36m\n------------------------------------------------------------
printf "\033[1;36mInstrument\n"
printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
make FPGO="generate=/tmp/${PGO_PATH}" -B "$@"
make FLTO=${USE_LTO} FPGO="generate=/tmp/${PGO_PATH}" -B "$@"
printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
printf "\033[1;36mProfiling\n"
@ -39,6 +40,6 @@ printf "\033[1;36m\n------------------------------------------------------------
printf "\033[1;36mRe-compile\n"
printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
make FPGO="use=/tmp/${PGO_PATH}" STRIP=1 -B "$@"
make FLTO=${USE_LTO} FPGO="use=/tmp/${PGO_PATH}" STRIP=1 -B "$@"
printf "\033[1;32m\nBuild completed successfully.\033[0m\n\n"