2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv, fetchurl, nasm }:
|
2015-04-23 21:45:34 +00:00
|
|
|
|
|
|
|
let
|
2020-11-10 04:12:31 +00:00
|
|
|
inherit (stdenv.hostPlatform.parsed.cpu) bits;
|
|
|
|
arch = "bandwidth${toString bits}";
|
2015-04-23 21:45:34 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "bandwidth";
|
2023-03-17 09:14:06 +00:00
|
|
|
version = "1.11.2d";
|
2015-04-23 21:45:34 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2024-08-21 00:23:37 +00:00
|
|
|
url = "https://zsmith.co/archives/bandwidth-${version}.tar.gz";
|
2023-03-17 09:14:06 +00:00
|
|
|
hash = "sha256-7IrNiCXKf1vyRGl73Ccu3aYMqPVc4PpEr6lnSqIa4Q8=";
|
2015-04-23 21:45:34 +00:00
|
|
|
};
|
|
|
|
|
2020-11-10 04:12:31 +00:00
|
|
|
postPatch = ''
|
|
|
|
sed -i 's,ar ,$(AR) ,g' OOC/Makefile
|
2021-09-09 03:17:19 +00:00
|
|
|
# Remove unnecessary -m32 for 32-bit targets
|
|
|
|
sed -i 's,-m32,,g' OOC/Makefile
|
2022-11-03 00:41:46 +00:00
|
|
|
# Replace arm64 with aarch64
|
|
|
|
sed -i 's#,arm64#,aarch64#g' Makefile
|
2021-09-09 03:17:19 +00:00
|
|
|
# Fix wrong comment character
|
|
|
|
sed -i 's,# 32,; 32,g' routines-x86-32bit.asm
|
|
|
|
# Fix missing symbol exports for macOS clang
|
|
|
|
echo global _VectorToVector128 >> routines-x86-64bit.asm
|
|
|
|
echo global _VectorToVector256 >> routines-x86-64bit.asm
|
2023-03-17 09:14:06 +00:00
|
|
|
# Fix unexpected token on macOS
|
|
|
|
sed -i '/.section .note.GNU-stack/d' *-64bit.asm
|
|
|
|
sed -i '/.section code/d' *-arm-64bit.asm
|
|
|
|
sed -i 's#-Wl,-z,noexecstack##g' Makefile-arm64
|
2020-11-10 04:12:31 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [ nasm ];
|
2015-04-23 21:45:34 +00:00
|
|
|
|
2021-09-09 03:17:19 +00:00
|
|
|
buildFlags = [
|
|
|
|
"AR=${stdenv.cc.targetPrefix}ar"
|
|
|
|
"CC=${stdenv.cc.targetPrefix}cc"
|
|
|
|
"ARM_AS=${stdenv.cc.targetPrefix}as"
|
|
|
|
"ARM_CC=$(CC)"
|
|
|
|
"UNAMEPROC=${stdenv.hostPlatform.parsed.cpu.name}"
|
|
|
|
"UNAMEMACHINE=${stdenv.hostPlatform.parsed.cpu.name}"
|
|
|
|
arch
|
|
|
|
];
|
2015-04-23 21:45:34 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
2020-11-10 04:12:31 +00:00
|
|
|
cp ${arch} $out/bin/bandwidth
|
2015-04-23 21:45:34 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://zsmith.co/bandwidth.html";
|
2016-04-02 00:16:31 +00:00
|
|
|
description = "Artificial benchmark for identifying weaknesses in the memory subsystem";
|
2020-11-10 04:12:31 +00:00
|
|
|
license = licenses.gpl2Plus;
|
2021-09-09 03:17:19 +00:00
|
|
|
platforms = platforms.x86 ++ platforms.arm ++ platforms.aarch64;
|
2020-11-10 04:12:31 +00:00
|
|
|
maintainers = with maintainers; [ r-burns ];
|
2023-11-27 01:17:53 +00:00
|
|
|
mainProgram = "bandwidth";
|
2015-04-23 21:45:34 +00:00
|
|
|
};
|
|
|
|
}
|