---
title: "Gettting Valgrind working on Artix Linux"
date: 2023-08-29T21:38:32-04:00
tags: ['software development', 'linux', 'Artix']
---

I'm currently working on developing an implementation of the Concurrent Atomistic-Continuum method using C++ and CUDA to accelerate calculations. 
A need arose to use `valgrind` for debugging some memory issues. 
I currently run [Artix Linux](https://artixlinux.org) and it turns out that both Artix Linux and Arch Linux have fully removed all debug packages from their repositories and have swapped over to a `debuginfod` style system.
On my system, said `debuginfod` was working with `gdb` but not with `valgrind`.
In particular I was missing the debug symbols for `glibc` which prevented `valgrind` from working at all.
I had to try a few things before I got it working so I want to share how I did. 
I also want to mention an issue I ran into if any guys from Artix Linux ever end up reading this post.

## What should've worked but didn't

Artix linux is hosting a debuginfod server at https://debuginfod.artixlinux.org. 
They have this set up so that you can add it to your `/etc/pacman.conf` as a custom repository. 
All you have to do is append:
```
[system-debug]
Server = https://debuginfod.artixlinux.org/$repo/os/$arch
[world-debug]
Server = https://debuginfod.artixlinux.org/$repo/os/$arch
[galaxy-debug]
Server = https://debuginfod.artixlinux.org/$repo/os/$arch
[lib32-debug]
Server = https://debuginfod.artixlinux.org/$repo/os/$arch
```

to the bottom of the file, run a quick `pacman -Syu`, and then you should be good to go.
The issue that I ran into was that the debug package for `glibc` was old compared to the version of `glibc` I had installed.
This meant that even though I had the `glibc-debug` package, `valgrind` still didn't work.
My only gripe with the Artix Linux team is that if you are going to switch to a `debuginfod` setup and not allow us to install packages from the core repositories that have debug symbols enabled, please at least keep it up to date with the other core repositories.

## What does work and isn't ideal

Once the Artix specific solution didn't work, I switched over to figuring out the more general Arch Linux solution with the hope that it didn't involve `systemd`.
It turns out that the Arch Linux team has not exposed their debug repositories the same way that the Artix Linux team has which means you have to dig a little bit more.
I ended up finding in the Arch Linux wiki, that there are Arch Linux sponsored mirrors which contain the debug packages. 
To enable these you just add:

```
[core-debug]
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
[extra-debug]
Include = https://geo.mirror.pkgbuild.com/$repo/os/$arch

[multilib-debug]
Include = https://geo.mirror.pkgbuild.com/$repo/os/$arch
```

to the bottom of your `/etc/pacman.conf`. 
Now you are actually good to update with  `pacman -Syu` and install debug symbols for glibc, `pacman -S glibc-debug`.
Just watch out for incompatible versions again. 
It may be that on another upgrade, Arch linux will move further ahead on the debug package version number than the Artix Linux version of `glibc`. 
A workaround for this is to just install glibc from the Arch Linux `[core]` repository from https://geo.mirror.pkgbuild.com instead of the `[system]` repository on Artix. 
**Be warned** though that this might mess up other Artix programs which depend on the current Artix version of `glibc`.
For now I've left it this way so I can get back to figuring out CUDA.
Hopefully this helps someone out, happy valgrinding!
