lol
at 23.11-beta 57 lines 1.7 kB view raw
1{ lib, stdenv, fetchurl, nasm }: 2 3let 4 inherit (stdenv.hostPlatform.parsed.cpu) bits; 5 arch = "bandwidth${toString bits}"; 6in 7stdenv.mkDerivation rec { 8 pname = "bandwidth"; 9 version = "1.11.2d"; 10 11 src = fetchurl { 12 url = "https://zsmith.co/archives/${pname}-${version}.tar.gz"; 13 hash = "sha256-7IrNiCXKf1vyRGl73Ccu3aYMqPVc4PpEr6lnSqIa4Q8="; 14 }; 15 16 postPatch = '' 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 27 # Fix unexpected token on macOS 28 sed -i '/.section .note.GNU-stack/d' *-64bit.asm 29 sed -i '/.section code/d' *-arm-64bit.asm 30 sed -i 's#-Wl,-z,noexecstack##g' Makefile-arm64 31 ''; 32 33 nativeBuildInputs = [ nasm ]; 34 35 buildFlags = [ 36 "AR=${stdenv.cc.targetPrefix}ar" 37 "CC=${stdenv.cc.targetPrefix}cc" 38 "ARM_AS=${stdenv.cc.targetPrefix}as" 39 "ARM_CC=$(CC)" 40 "UNAMEPROC=${stdenv.hostPlatform.parsed.cpu.name}" 41 "UNAMEMACHINE=${stdenv.hostPlatform.parsed.cpu.name}" 42 arch 43 ]; 44 45 installPhase = '' 46 mkdir -p $out/bin 47 cp ${arch} $out/bin/bandwidth 48 ''; 49 50 meta = with lib; { 51 homepage = "https://zsmith.co/bandwidth.html"; 52 description = "Artificial benchmark for identifying weaknesses in the memory subsystem"; 53 license = licenses.gpl2Plus; 54 platforms = platforms.x86 ++ platforms.arm ++ platforms.aarch64; 55 maintainers = with maintainers; [ r-burns ]; 56 }; 57}