Difference between revisions of "Makepkg-optimize"

From ArchWiki
Jump to: navigation, search
m (sub-subsection links are a bit wonky...)
m (more communicative; better sense of order)
(8 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
[[Category: DeveloperWiki]]
 
[[Category: DeveloperWiki]]
 
[[Category:Package management]]
 
[[Category:Package management]]
[[de:makepkg-optimize]]
 
[[fa:makepkg-optimize]]
 
[[fr:makepkg-optimize]]
 
[[ja:makepkg-optimize]]
 
[[sv:makepkg-optimize]]
 
 
{{Related articles start}}
 
{{Related articles start}}
 
{{Related|DeveloperWiki:Building in a Clean Chroot}}
 
{{Related|DeveloperWiki:Building in a Clean Chroot}}
 
{{Related|Arch User Repository}}
 
{{Related|Arch User Repository}}
 
{{Related articles end}}
 
{{Related articles end}}
{{Move||AUR is not a code hosting platform and the wiki is not well suited for upstream documentation, in this case for a [[pacman]] fork. Propose to move the code and documentation to github or other suitable platform; it could then be linked from other articles where appropriate}}
+
{{Move|[https://github.com/quequotion/makepkg-optimize qq's github]|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.|section=This article should not be (re)moved.}}
  
 
{{AUR|makepkg-optimize}} is a collection of supplemental {{ic|build_env}} and {{ic|tidy}} scripts for {{AUR|pacman-buildenv_ext-git}}, a fork of {{AUR|pacman-git}}. Their purpose is to provide macros to [[makepkg]] for several kinds of optimization in build and packaging stages, both in response to [https://lists.archlinux.org/pipermail/pacman-dev/2016-February/020826.html the simplification of makepkg] and as a proposal [https://lists.archlinux.org/pipermail/pacman-dev/2018-May/022498.html for a future version of pacman].
 
{{AUR|makepkg-optimize}} is a collection of supplemental {{ic|build_env}} and {{ic|tidy}} scripts for {{AUR|pacman-buildenv_ext-git}}, a fork of {{AUR|pacman-git}}. Their purpose is to provide macros to [[makepkg]] for several kinds of optimization in build and packaging stages, both in response to [https://lists.archlinux.org/pipermail/pacman-dev/2016-February/020826.html the simplification of makepkg] and as a proposal [https://lists.archlinux.org/pipermail/pacman-dev/2018-May/022498.html for a future version of pacman].
Line 27: Line 22:
 
== Build an optimized package ==
 
== Build an optimized package ==
  
Edit {{ic|/etc/makepkg-optimize.conf}} and select your preferred optimizations for [[Makepkg#Building optimized binaries|{{ic|ARCHITECTURE, COMPILE FLAGS}}]], {{ic|BUILD ENVIRONMENT}}, {{ic|GLOBAL PACKAGE OPTIONS}} and {{ic|COMPRESSION DEFAULTS}}.
+
First, edit [[Makepkg-optimize#Configuration|{{ic|/etc/makepkg-optimize.conf}}]] and select your preferred optimizations for [[Makepkg#Building optimized binaries|{{ic|ARCHITECTURE, COMPILE FLAGS}}]], {{ic|BUILD ENVIRONMENT}}, {{ic|GLOBAL PACKAGE OPTIONS}} and {{ic|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.}}
 
{{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.}}
Line 43: Line 38:
 
It is not necessary to install {{AUR|pacman-buildenv_ext-git}} or {{AUR|makepkg-optimize}} in your Archlinux installation. Alternatively, they can be used to build optimized packages within a [[chroot]].
 
It is not necessary to install {{AUR|pacman-buildenv_ext-git}} or {{AUR|makepkg-optimize}} in your Archlinux installation. Alternatively, they can be used to build optimized packages within a [[chroot]].
  
=== Chroot Setup (First time only) ===
+
=== Chroot Setup ===
  
After [[DeveloperWiki:Building in a Clean Chroot#Setting Up A Chroot|setting up a chroot]], a few additional steps are needed to build optimized packages.
+
After [[DeveloperWiki:Building in a Clean Chroot#Setting Up A Chroot|setting up a chroot]], a few additional steps are needed.
  
 
==== Install required packages ====
 
==== Install required packages ====
  
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 {{AUR|makepkg-optimize}}'s macros in the chroot:
  
 
  $ 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 81: 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 built and [[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 cruft but ''do not'' clean the chroot:
  
 
{{Note|If you have rebooted, be sure to rebind the PGO folder!}}
 
{{Note|If you have rebooted, be sure to rebind the PGO folder!}}
  
 
  $ 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

Revision as of 18:37, 10 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 makepkg-optimizeAUR's macros in the chroot:

$ 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 built and installed, test-run its executables.

Then, for the second building phase, remove cruft but do not clean the chroot:

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