Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Mar 2026 08:29:50 +0000
From:      Dimitry Andric <dim@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 814f8741c251 - main - science/py-tensorflow: fix build with libc++ 21
Message-ID:  <69b3cafe.3a200.41c98773@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by dim:

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
---
 .../patch-tensorflow_lite_kernels_elementwise.cc   | 22 ++++++++++++++++++++++
 .../patch-tensorflow_tsl_framework_type__traits.h  | 21 +++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/science/py-tensorflow/files/patch-tensorflow_lite_kernels_elementwise.cc b/science/py-tensorflow/files/patch-tensorflow_lite_kernels_elementwise.cc
new file mode 100644
index 000000000000..7fad158af10a
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_lite_kernels_elementwise.cc
@@ -0,0 +1,22 @@
+--- tensorflow/lite/kernels/elementwise.cc.orig	2023-09-12 16:46:28 UTC
++++ tensorflow/lite/kernels/elementwise.cc
+@@ -242,7 +242,8 @@ TfLiteStatus AbsEval(TfLiteContext* context, TfLiteNod
+   const TfLiteType type = input->type;
+   switch (type) {
+     case kTfLiteFloat32:
+-      return EvalImpl<float>(context, node, std::abs<float>, type);
++      return EvalImpl<float>(
++          context, node, [](float f) { return std::abs(f); }, type);
+     case kTfLiteInt8:
+       return AbsEvalQuantized<int8_t>(context, node, type);
+     case kTfLiteInt16:
+@@ -250,7 +251,8 @@ TfLiteStatus AbsEval(TfLiteContext* context, TfLiteNod
+                  ? AbsInt16EvalImpl(context, node, type)
+                  : AbsEvalQuantized<int16_t>(context, node, type);
+     case kTfLiteInt32:
+-      return EvalImpl<int32_t>(context, node, std::abs<int32_t>, type);
++      return EvalImpl<int32_t>(
++          context, node, [](int32_t i) { return std::abs(i); }, type);
+     default:
+       TF_LITE_KERNEL_LOG(context, "Current data type %s is not supported.",
+                          TfLiteTypeGetName(type));
diff --git a/science/py-tensorflow/files/patch-tensorflow_tsl_framework_type__traits.h b/science/py-tensorflow/files/patch-tensorflow_tsl_framework_type__traits.h
new file mode 100644
index 000000000000..8b2cfe43ee49
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_tsl_framework_type__traits.h
@@ -0,0 +1,21 @@
+--- tensorflow/tsl/framework/type_traits.h.orig	2023-09-12 16:46:28 UTC
++++ tensorflow/tsl/framework/type_traits.h
+@@ -91,18 +91,6 @@ class numeric_limits<tsl::qint32> : public numeric_lim
+ template <>
+ class numeric_limits<tsl::qint32> : public numeric_limits<tsl::int32> {};
+ 
+-// Specialize is_signed for quantized types.
+-template <>
+-struct is_signed<tsl::qint8> : public is_signed<tsl::int8> {};
+-template <>
+-struct is_signed<tsl::quint8> : public is_signed<tsl::uint8> {};
+-template <>
+-struct is_signed<tsl::qint16> : public is_signed<tsl::int16> {};
+-template <>
+-struct is_signed<tsl::quint16> : public is_signed<tsl::uint16> {};
+-template <>
+-struct is_signed<tsl::qint32> : public is_signed<tsl::int32> {};
+-
+ }  // namespace std
+ 
+ #endif  // TENSORFLOW_TSL_FRAMEWORK_TYPE_TRAITS_H_


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69b3cafe.3a200.41c98773>