-- Declare explicit template instantiations for BinaryOpNode specializations so -- they are defined only in libdwave-optimization.so (dwave/optimization/src/nodes/binaryop.cpp). -- Without this, each Cython extension module that creates a binary-op node -- instantiates its own copy of the class template, producing a distinct type_info -- object for the same type. libc++'s default type_info comparison then treats -- those copies as different types and cross-DSO dynamic_cast fails on -- FreeBSD/Clang. --- dwave/optimization/include/dwave-optimization/nodes/binaryop.hpp.orig 2026-07-23 12:58:12 UTC +++ dwave/optimization/include/dwave-optimization/nodes/binaryop.hpp @@ -106,4 +106,23 @@ using SubtractNode = BinaryOpNode>; using XorNode = BinaryOpNode>; +// Explicit instantiations live in dwave/optimization/src/nodes/binaryop.cpp so +// that libdwave-optimization.so owns the canonical type_info objects. Tell +// other translation units (especially the Cython extension modules) not to +// emit their own copies, which would break cross-DSO dynamic_cast on +// FreeBSD/Clang. +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; +extern template class BinaryOpNode>; + } // namespace dwave::optimization