1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, doctest
6}:
7
8stdenv.mkDerivation (finalAttrs: {
9 pname = "xsimd";
10 version = "11.1.0";
11 src = fetchFromGitHub {
12 owner = "xtensor-stack";
13 repo = "xsimd";
14 rev = finalAttrs.version;
15 sha256 = "sha256-l6IRzndjb95hIcFCCm8zmlNHWtKduqy2t/oml/9Xp+w=";
16 };
17 patches = [
18 # Ideally, Accelerate/Accelerate.h should be used for this implementation,
19 # but it doesn't work... Needs a Darwin user to debug this. We apply this
20 # patch unconditionally, because the #if macros make sure it doesn't
21 # interfer with the Linux implementations.
22 ./fix-darwin-exp10-implementation.patch
23 ] ++ lib.optionals stdenv.isDarwin [
24 # https://github.com/xtensor-stack/xsimd/issues/807
25 ./disable-test_error_gamma-test.patch
26 ] ++ lib.optionals (stdenv.isDarwin || stdenv.hostPlatform.isMusl) [
27 # - Darwin report: https://github.com/xtensor-stack/xsimd/issues/917
28 # - Musl report: https://github.com/xtensor-stack/xsimd/issues/798
29 ./disable-exp10-test.patch
30 ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
31 # https://github.com/xtensor-stack/xsimd/issues/798
32 ./disable-polar-test.patch
33 ] ++ lib.optionals stdenv.hostPlatform.isMusl [
34 # Fix suggested here: https://github.com/xtensor-stack/xsimd/issues/798#issuecomment-1356884601
35 # Upstream didn't merge that from some reason.
36 ./fix-atan-test.patch
37 ];
38
39 nativeBuildInputs = [
40 cmake
41 ];
42
43 cmakeFlags = [
44 "-DBUILD_TESTS=${if (finalAttrs.doCheck && stdenv.hostPlatform == stdenv.buildPlatform) then "ON" else "OFF"}"
45 ];
46
47 doCheck = true;
48 nativeCheckInputs = [
49 doctest
50 ];
51 checkTarget = "xtest";
52
53 meta = with lib; {
54 description = "C++ wrappers for SIMD intrinsics";
55 homepage = "https://github.com/xtensor-stack/xsimd";
56 license = licenses.bsd3;
57 maintainers = with maintainers; [ tobim ];
58 platforms = platforms.all;
59 };
60})