summary refs log tree commit diff
path: root/pkgs/development/libraries/xsimd/default.nix
blob: 8b53db0388fe152db95781f68f626363c0c95d46 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ lib
, stdenv
, fetchFromGitHub
, cmake
, doctest
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "xsimd";
  version = "11.1.0";
  src = fetchFromGitHub {
    owner = "xtensor-stack";
    repo = "xsimd";
    rev = finalAttrs.version;
    sha256 = "sha256-l6IRzndjb95hIcFCCm8zmlNHWtKduqy2t/oml/9Xp+w=";
  };
  patches = [
    # Ideally, Accelerate/Accelerate.h should be used for this implementation,
    # but it doesn't work... Needs a Darwin user to debug this. We apply this
    # patch unconditionally, because the #if macros make sure it doesn't
    # interfer with the Linux implementations.
    ./fix-darwin-exp10-implementation.patch
  ] ++ lib.optionals stdenv.isDarwin [
    # https://github.com/xtensor-stack/xsimd/issues/807
    ./disable-test_error_gamma-test.patch
  ] ++ lib.optionals (stdenv.isDarwin || stdenv.hostPlatform.isMusl) [
    # - Darwin report: https://github.com/xtensor-stack/xsimd/issues/917
    # - Musl   report: https://github.com/xtensor-stack/xsimd/issues/798
    ./disable-exp10-test.patch
  ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
    # https://github.com/xtensor-stack/xsimd/issues/798
    ./disable-polar-test.patch
  ] ++ lib.optionals stdenv.hostPlatform.isMusl [
    # Fix suggested here: https://github.com/xtensor-stack/xsimd/issues/798#issuecomment-1356884601
    # Upstream didn't merge that from some reason.
    ./fix-atan-test.patch
  ];

  nativeBuildInputs = [
    cmake
  ];

  cmakeFlags = [
    "-DBUILD_TESTS=${if (finalAttrs.doCheck && stdenv.hostPlatform == stdenv.buildPlatform) then "ON" else "OFF"}"
  ];

  doCheck = true;
  nativeCheckInputs = [
    doctest
  ];
  checkTarget = "xtest";

  meta = with lib; {
    description = "C++ wrappers for SIMD intrinsics";
    homepage = "https://github.com/xtensor-stack/xsimd";
    license = licenses.bsd3;
    maintainers = with maintainers; [ tobim ];
    platforms = platforms.all;
  };
})