at 24.11-pre 73 lines 2.5 kB view raw
1{ lib 2, stdenv 3, cmake 4, ninja 5, gtest 6, fetchFromGitHub 7, fetchpatch 8}: 9 10stdenv.mkDerivation rec { 11 pname = "libhwy"; 12 version = "1.0.7"; 13 14 src = fetchFromGitHub { 15 owner = "google"; 16 repo = "highway"; 17 rev = version; 18 hash = "sha256-Z+mAR9nSAbCskUvo6oK79Yd85bu0HtI2aR5THS1EozM="; 19 }; 20 21 patches = lib.optional stdenv.hostPlatform.isRiscV 22 # Adds CMake option HWY_CMAKE_RVV 23 # https://github.com/google/highway/pull/1743 24 (fetchpatch { 25 name = "libhwy-add-rvv-optout.patch"; 26 url = "https://github.com/google/highway/commit/5d58d233fbcec0c6a39df8186a877329147324b3.patch"; 27 hash = "sha256-ileSNYddOt1F5rooRB0fXT20WkVlnG+gP5w7qJdBuww="; 28 }); 29 30 nativeBuildInputs = [ cmake ninja ]; 31 32 # Required for case-insensitive filesystems ("BUILD" exists) 33 dontUseCmakeBuildDir = true; 34 35 cmakeFlags = let 36 libExt = stdenv.hostPlatform.extensions.library; 37 in [ 38 "-GNinja" 39 "-DCMAKE_INSTALL_LIBDIR=lib" 40 "-DCMAKE_INSTALL_INCLUDEDIR=include" 41 ] ++ lib.optionals doCheck [ 42 "-DHWY_SYSTEM_GTEST:BOOL=ON" 43 "-DGTEST_INCLUDE_DIR=${lib.getDev gtest}/include" 44 "-DGTEST_LIBRARY=${lib.getLib gtest}/lib/libgtest${libExt}" 45 "-DGTEST_MAIN_LIBRARY=${lib.getLib gtest}/lib/libgtest_main${libExt}" 46 ] ++ lib.optionals stdenv.hostPlatform.isAarch32 [ 47 "-DHWY_CMAKE_ARM7=ON" 48 ] ++ lib.optionals stdenv.hostPlatform.isx86_32 [ 49 # Quoting CMakelists.txt: 50 # This must be set on 32-bit x86 with GCC < 13.1, otherwise math_test will be 51 # skipped. For GCC 13.1+, you can also build with -fexcess-precision=standard. 52 # Fixes tests: 53 # HwyMathTestGroup/HwyMathTest.TestAllAtanh/EMU128 54 # HwyMathTestGroup/HwyMathTest.TestAllLog1p/EMU128 55 "-DHWY_CMAKE_SSE2=ON" 56 ] ++ lib.optionals stdenv.hostPlatform.isRiscV [ 57 # Runtime dispatch is not implemented https://github.com/google/highway/issues/838 58 # so tests (and likely normal operation) fail with SIGILL on processors without V. 59 # Until the issue is resolved, we disable RVV completely. 60 "-DHWY_CMAKE_RVV=OFF" 61 ]; 62 63 # hydra's darwin machines run into https://github.com/libjxl/libjxl/issues/408 64 doCheck = !stdenv.hostPlatform.isDarwin; 65 66 meta = with lib; { 67 description = "Performance-portable, length-agnostic SIMD with runtime dispatch"; 68 homepage = "https://github.com/google/highway"; 69 license = with licenses; [ asl20 bsd3 ]; 70 platforms = platforms.unix; 71 maintainers = with maintainers; [ zhaofengli ]; 72 }; 73}