Package Details: makepkg-optimize 21-1

Git Clone URL: https://aur.archlinux.org/makepkg-optimize.git (read-only, click to copy)
Package Base: makepkg-optimize
Description: Supplemental build and packaging optimizations for makepkg
Upstream URL: https://wiki.archlinux.org/index.php/Makepkg-optimize
Licenses: GPL
Submitter: quequotion
Maintainer: quequotion
Last Packager: quequotion
Votes: 17
Popularity: 0.000022
First Submitted: 2016-03-20 15:08 (UTC)
Last Updated: 2022-01-09 15:05 (UTC)

Dependencies (6)

Required by (0)

Sources (20)

Pinned Comments

quequotion commented on 2019-02-27 07:49 (UTC) (edited on 2022-01-09 13:20 (UTC) by quequotion)

makepkg-optimize is a collection of libmakepkg tidy, buildenv, and executable extensions, and a supplement to pacman. These enable various optimization routines for building and packaging such as upx compression, profile guided optimization, polyhedral model optimization, etc..

Note: Over-optimization is a thing, and it is not good.

See the wiki article for details.

Note to packagers: makepkg-optmize's macros may be enabled or disabled in options() as well!

Latest Comments

« First ‹ Previous 1 2 3 4 5 6 7 Next › Last »

brikler commented on 2019-07-01 06:28 (UTC) (edited on 2019-07-03 12:30 (UTC) by brikler)

it seems llvm/clang doesn't support -flto=nCore but the build doesn't stop if set.

-rw-r--r-- 1 tom tom 373988 10.04.2019 09:11 upx-3.95-1-x86_64.pkg.tar.xz.clangLTO
-rw-r--r-- 1 tom tom 376536 10.04.2019 09:14 upx-3.95-1-x86_64.pkg.tar.xz.clangTHINLTO
-rw-r--r-- 1 tom tom 371856 10.04.2019 10:24 upx-3.95-1-x86_64.pkg.tar.xz.clangWithoutLTO
-rw-r--r-- 1 tom tom 368732 06.04.2019 16:30 upx-3.95-1-x86_64.pkg.tar.xz.gccLTO
-rw-r--r-- 1 tom tom 373300 10.04.2019 09:53 upx-3.95-1-x86_64.pkg.tar.xz.gccWithoutLTO

btw -flto=thindoes the same as -flto=nCore but it differs how it is be done …please read the linked blog article in my previous post for a more reliable explanation

quequotion commented on 2019-06-28 02:09 (UTC) (edited on 2019-06-28 02:35 (UTC) by quequotion)

brikler, the LTO macro is set in lto.sh.in, which installs to /usr/share/makepkg/buildenv/lto.sh.

Not sure how or if I could add code here to check which compiler was to be used and change the flag accordingly; you can edit it by hand in the meantime.

-flto=thin doesn't do the same thing as -flto=nCPUs; did llvm never support =nCPUs to begin with?

brikler commented on 2019-06-25 14:57 (UTC) (edited on 2019-06-26 18:21 (UTC) by brikler)

is it possible to make it work with llvm/clang without touch makepkg.conf?

=> loop optimization is enabled by default

==> i doesn't found llvm/clang support pgo

===>llvm/clang doesn't use the "-flto=nCores" flag, instead they use "-flto=thin", if is compiled with this option (llvm/clang 8 isn't compiled with) http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html

quequotion commented on 2019-03-10 10:15 (UTC) (edited on 2019-03-10 11:52 (UTC) by quequotion)

@brikler What profile-guided optimization does is collect statistics on the execution of a program, then use the data to generate more optimal code when recompiling the program. The result should be a faster, smaller binary that achieves whatever the original code intends. Of course, as the second version of the code is machine-generated, that cannot always be guaranteed; the benefits also depend on how well the profiling run exemplifies typical use of the program.

In order to use PGO, a package must be built, installed, used, and then rebuilt and reinstalled. During the first run, profiles are generated and stored in $PROFDEST/$pkgbase.gen. Once you've used every feature of the software that you wish to optimize, rebuild the package to move the profiles to $PROFDEST/$pkgbase.used and apply them, creating optimized binaries. It is a time-consuming process, but the benefits are generally proportional to the effort.

It is possible to use the collected profiles to make improvements to the code by hand, such as is done by developers of the kernel, kernel modules, real-time control software, etc. Unless you intend to do so, it is not necessary to keep the $pkgbase.used folder.

