Skip to content

Commit 491d3b2

Browse files
committed
chore: add justfile to build valgrind locally and from upstream
1 parent 2213ad5 commit 491d3b2

2 files changed

Lines changed: 61 additions & 34 deletions

File tree

.github/workflows/codspeed.yml

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ jobs:
1616
benchmark:
1717
- testdata/take_strings-aarch64
1818
valgrind:
19-
- /bin/valgrind
20-
- ../vg-in-place
19+
- "3.26.0"
20+
- "3.25.0"
21+
- "3.24.0"
22+
- "local"
2123
steps:
2224
- uses: actions/checkout@v4
2325
with:
@@ -38,18 +40,9 @@ jobs:
3840
- name: Update apt-get cache
3941
run: sudo apt-get update
4042

41-
# Install upstream Valgrind for comparison
42-
- name: Install upstream Valgrind
43-
run: |
44-
# Macro runners already have valgrind pre-installed, so we have to remove it first
45-
sudo apt-get remove -y valgrind || true
46-
47-
# Install the actual upstream valgrind package
48-
sudo apt-get install -y valgrind
49-
which valgrind
50-
which -a valgrind
51-
/usr/bin/valgrind --version
52-
/bin/valgrind --version
43+
# Remove any existing Valgrind installation to avoid conflicts
44+
- name: Remove existing Valgrind installation
45+
run: sudo apt-get remove -y valgrind || true
5346

5447
- name: Install build dependencies
5548
run: |
@@ -64,27 +57,12 @@ jobs:
6457
docbook-xml \
6558
xsltproc
6659
67-
- name: Run autogen
68-
run: ./autogen.sh
69-
70-
- name: Configure
71-
run: ./configure
72-
73-
- name: Build Valgrind
74-
run: |
75-
make include/vgversion.h
76-
make -j$(nproc) -C VEX
77-
make -j$(nproc) -C coregrind
78-
make -j$(nproc) -C callgrind
60+
- uses: extractions/setup-just@v3
61+
- name: Build Valgrind (${{ matrix.valgrind }})
62+
run: just build ${{ matrix.valgrind }}
7963

8064
- name: Verify Valgrind build
81-
run: |
82-
# Verify that vg-in-place script exists
83-
test -f ./vg-in-place || { echo "vg-in-place not found!"; exit 1; }
84-
# Test valgrind works with vg-in-place
85-
./vg-in-place --version
86-
./vg-in-place --tool=callgrind --help > /dev/null || { echo "callgrind tool not accessible!"; exit 1; }
87-
echo "Valgrind build successful and callgrind tool is accessible"
65+
run: /usr/local/bin/valgrind --version
8866

8967
# Setup benchmarks and run them
9068
- name: Install uv
@@ -100,4 +78,4 @@ jobs:
10078
cache-instruments: false
10179
working-directory: bench
10280
mode: walltime
103-
run: uv run bench.py --binary-path ${{ matrix.benchmark }} --valgrind-path ${{ matrix.valgrind }}
81+
run: uv run bench.py --binary-path ${{ matrix.benchmark }} --valgrind-path /usr/local/bin/valgrind

Justfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Builds a specific valgrind version
2+
# Usage:
3+
# - just build 3.24.0: Downloads the specified version from sourceware.org, builds and installs it
4+
# - just build local: Builds the local Valgrind source in the current directory
5+
build version:
6+
#!/usr/bin/env bash
7+
set -euo pipefail
8+
9+
if [ "{{ version }}" = "local" ]; then
10+
just build-in "."
11+
else
12+
just build-upstream "{{ version }}"
13+
fi
14+
15+
build-in dir:
16+
#!/usr/bin/env bash
17+
set -euo pipefail
18+
cd "{{ dir }}"
19+
20+
# Check if we need to run autogen.sh (for git checkouts)
21+
if [ -f "autogen.sh" ] && [ ! -f "configure" ]; then
22+
./autogen.sh
23+
fi
24+
25+
./configure
26+
make include/vgversion.h
27+
make -j$(nproc) -C VEX
28+
make -j$(nproc) -C coregrind
29+
make -j$(nproc) -C callgrind
30+
echo "Valgrind build complete in {{ dir }}"
31+
32+
# Install Valgrind
33+
sudo make install
34+
/usr/local/bin/valgrind --version
35+
36+
# Download, build and install upstream Valgrind from sourceware.org
37+
build-upstream version:
38+
#!/usr/bin/env bash
39+
set -euo pipefail
40+
41+
# Download and extract upstream Valgrind
42+
mkdir -p /tmp/valgrind-upstream
43+
cd /tmp/valgrind-upstream
44+
rm -rf valgrind-{{ version }}*
45+
wget -q https://sourceware.org/pub/valgrind/valgrind-{{ version }}.tar.bz2
46+
tar -xjf valgrind-{{ version }}.tar.bz2
47+
48+
# Build and install using absolute path
49+
just build-in "/tmp/valgrind-upstream/valgrind-{{ version }}"

0 commit comments

Comments
 (0)