diff options
-rw-r--r-- | doc/PKGBUILD.5.asciidoc | 4 | ||||
-rw-r--r-- | doc/makepkg.conf.5.asciidoc | 4 | ||||
-rw-r--r-- | etc/makepkg.conf.in | 5 | ||||
-rw-r--r-- | scripts/libmakepkg/buildenv/lto.sh.in | 37 | ||||
-rw-r--r-- | scripts/libmakepkg/buildenv/meson.build | 1 |
5 files changed, 49 insertions, 2 deletions
diff --git a/doc/PKGBUILD.5.asciidoc b/doc/PKGBUILD.5.asciidoc index 1db0b6c4..af615040 100644 --- a/doc/PKGBUILD.5.asciidoc +++ b/doc/PKGBUILD.5.asciidoc @@ -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 containing the debug symbols is created. + *lto*;; + Enable building packages using link time optimization. Adds '-flto' + to both CFLAGS and CXXFLAGS. + Packaging Functions ------------------- diff --git a/doc/makepkg.conf.5.asciidoc b/doc/makepkg.conf.5.asciidoc index 04cc5ea9..2c7a54db 100644 --- a/doc/makepkg.conf.5.asciidoc +++ b/doc/makepkg.conf.5.asciidoc @@ -189,6 +189,10 @@ Options DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate 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 ...**)**:: File integrity checks to use. Multiple checks may be specified; this affects both generation and checking. The current valid options are: diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index b13b1d5d..43a69df6 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -76,7 +76,7 @@ BUILDENV=(!distcc color !ccache check !sign) # 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. # #-- 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 #-- purge: Remove files specified by PURGE_TARGETS #-- 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 INTEGRITY_CHECK=(ck) diff --git a/scripts/libmakepkg/buildenv/lto.sh.in b/scripts/libmakepkg/buildenv/lto.sh.in new file mode 100644 index 00000000..8e7be66a --- /dev/null +++ b/scripts/libmakepkg/buildenv/lto.sh.in @@ -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 +} diff --git a/scripts/libmakepkg/buildenv/meson.build b/scripts/libmakepkg/buildenv/meson.build index 34d4ba7b..b72d91c0 100644 --- a/scripts/libmakepkg/buildenv/meson.build +++ b/scripts/libmakepkg/buildenv/meson.build @@ -4,6 +4,7 @@ sources = [ 'buildflags.sh.in', 'compiler.sh.in', 'debugflags.sh.in', + 'lto.sh.in', 'makeflags.sh.in', ] |