With libc++ 21 science/py-tensorflow fails to build, with errors similar to: In file included from tensorflow/tsl/framework/allocator_registry.cc:16: In file included from ./tensorflow/tsl/framework/allocator_registry.h:23: In file included from ./tensorflow/tsl/framework/allocator.h:28: ./tensorflow/tsl/framework/type_traits.h:96:8: error: 'is_signed' cannot be specialized: Users are not allowed to specialize this standard library entity [-Winvalid-specialization] 96 | struct is_signed<tsl::qint8> : public is_signed<tsl::int8> {}; | ^ /usr/include/c++/v1/__type_traits/is_signed.h:25:8: note: marked '_Clang::no_specializations' here 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_signed : _BoolConstant<__is_signed(_Tp)> {}; | ^ /usr/include/c++/v1/__config:1167:9: note: expanded from macro '_LIBCPP_NO_SPECIALIZATIONS' 1167 | [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]] | ^ and later: tensorflow/lite/kernels/elementwise.cc:245:14: error: no matching function for call to 'EvalImpl' 245 | return EvalImpl<float>(context, node, std::abs<float>, type); | ^~~~~~~~~~~~~~~ tensorflow/lite/kernels/elementwise.cc:192:21: note: candidate function template not viable: no overload of 'abs' matching 'std::function<float (float)>' for 3rd argument 192 | inline TfLiteStatus EvalImpl(TfLiteContext* context, TfLiteNode* node, | ^ 193 | std::function<T(T)> func, | ~~~~~~~~~~~~~~~~~~~~~~~~ The former is fixed by https://github.com/openxla/xla/commit/0cead9f, which unfortunately happened after tsl got split off from tensorflow into a bunch of separate projects. The latter is fixed as part of https://github.com/tensorflow/tensorflow/commit/358119a, but that commit is quite large. Only the changes to elementwise.cc need to be applied.
Created attachment 268297 [details] science/py-tensorflow: fix build with libc++ 21
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=814f8741c251862849f74431be09c0ab969e936a commit 814f8741c251862849f74431be09c0ab969e936a Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2026-02-23 13:18:05 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2026-03-13 08:29:30 +0000 science/py-tensorflow: fix build with libc++ 21 With libc++ 21 science/py-tensorflow fails to build, with errors similar to: In file included from tensorflow/tsl/framework/allocator_registry.cc:16: In file included from ./tensorflow/tsl/framework/allocator_registry.h:23: In file included from ./tensorflow/tsl/framework/allocator.h:28: ./tensorflow/tsl/framework/type_traits.h:96:8: error: 'is_signed' cannot be specialized: Users are not allowed to specialize this standard library entity [-Winvalid-specialization] 96 | struct is_signed<tsl::qint8> : public is_signed<tsl::int8> {}; | ^ /usr/include/c++/v1/__type_traits/is_signed.h:25:8: note: marked '_Clang::no_specializations' here 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_signed : _BoolConstant<__is_signed(_Tp)> {}; | ^ /usr/include/c++/v1/__config:1167:9: note: expanded from macro '_LIBCPP_NO_SPECIALIZATIONS' 1167 | [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]] | ^ and later: tensorflow/lite/kernels/elementwise.cc:245:14: error: no matching function for call to 'EvalImpl' 245 | return EvalImpl<float>(context, node, std::abs<float>, type); | ^~~~~~~~~~~~~~~ tensorflow/lite/kernels/elementwise.cc:192:21: note: candidate function template not viable: no overload of 'abs' matching 'std::function<float (float)>' for 3rd argument 192 | inline TfLiteStatus EvalImpl(TfLiteContext* context, TfLiteNode* node, | ^ 193 | std::function<T(T)> func, | ~~~~~~~~~~~~~~~~~~~~~~~~ The former is fixed by https://github.com/openxla/xla/commit/0cead9f, which unfortunately happened after tsl got split off from tensorflow into a bunch of separate projects. The latter is fixed as part of https://github.com/tensorflow/tensorflow/commit/358119a, but that commit is quite large. Only the changes to elementwise.cc need to be applied. PR: 293384 Approved by: maintainer timeout (2 weeks) MFH: 2026Q1 ...ch-tensorflow_lite_kernels_elementwise.cc (new) | 22 ++++++++++++++++++++++ ...h-tensorflow_tsl_framework_type__traits.h (new) | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+)
A commit in branch 2026Q1 references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=b002c40dc191a929fc18fe6d7e44871a7d082400 commit b002c40dc191a929fc18fe6d7e44871a7d082400 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2026-02-23 13:18:05 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2026-03-13 08:32:47 +0000 science/py-tensorflow: fix build with libc++ 21 With libc++ 21 science/py-tensorflow fails to build, with errors similar to: In file included from tensorflow/tsl/framework/allocator_registry.cc:16: In file included from ./tensorflow/tsl/framework/allocator_registry.h:23: In file included from ./tensorflow/tsl/framework/allocator.h:28: ./tensorflow/tsl/framework/type_traits.h:96:8: error: 'is_signed' cannot be specialized: Users are not allowed to specialize this standard library entity [-Winvalid-specialization] 96 | struct is_signed<tsl::qint8> : public is_signed<tsl::int8> {}; | ^ /usr/include/c++/v1/__type_traits/is_signed.h:25:8: note: marked '_Clang::no_specializations' here 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_signed : _BoolConstant<__is_signed(_Tp)> {}; | ^ /usr/include/c++/v1/__config:1167:9: note: expanded from macro '_LIBCPP_NO_SPECIALIZATIONS' 1167 | [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]] | ^ and later: tensorflow/lite/kernels/elementwise.cc:245:14: error: no matching function for call to 'EvalImpl' 245 | return EvalImpl<float>(context, node, std::abs<float>, type); | ^~~~~~~~~~~~~~~ tensorflow/lite/kernels/elementwise.cc:192:21: note: candidate function template not viable: no overload of 'abs' matching 'std::function<float (float)>' for 3rd argument 192 | inline TfLiteStatus EvalImpl(TfLiteContext* context, TfLiteNode* node, | ^ 193 | std::function<T(T)> func, | ~~~~~~~~~~~~~~~~~~~~~~~~ The former is fixed by https://github.com/openxla/xla/commit/0cead9f, which unfortunately happened after tsl got split off from tensorflow into a bunch of separate projects. The latter is fixed as part of https://github.com/tensorflow/tensorflow/commit/358119a, but that commit is quite large. Only the changes to elementwise.cc need to be applied. PR: 293384 Approved by: maintainer timeout (2 weeks) MFH: 2026Q1 (cherry picked from commit 814f8741c251862849f74431be09c0ab969e936a) ...ch-tensorflow_lite_kernels_elementwise.cc (new) | 22 ++++++++++++++++++++++ ...h-tensorflow_tsl_framework_type__traits.h (new) | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+)