*/*: Added LTO use flag, respecting environment

Closes: https://bugs.gentoo.org/887427
Closes: https://bugs.gentoo.org/887429
Signed-off-by: Denis Reva <denis7774@gmail.com>
This commit is contained in:
Denis Reva
2022-12-27 19:20:35 +05:00
parent b53c113142
commit 83488982f8
4 changed files with 72 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
diff --git a/Makefile b/Makefile
index 8fc7e55..03cec93 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ endif
# Windows cross compilation from Linux
#CONFIG_WIN32=y
# use link time optimization (smaller and faster executables but slower build)
-CONFIG_LTO=y
+#CONFIG_LTO=y
# consider warnings as errors (for development)
#CONFIG_WERROR=y
# force 32 bit build for some utilities
@@ -65,7 +65,7 @@ else
endif
ifdef CONFIG_CLANG
HOST_CC=clang
- CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
+ CFLAGS+=-Wall -MMD -MF $(OBJDIR)/$(@F).d
CFLAGS += -Wextra
CFLAGS += -Wno-sign-compare
CFLAGS += -Wno-missing-field-initializers
@@ -82,7 +82,7 @@ ifdef CONFIG_CLANG
endif
else
HOST_CC=gcc
- CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
+ CFLAGS+=-Wall -MMD -MF $(OBJDIR)/$(@F).d
CFLAGS += -Wno-array-bounds -Wno-format-truncation
ifdef CONFIG_LTO
else
@@ -101,11 +101,11 @@ DEFINES+=-D__USE_MINGW_ANSI_STDIO # for standard snprintf behavior
endif
CFLAGS+=$(DEFINES)
-CFLAGS_DEBUG=$(CFLAGS) -O0
-CFLAGS_SMALL=$(CFLAGS) -Os
-CFLAGS_OPT=$(CFLAGS) -O2
+CFLAGS_DEBUG=$(CFLAGS)
+CFLAGS_SMALL=$(CFLAGS)
+CFLAGS_OPT=$(CFLAGS)
CFLAGS_NOLTO:=$(CFLAGS_OPT)
-LDFLAGS+=-g
+#LDFLAGS+=
ifdef CONFIG_LTO
CFLAGS_SMALL+=-flto
CFLAGS_OPT+=-flto

View File

@@ -6,4 +6,7 @@
<name>Denis Reva</name>
<description>rarogcmex</description>
</maintainer>
<use>
<flag name="lto">Enable Link Time Optimizations (improves performance and decreases size of executables)</flag>
</use>
</pkgmetadata>

View File

@@ -14,8 +14,12 @@ S="${WORKDIR}/${MY_P}"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="lto"
PATCHES=( "${FILESDIR}/${PN}-2020.11.08_Remove-TTY-check-in-test.patch" )
PATCHES=(
"${FILESDIR}/${PN}-2020.11.08_Remove-TTY-check-in-test.patch"
"${FILESDIR}/${PN}-2021-03-27-respect-env.patch"
)
src_prepare() {
sed -i \
@@ -34,3 +38,11 @@ src_prepare() {
default
}
src_compile() {
if use lto; then
CONFIG_LTO=$(use lto) emake
else
emake
fi
}