Skip to content

Commit 693bc49

Browse files
dmjioclaude
andcommitted
CI: build via nix build -L, drop brew and cabal flow
Replace the cabal-in-devShell test flow with `nix build -L`, which builds the package derivation and runs the hspec suite in its checkPhase. Drop the redundant `brew install arrayfire` (ArrayFire is provided by the flake's .pkg-based darwin build) and pin macOS to macos-13 since ArrayFire only ships an x86_64 macOS binary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent cc65036 commit 693bc49

2 files changed

Lines changed: 31 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,16 @@ jobs:
1212
build:
1313
strategy:
1414
matrix:
15-
os: [ubuntu-latest, macos-latest] # Add macOS to the matrix
15+
# macos-13 is the last x86_64 runner; ArrayFire only ships an x86_64
16+
# macOS binary, so the flake has no aarch64-darwin (macos-latest) build.
17+
os: [ubuntu-latest, macos-13]
1618
runs-on: ${{ matrix.os }}
1719
steps:
1820
- uses: actions/checkout@v4
1921

20-
- name: Install ArrayFire (macOS)
21-
if: runner.os == 'macOS'
22-
run: |
23-
set -euo pipefail
24-
brew install arrayfire
25-
# The cabal file's OSX default paths are hardcoded to /opt/arrayfire;
26-
# point them at the Homebrew install so the build finds the headers,
27-
# libs, and rpath.
28-
sudo ln -sfn "$(brew --prefix arrayfire)" /opt/arrayfire
29-
3022
- uses: cachix/install-nix-action@v31
3123
with:
3224
nix_path: nixpkgs=channel:nixpkgs-unstable
3325

34-
- name: Nix channel --update
35-
run: nix-channel --update
36-
37-
- name: Cabal update
38-
run: nix develop --command bash -c 'cabal update'
39-
4026
- name: Build and run tests
41-
run: nix develop --command bash -c 'cabal install hspec-discover && cabal test'
27+
run: nix build -L

flake.nix

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@
5050
mkdir -p $out
5151
bash $src --exclude-subdir --prefix=$out
5252
'';
53+
# autoPatchelfIgnoreMissingDeps silences missing-dep errors at build time,
54+
# but a genuinely-absent dep of libafcpu.so would still make its runtime
55+
# dlopen fail with LoadLibError. Fail the build loudly if the CPU backend
56+
# has any unresolved (=> not just intentionally-ignored GPU) dependencies.
57+
doInstallCheck = true;
58+
installCheckPhase = ''
59+
libdir=$out/lib64
60+
[ -d "$libdir" ] || libdir=$out/lib
61+
cpu=$(echo "$libdir"/libafcpu.so* | tr ' ' '\n' | head -n1)
62+
echo "Checking runtime deps of $cpu"
63+
if ldd "$cpu" | grep -i 'not found'; then
64+
echo "ERROR: libafcpu.so has unresolved dependencies" >&2
65+
exit 1
66+
fi
67+
'';
5368
meta = {
5469
description = "A general-purpose library for parallel and massively-parallel architectures";
5570
platforms = [ "x86_64-linux" ];
@@ -155,7 +170,18 @@
155170
export DYLD_LIBRARY_PATH="${self.arrayfire}/lib''${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
156171
'';
157172
})
158-
else pkg;
173+
# On Linux we link against the unified backend (libaf), which is
174+
# just a dispatcher that dlopens the real backend impl
175+
# (libafcpu.so) at runtime. The sandboxed check phase has no
176+
# LD_LIBRARY_PATH/AF_PATH, so that dlopen finds nothing and every
177+
# test throws AFException LoadLibError (501). Point the loader at
178+
# the arrayfire libs so the backend can be found.
179+
else pkg.overrideAttrs (old: {
180+
preCheck = (old.preCheck or "") + ''
181+
export AF_PATH="${self.arrayfire}"
182+
export LD_LIBRARY_PATH="${self.arrayfire}/lib:${self.arrayfire}/lib64''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
183+
'';
184+
});
159185
});
160186
};
161187
};

0 commit comments

Comments
 (0)