Home Arch User Repository (AUR) How To Speed Up Compilation Process When Installing Packages From AUR

How To Speed Up Compilation Process When Installing Packages From AUR

By sk
Published: Last Updated on 2,196 Views

This brief tutorial describes how to speed up compilation process when installing packages from AUR using Ccache in Arch Linux and its variants EndeavourOS and Manjaro Linux.

The reasons why I (and everyone) prefer Arch Linux over other Linux distributions are:

  • It is a rolling release, so you will always have the last version of your applications,
  • Robust and powerful package manager Pacman,
  • Arch User Repository (AUR),
  • and Arch Wiki.

As you may already know, Pacman is the simple and powerful package manager for Arch Linux and its derivatives.

Arch Wiki doesn't need any introduction. It is an incredible documentation site, contributed by well-experienced users, where you can find tons of guides, tips and tricks etc.

And, finally the AUR or Arch User Repository. In this repository, almost every piece of software that runs on Linux is available. It is the largest repository maintained by trusted users from all over the world.

You don't have to deal with PPAs or a any other third-party repositories. You can easily install any software from AUR using helper programs such as Paru and Yay.

If you use AUR regularly, I've got a good news for you. You can speed up the compilation process when installing packages from AUR using ccache compiler.

What is Ccache?

For those wondering, ccache is a fast c/c++ compiler which is used to speed up the compilation process. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again. It supports C, C++, Objective-C and Objective-C++.

Speed Up Compilation Process When Installing Packages From AUR

Step 1: You need to install ccache package first. Ccache is available in the default repositories.

To install Ccache in Arch Linux, EndeavourOS, Manjaro Linux, run:

$ sudo pacman -S ccache

Step 2: After installing ccache, edit /etc/makepkg.conf file:

$ sudo vi /etc/makepkg.conf

Step 3: Find and uncomment ccache from the following line (remove the exclamation mark) to enable caching.

BUILDENV=(fakeroot !distcc color ccache check !sign)

Then uncomment and edit the MAKEFLAGS value to reflect your CPU threads. Say for example, if your CPU has 8 threads (4 cores), then update the value as shown below:

MAKEFLAGS="-j8"

Press ESC key, then type :wq and press ENTER to save the file and close it.

Tip: To find the number of CPU cores in your system, refer the following link.

Step 4: Then, edit your bashrc file:

$ vi ~/.bashrc

Step 5: Add the following line to enable for command line compilations:

export PATH="/usr/lib/ccache/bin/:$PATH"

Save the file and close it.

Step 6: Finally, source the bashrc file to take effect the changes using command:

$ source ~/.bashrc

Now, you will notice the difference while compiling packages from AUR. Please note that ccache may take a few seconds longer to compile a program the first time, but the subsequent compiles will be much faster.

Resources:

You May Also Like

2 comments

Przemek Skweres August 27, 2017 - 9:28 pm

What command will be when I use ZSH?

Reply
Michał February 9, 2019 - 10:49 pm

Przemek Skweres, commands will be the same. ZSH works differently then bask but commands stay the same.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More