Add link time optimization support to makepkg
Add the 'lto' option to enable building with link time optimization by adding '-flto' to both CFLAGS and CXXFLAGS. The 'lto' option can be specificed both in the PKGBUILD or by setting the default in makepkg.conf. Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
17f9911ffc
commit
4a0891f49d
5 changed files with 49 additions and 2 deletions
|
@ -325,6 +325,10 @@ underscore and the architecture name e.g., 'replaces_x86_64=()'.
|
||||||
When used in combination with the `strip' option, a separate package
|
When used in combination with the `strip' option, a separate package
|
||||||
containing the debug symbols is created.
|
containing the debug symbols is created.
|
||||||
|
|
||||||
|
*lto*;;
|
||||||
|
Enable building packages using link time optimization. Adds '-flto'
|
||||||
|
to both CFLAGS and CXXFLAGS.
|
||||||
|
|
||||||
|
|
||||||
Packaging Functions
|
Packaging Functions
|
||||||
-------------------
|
-------------------
|
||||||
|
|
|
@ -189,6 +189,10 @@ Options
|
||||||
DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate
|
DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate
|
||||||
package containing the debug symbols when used with `strip'.
|
package containing the debug symbols when used with `strip'.
|
||||||
|
|
||||||
|
*lto*;;
|
||||||
|
Enable building packages using link time optimization. Adds '-flto'
|
||||||
|
to both CFLAGS and CXXFLAGS.
|
||||||
|
|
||||||
**INTEGRITY_CHECK=(**check1 ...**)**::
|
**INTEGRITY_CHECK=(**check1 ...**)**::
|
||||||
File integrity checks to use. Multiple checks may be specified; this
|
File integrity checks to use. Multiple checks may be specified; this
|
||||||
affects both generation and checking. The current valid options are:
|
affects both generation and checking. The current valid options are:
|
||||||
|
|
|
@ -76,7 +76,7 @@ BUILDENV=(!distcc color !ccache check !sign)
|
||||||
# These are default values for the options=() settings
|
# These are default values for the options=() settings
|
||||||
#########################################################################
|
#########################################################################
|
||||||
#
|
#
|
||||||
# Makepkg defaults: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug)
|
# Makepkg defaults: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug !lto)
|
||||||
# A negated option will do the opposite of the comments below.
|
# A negated option will do the opposite of the comments below.
|
||||||
#
|
#
|
||||||
#-- strip: Strip symbols from binaries/libraries
|
#-- strip: Strip symbols from binaries/libraries
|
||||||
|
@ -87,8 +87,9 @@ BUILDENV=(!distcc color !ccache check !sign)
|
||||||
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
|
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
|
||||||
#-- purge: Remove files specified by PURGE_TARGETS
|
#-- purge: Remove files specified by PURGE_TARGETS
|
||||||
#-- debug: Add debugging flags as specified in DEBUG_* variables
|
#-- debug: Add debugging flags as specified in DEBUG_* variables
|
||||||
|
#-- lto: Add compile flags for building with link time optimization
|
||||||
#
|
#
|
||||||
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !debug)
|
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !debug !lto)
|
||||||
|
|
||||||
#-- File integrity checks to use. Valid: ck, md5, sha1, sha224, sha256, sha384, sha512, b2
|
#-- File integrity checks to use. Valid: ck, md5, sha1, sha224, sha256, sha384, sha512, b2
|
||||||
INTEGRITY_CHECK=(ck)
|
INTEGRITY_CHECK=(ck)
|
||||||
|
|
37
scripts/libmakepkg/buildenv/lto.sh.in
Normal file
37
scripts/libmakepkg/buildenv/lto.sh.in
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
#
|
||||||
|
# lto.sh - Specify flags for building a package with link-time
|
||||||
|
# optimisation
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 Pacman Development Team <pacman-dev@archlinux.org>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
[[ -n "$LIBMAKEPKG_BUILDENV_LTO_SH" ]] && return
|
||||||
|
LIBMAKEPKG_BUILDENV_LTO_SH=1
|
||||||
|
|
||||||
|
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||||
|
|
||||||
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
build_options+=('lto')
|
||||||
|
buildenv_functions+=('buildenv_lto')
|
||||||
|
|
||||||
|
buildenv_lto() {
|
||||||
|
if check_option "lto" "y"; then
|
||||||
|
CFLAGS+=" -flto"
|
||||||
|
CXXFLAGS+=" -flto"
|
||||||
|
fi
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ sources = [
|
||||||
'buildflags.sh.in',
|
'buildflags.sh.in',
|
||||||
'compiler.sh.in',
|
'compiler.sh.in',
|
||||||
'debugflags.sh.in',
|
'debugflags.sh.in',
|
||||||
|
'lto.sh.in',
|
||||||
'makeflags.sh.in',
|
'makeflags.sh.in',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue