Automated Valgrind build script with advanced compiler optimizations using Intel oneAPI compilers. Designed for users who want a more performant Valgrind installation.
This project provides an optimized build script for Valgrind that leverages Intel's oneAPI compilers (ICX/ICPX) to produce a more performant binary through:
- Profile-Guided Optimization (PGO) - Uses runtime profiling to optimize hot paths
- Link-Time Optimization (LTO) - Enables whole-program optimization across translation units
- Intel-specific flags - Utilizes
-march=native,-ffast-math, vectorization, and other Intel compiler optimizations
curl -fsSL https://raw.githubusercontent.com/TheValiant/icx-valgrind/main/install.sh | bashThen restart your terminal or source your shell configuration:
source ~/.bashrc # or ~/.zshrc- Intel oneAPI Base Toolkit (includes ICX compiler)
- Standard build tools (make, autoconf)
- LLVM tools (llvm-ar, llvm-ranlib, lld)
- Internet connection (downloads Valgrind source)
On Linux:
# Add Intel repository
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | sudo apt-key add -
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
# Install base toolkit
sudo apt install intel-basekitOn macOS (Intel):
# Install via installer from Intel's website
# https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html- Pre-flight checks - Verifies Intel compilers and required tools are available
- Downloads Valgrind - Fetches the latest stable Valgrind release (3.25.1)
- Stage 1 Build - Compiles with basic optimizations
- PGO Training - Runs benchmark suite to generate optimization profile
- Stage 2 Build - Recompiles with PGO data and full LTO enabled
- Installation - Installs to
~/.local/bin/valgrind - PATH Setup - Automatically updates shell configuration files
-O3 -pipe -fp-model=fast -march=native-O3 -pipe -fp-model=fast -march=native -static -ffast-math
-funroll-loops -fvectorize -vec -flto=full
-fprofile-instr-use=<profile_data>If you prefer to run the build manually or need to customize:
git clone https://github.com/TheValiant/icx-valgrind.git
cd icx-valgrind
chmod +x install.sh
./install.sh --verbose--verbose,-v- Enable verbose build output--help,-h- Show usage information
After installation, verify the optimized build:
which valgrind
# Should show: ~/.local/bin/valgrind
valgrind --version
# Shows installed version
# Check for LTO in binary
readelf -p .comment ~/.local/bin/valgrindFor systems without Intel compilers, a GCC fallback script is provided:
./gcc.shThis uses GCC with similar optimization flags but without Intel-specific optimizations.
- Build takes approximately 15-30 minutes depending on system
- Requires ~500MB of temporary disk space during build
- PGO training phase runs Valgrind against a comprehensive test suite
- The script is idempotent and safe to re-run
Ensure you've sourced the oneAPI environment:
source /opt/intel/oneapi/setvars.shLTO requires matching versions of compiler tools. Ensure llvm-ar, llvm-ranlib, and lld are from the Intel oneAPI installation.
Reduce parallel jobs by editing the script to use make -j4 instead of make -j$(nproc).
This project is provided as-is. Valgrind itself is licensed under GPLv2.