Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 65 lines 1.8 kB view raw
1{ 2 lib, 3 stdenv, 4 requireFile, 5 nasm, 6}: 7 8let 9 arch = "bandwidth${toString stdenv.hostPlatform.parsed.cpu.bits}"; 10in 11stdenv.mkDerivation (finalAttrs: { 12 pname = "bandwidth"; 13 version = "1.11.2d"; 14 15 src = requireFile { 16 message = "This file does not have a valid url."; 17 name = "bandwidth-${finalAttrs.version}.tar.gz"; 18 hash = "sha256-7IrNiCXKf1vyRGl73Ccu3aYMqPVc4PpEr6lnSqIa4Q8="; 19 }; 20 21 postPatch = '' 22 sed -i 's,ar ,$(AR) ,g' OOC/Makefile 23 # Remove unnecessary -m32 for 32-bit targets 24 sed -i 's,-m32,,g' OOC/Makefile 25 # Replace arm64 with aarch64 26 sed -i 's#,arm64#,aarch64#g' Makefile 27 # Fix wrong comment character 28 sed -i 's,# 32,; 32,g' routines-x86-32bit.asm 29 # Fix missing symbol exports for macOS clang 30 echo global _VectorToVector128 >> routines-x86-64bit.asm 31 echo global _VectorToVector256 >> routines-x86-64bit.asm 32 # Fix unexpected token on macOS 33 sed -i '/.section .note.GNU-stack/d' *-64bit.asm 34 sed -i '/.section code/d' *-arm-64bit.asm 35 sed -i 's#-Wl,-z,noexecstack##g' Makefile-arm64 36 ''; 37 38 nativeBuildInputs = [ nasm ]; 39 40 buildFlags = [ 41 "AR=${stdenv.cc.targetPrefix}ar" 42 "CC=${stdenv.cc.targetPrefix}cc" 43 "ARM_AS=${stdenv.cc.targetPrefix}as" 44 "ARM_CC=$(CC)" 45 "UNAMEPROC=${stdenv.hostPlatform.parsed.cpu.name}" 46 "UNAMEMACHINE=${stdenv.hostPlatform.parsed.cpu.name}" 47 arch 48 ]; 49 50 installPhase = '' 51 runHook preInstall 52 53 install -Dm755 ${arch} $out/bin/bandwidth 54 55 runHook postInstall 56 ''; 57 58 meta = { 59 description = "Artificial benchmark for identifying weaknesses in the memory subsystem"; 60 license = lib.licenses.gpl2Plus; 61 platforms = lib.platforms.x86 ++ lib.platforms.arm ++ lib.platforms.aarch64; 62 maintainers = with lib.maintainers; [ r-burns ]; 63 mainProgram = "bandwidth"; 64 }; 65})