Skip to content

Commit a84bbd1

Browse files
Aleksanaaphodina
andauthored
xtensor: Fix darwin build with clang (#393992)
Co-authored-by: Petr Hodina <petr.hodina@luxonis.com>
2 parents 90a1eaf + 05d78e5 commit a84bbd1

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
From 475bedb15252a3732683f3a62c45cc3f1abbab5c Mon Sep 17 00:00:00 2001
2+
From: Mykola Vankovych <mykola.vankovych@biodataanalysis.de>
3+
Date: Tue, 14 Jan 2025 16:48:47 +0100
4+
Subject: [PATCH] Added fixes for building with clang 19 (more strict template
5+
matching rules)
6+
7+
---
8+
include/xtensor/xexpression_traits.hpp | 7 +++----
9+
include/xtensor/xstorage.hpp | 4 ++--
10+
include/xtensor/xutils.hpp | 3 ++-
11+
3 files changed, 7 insertions(+), 7 deletions(-)
12+
13+
diff --git a/include/xtensor/xexpression_traits.hpp b/include/xtensor/xexpression_traits.hpp
14+
index 205de67a5..2f84ae234 100644
15+
--- a/include/xtensor/xexpression_traits.hpp
16+
+++ b/include/xtensor/xexpression_traits.hpp
17+
@@ -103,16 +103,15 @@ namespace xt
18+
using type = xarray<T, L>;
19+
};
20+
21+
-#if defined(__GNUC__) && (__GNUC__ > 6)
22+
-#if __cplusplus == 201703L
23+
+// Workaround for rebind_container problems when C++17 feature is enabled
24+
+#ifdef __cpp_template_template_args
25+
template <template <class, std::size_t, class, bool> class S, class X, std::size_t N, class A, bool Init>
26+
struct xtype_for_shape<S<X, N, A, Init>>
27+
{
28+
template <class T, layout_type L>
29+
using type = xarray<T, L>;
30+
};
31+
-#endif // __cplusplus == 201703L
32+
-#endif // __GNUC__ && (__GNUC__ > 6)
33+
+#endif // __cpp_template_template_args
34+
35+
template <template <class, std::size_t> class S, class X, std::size_t N>
36+
struct xtype_for_shape<S<X, N>>
37+
diff --git a/include/xtensor/xstorage.hpp b/include/xtensor/xstorage.hpp
38+
index ac179a852..fec8e10f3 100644
39+
--- a/include/xtensor/xstorage.hpp
40+
+++ b/include/xtensor/xstorage.hpp
41+
@@ -1637,8 +1637,8 @@ namespace xt
42+
return !(lhs < rhs);
43+
}
44+
45+
-// Workaround for rebind_container problems on GCC 8 with C++17 enabled
46+
-#if defined(__GNUC__) && __GNUC__ > 6 && !defined(__clang__) && __cplusplus >= 201703L
47+
+// Workaround for rebind_container problems when C++17 feature is enabled
48+
+#ifdef __cpp_template_template_args
49+
template <class X, class T, std::size_t N>
50+
struct rebind_container<X, aligned_array<T, N>>
51+
{
52+
diff --git a/include/xtensor/xutils.hpp b/include/xtensor/xutils.hpp
53+
index 9844b0ba7..b8c818efd 100644
54+
--- a/include/xtensor/xutils.hpp
55+
+++ b/include/xtensor/xutils.hpp
56+
@@ -1023,7 +1023,8 @@ namespace xt
57+
using type = C<X, allocator>;
58+
};
59+
60+
-#if defined(__GNUC__) && __GNUC__ > 6 && !defined(__clang__) && __cplusplus >= 201703L
61+
+// Workaround for rebind_container problems when C++17 feature is enabled
62+
+#ifdef __cpp_template_template_args
63+
template <class X, class T, std::size_t N>
64+
struct rebind_container<X, std::array<T, N>>
65+
{
66+

pkgs/by-name/xt/xtensor/package.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ stdenv.mkDerivation (finalAttrs: {
2222
hash = "sha256-hVfdtYcJ6mzqj0AUu6QF9aVKQGYKd45RngY6UN3yOH4=";
2323
};
2424

25+
# See https://github.com/xtensor-stack/xtensor/pull/2821
26+
patches = lib.optionals stdenv.cc.isClang [ ./0001-Fix-clang-build-errors-on-darwin.patch ];
27+
2528
nativeBuildInputs = [
2629
cmake
2730
];

0 commit comments

Comments
 (0)