Difference between revisions of "Makepkg-optimize"

From ArchWiki
Jump to: navigation, search
m (more communicative; better sense of order)
m (less is probably more)
 
(2 intermediate revisions by the same user not shown)
Line 44: Line 44:
 
==== Install required packages ====
 
==== Install required packages ====
  
First, install [[Git]] and some of the backends for {{AUR|makepkg-optimize}}'s macros in the chroot:
+
First, install [[Git]] and some of the backends for the optimization macros:
  
 
  $ arch-nspawn -M /etc/makepkg.conf "$CHROOT"/root pacman -S git graphite openmp upx optipng
 
  $ arch-nspawn -M /etc/makepkg.conf "$CHROOT"/root pacman -S git graphite openmp upx optipng
Line 76: Line 76:
 
  # mount -o bind {,"$CHROOT"/"$USER"}/mnt/pgo
 
  # mount -o bind {,"$CHROOT"/"$USER"}/mnt/pgo
  
Once the package is built and [[Pacman#Usage#Additional commands|installed]], test-run its executables.
+
Once the package is [[Pacman#Usage#Additional commands|installed]], test-run its executables.
  
Then, for the second building phase, remove cruft but ''do not'' clean the chroot:
+
Then, for the second building phase, remove package cruft but ''do not'' clean the chroot (do not pass {{ic|-c}}):
  
{{Note|If you have rebooted, be sure to rebind the PGO folder!}}
+
{{Note|If you have rebooted, be sure to rebind the PGO folder. Alternatively, use [[fstab]] to bind these folders persistently.}}
  
 
  $ rm -rf *.pkg.tar.xz pkg src; makechrootpkg -r "$CHROOT" -- --config /etc/makepkg-optimize.conf
 
  $ rm -rf *.pkg.tar.xz pkg src; makechrootpkg -r "$CHROOT" -- --config /etc/makepkg-optimize.conf

Latest revision as of 16:15, 14 September 2018

Tango-go-next.pngThis article or section is a candidate for moving to [[qq's github]].Tango-go-next.png

Notes: AUR is not a code hosting platform and the wiki is not well suited for upstream documentation, in this case for a (temporary) pacman fork. (Discuss in Talk:Makepkg-optimize#This article should not be (re)moved.)

makepkg-optimizeAUR is a collection of supplemental build_env and tidy scripts for pacman-buildenv_ext-gitAUR, a fork of pacman-gitAUR. Their purpose is to provide macros to makepkg for several kinds of optimization in build and packaging stages, both in response to the simplification of makepkg and as a proposal for a future version of pacman.

Installation

Install pacman-buildenv_ext-gitAUR and makepkg-optimizeAUR from the AUR.

To make optimizations available, install their backends: graphite, openmp, upx, optipng, and nodejs-svgoAUR

Configuration

makepkg-optimizeAUR generates an additional configuration file, from your current makepkg configuration, with supplementary options for optimization that are disabled by default.

Build an optimized package

First, edit /etc/makepkg-optimize.conf and select your preferred optimizations for ARCHITECTURE, COMPILE FLAGS, BUILD ENVIRONMENT, GLOBAL PACKAGE OPTIONS and COMPRESSION DEFAULTS.

Warning: While many packages build with all optimizations enabled, some will not. It may take a few attempts to find which--if any--optimizations a package is compatible with. Some software may also experience runtime problems caused by over-optimization.

When building, pass the makepkg-optimizeAUR configuration file to makepkg:

$ makepkg --config /etc/makepkg-optimize.conf
Note: Building with Profile-guided optimization requires that a package be built and installed twice. The first phase initiates profile generation in $PROFDEST/$pkgbase.gen while the second moves the profiles to $PROFDEST/$pkgbase.used and applies them to the software being packaged.

Build an optimized package in a clean chroot

Note: Read Building in a Clean Chroot and familiarize yourself with the "Classic Way".

It is not necessary to install pacman-buildenv_ext-gitAUR or makepkg-optimizeAUR in your Archlinux installation. Alternatively, they can be used to build optimized packages within a chroot.

Chroot Setup

After setting up a chroot, a few additional steps are needed.

Install required packages

First, install Git and some of the backends for the optimization macros:

$ arch-nspawn -M /etc/makepkg.conf "$CHROOT"/root pacman -S git graphite openmp upx optipng

Then download, build and install pacman-buildenv_ext-gitAUR, makepkg-optimizeAUR, and nodejs-svgoAUR.

Create a Profile-guided Optimization cache

First, create a folder in the same place--both inside and outside of the chroot--to store profiles:

# mkdir -m 777 {"$CHROOT"/root,}/mnt/pgo

Then edit $CHROOT/root/etc/makepkg-optimize.conf and set PROFDEST=/mnt/pgo under PACKAGE OUTPUT.

Using the chroot

Note: When updating the chroot, AUR packages will have to be updated manually

Build a package

First, edit $CHROOT/root/etc/makepkg-optimize.conf and select your preferred optimizations for ARCHITECTURE, COMPILE FLAGS, BUILD ENVIRONMENT, GLOBAL PACKAGE OPTIONS and COMPRESSION DEFAULTS.

When building, pass the makepkg-optimizeAUR configuration file to makepkg:

$ makechrootpkg -c -r "$CHROOT" -- --config /etc/makepkg-optimize.conf
Building with Profile-guided optimization

After the first building phase, bind the PGO folder:

# mount -o bind {,"$CHROOT"/"$USER"}/mnt/pgo

Once the package is installed, test-run its executables.

Then, for the second building phase, remove package cruft but do not clean the chroot (do not pass -c):

Note: If you have rebooted, be sure to rebind the PGO folder. Alternatively, use fstab to bind these folders persistently.
$ rm -rf *.pkg.tar.xz pkg src; makechrootpkg -r "$CHROOT" -- --config /etc/makepkg-optimize.conf