10 stdenv.mkDerivation rec {
14 src = fetchFromGitHub {
18 hash = "sha256-Z+mAR9nSAbCskUvo6oK79Yd85bu0HtI2aR5THS1EozM=";
21 patches = lib.optional stdenv.hostPlatform.isRiscV
22 # Adds CMake option HWY_CMAKE_RVV
23 # https://github.com/google/highway/pull/1743
25 name = "libhwy-add-rvv-optout.patch";
26 url = "https://github.com/google/highway/commit/5d58d233fbcec0c6a39df8186a877329147324b3.patch";
27 hash = "sha256-ileSNYddOt1F5rooRB0fXT20WkVlnG+gP5w7qJdBuww=";
30 hardeningDisable = lib.optionals stdenv.hostPlatform.isAarch64 [
31 # aarch64-specific code gets:
32 # __builtin_clear_padding not supported for variable length aggregates
36 nativeBuildInputs = [ cmake ninja ];
38 # Required for case-insensitive filesystems ("BUILD" exists)
39 dontUseCmakeBuildDir = true;
42 libExt = stdenv.hostPlatform.extensions.library;
45 "-DCMAKE_INSTALL_LIBDIR=lib"
46 "-DCMAKE_INSTALL_INCLUDEDIR=include"
47 ] ++ lib.optionals doCheck [
48 "-DHWY_SYSTEM_GTEST:BOOL=ON"
49 "-DGTEST_INCLUDE_DIR=${lib.getDev gtest}/include"
50 "-DGTEST_LIBRARY=${lib.getLib gtest}/lib/libgtest${libExt}"
51 "-DGTEST_MAIN_LIBRARY=${lib.getLib gtest}/lib/libgtest_main${libExt}"
52 ] ++ lib.optionals stdenv.hostPlatform.isAarch32 [
54 ] ++ lib.optionals stdenv.hostPlatform.isx86_32 [
55 # Quoting CMakelists.txt:
56 # This must be set on 32-bit x86 with GCC < 13.1, otherwise math_test will be
57 # skipped. For GCC 13.1+, you can also build with -fexcess-precision=standard.
59 # HwyMathTestGroup/HwyMathTest.TestAllAtanh/EMU128
60 # HwyMathTestGroup/HwyMathTest.TestAllLog1p/EMU128
62 ] ++ lib.optionals stdenv.hostPlatform.isRiscV [
63 # Runtime dispatch is not implemented https://github.com/google/highway/issues/838
64 # so tests (and likely normal operation) fail with SIGILL on processors without V.
65 # Until the issue is resolved, we disable RVV completely.
69 # hydra's darwin machines run into https://github.com/libjxl/libjxl/issues/408
70 doCheck = !stdenv.hostPlatform.isDarwin;
73 description = "Performance-portable, length-agnostic SIMD with runtime dispatch";
74 homepage = "https://github.com/google/highway";
75 license = with licenses; [ asl20 bsd3 ];
76 platforms = platforms.unix;
77 maintainers = with maintainers; [ zhaofengli ];