brikler commented on 2019-03-10 07:45 (UTC) (edited on 2019-03-10 07:49 (UTC) by brikler)

so i must keep the optimized profile up to the next with pgo compiled version come? i thought it's code optimization not for run time?

quequotion commented on 2019-03-10 01:01 (UTC) (edited on 2019-03-10 01:02 (UTC) by quequotion)

@brikler Systemd is trying to access its profiles, but your home directory isn't available until you log in. There is a new "Package Output" variable for this in makepkg-optimize.conf, PROFDEST. If unset, profiles are stored in the build directory.

To profile systemd, you'll need to set PROFDEST to somewhere in the root file system; I use /mnt/pgo/.

brikler commented on 2019-03-09 12:58 (UTC)

next "problem": i have build systemd with pgo and after reboot my sreen was spammed with this kind of message:

…
profiling:/home/tom/compile/systemd/systemd.gen/src/journal/da05bd7@@journal-client@sta/journal-send.c.gcda:Cannot open
profiling:/home/tom/compile/systemd/systemd.gen/src/journal/da05bd7@@journal-client@sta/journal-vacuum.c.gcda:Cannot open
profiling:/home/tom/compile/systemd/systemd.gen/src/journal/da05bd7@@journal-client@sta/journal-verify.c.gcda:Cannot open
profiling:/home/tom/compile/systemd/systemd.gen/src/journal/da05bd7@@journal-client@sta/lookup3.c.gcda:Cannot open
profiling:/home/tom/compile/systemd/systemd.gen/src/journal/da05bd7@@journal-client@sta/mmap-cache.c.gcda:Cannot open
profiling:/home/tom/compile/systemd/systemd.gen/src/journal/da05bd7@@journal-client@sta/sd-journal.c.gcda:Cannot open

how to avoid this?

quequotion commented on 2019-03-08 14:55 (UTC) (edited on 2019-03-08 17:23 (UTC) by quequotion)

@brikler The flags were not getting set because of a typo!

lto.sh.in line 14:

-buildenv_functionss+=('buildenv_lto')
+buildenv_functions+=('buildenv_lto')

No idea how long that'd been there. Thanks for the help!

The flags are where they need to be. I test built a few things to make sure; these flags work. They have a long history.

Note that some packages may fail to compile with LTO, for example pulseaudio-git.

brikler commented on 2019-03-06 13:34 (UTC) (edited on 2019-03-06 13:45 (UTC) by brikler)

it seems the settings in /usr/share/makepkg/buildenv/lto.sh are not honered by gcc, as example a build with -flto set in makepkg.conf an on only lto.sh

<h1>-flto and -fuse-linker-plugin set in makepkg.conf. from config.log</h1>

gcc -o conftest -mf16c -mavx -lpthread -pthread -march=native -Os -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fopenmp -Wno-error -w -fno-plt -flto=4 -fuse-linker-plugin -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -ftree-vectorize -fprofile-correction -fprofile-use -fprofile-dir=/home/tom/compile/iwd/iwd.used -mf16c -mavx -lpthread -pthread -march=native -Os -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fopenmp -Wno-error -w -fno-plt -flto=4 -fuse-linker-plugin -Wl,-O3,--sort-common,--as-needed,-z,relro,--hash-style=gnu,-fuse-ld=gold conftest.c >&5

<h1>only in lto.sh from config.log</h1>

configure:3574: gcc -mf16c -mavx -lpthread -pthread -march=native -Os -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fopenmp -Wno-error -w -fno-plt -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -ftree-vectorize -fprofile-correction -fprofile-use -fprofile-dir=/home/tom/compile/iwd/iwd.used -mf16c -mavx -lpthread -pthread -march=native -Os -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fopenmp -Wno-error -w -fno-plt -Wl,-O3,--sort-common,--as-needed,-z,relro,--hash-style=gnu,-fuse-ld=gold conftest.c >&5

and the build process breaks when -fuse-linker-plugin is in LDFLAGS but is working in CFLAGS

quequotion commented on 2019-02-27 07:49 (UTC) (edited on 2022-01-09 13:20 (UTC) by quequotion)

makepkg-optimize is a collection of libmakepkg tidy, buildenv, and executable extensions, and a supplement to pacman. These enable various optimization routines for building and packaging such as upx compression, profile guided optimization, polyhedral model optimization, etc..

Note: Over-optimization is a thing, and it is not good.

See the wiki article for details.

Note to packagers: makepkg-optmize's macros may be enabled or disabled in options() as well!