1 { lib, stdenv, fetchurl, nasm }:
4 inherit (stdenv.hostPlatform.parsed.cpu) bits;
5 arch = "bandwidth${toString bits}";
7 stdenv.mkDerivation rec {
12 url = "https://zsmith.co/archives/${pname}-${version}.tar.gz";
13 sha256 = "sha256-mjtvQAOH9rv12XszGdD5hIX197er7Uc74WfVaP32TpM=";
17 sed -i 's,ar ,$(AR) ,g' OOC/Makefile
18 # Remove unnecessary -m32 for 32-bit targets
19 sed -i 's,-m32,,g' OOC/Makefile
20 # Replace arm64 with aarch64
21 sed -i 's#,arm64#,aarch64#g' Makefile
22 # Fix wrong comment character
23 sed -i 's,# 32,; 32,g' routines-x86-32bit.asm
24 # Fix missing symbol exports for macOS clang
25 echo global _VectorToVector128 >> routines-x86-64bit.asm
26 echo global _VectorToVector256 >> routines-x86-64bit.asm
29 nativeBuildInputs = [ nasm ];
32 "AR=${stdenv.cc.targetPrefix}ar"
33 "CC=${stdenv.cc.targetPrefix}cc"
34 "ARM_AS=${stdenv.cc.targetPrefix}as"
36 "UNAMEPROC=${stdenv.hostPlatform.parsed.cpu.name}"
37 "UNAMEMACHINE=${stdenv.hostPlatform.parsed.cpu.name}"
43 cp ${arch} $out/bin/bandwidth
47 homepage = "https://zsmith.co/bandwidth.html";
48 description = "Artificial benchmark for identifying weaknesses in the memory subsystem";
49 license = licenses.gpl2Plus;
50 platforms = platforms.x86 ++ platforms.arm ++ platforms.aarch64;
51 maintainers = with maintainers; [ r-burns ];