Bug 247939 - biology/treekin: does not build with lapacke 3.9.0
Summary: biology/treekin: does not build with lapacke 3.9.0
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Victorovich
URL:
Keywords:
Depends on:
Blocks: 247542
  Show dependency treegraph
 
Reported: 2020-07-12 20:55 UTC by Thierry Thomas
Modified: 2020-07-21 20:05 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (yuri)


Attachments
Log of treekin vs lapacke-3.9.0 (45.26 KB, text/plain)
2020-07-12 20:55 UTC, Thierry Thomas
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry Thomas freebsd_committer freebsd_triage 2020-07-12 20:55:13 UTC
Created attachment 216410 [details]
Log of treekin vs lapacke-3.9.0

biology/treekin builds fine with the version of lapacke in the ports tree (3.5.0_8), but if fails with the current version (3.9.0) proposed in PR 247542:

checking for mlapack... no
configure: WARNING:
**********************************************************************
Failed to setup linking the program against the MLAPACK library.

In case you have installed mlapack in a non-standard directory, consider
using the

  --with-mlapack=/path/to/mlapack

parameter to specify the location where to find MLAPACK.
Otherwise, you can obtain the mlapack library from

https://github.com/RaumZeit/mlapack

**********************************************************************

and further:

In file included from calcpp.cpp:6:
In file included from ./calcpp.h:52:
In file included from /usr/local/include/lapacke/lapacke.h:37:
In file included from /usr/local/include/lapacke/lapack.h:55:
In file included from /usr/include/c++/v1/complex.h:28:
In file included from /usr/include/c++/v1/ccomplex:20:
In file included from /usr/include/c++/v1/complex:244:
In file included from /usr/include/c++/v1/stdexcept:45:
/usr/include/c++/v1/exception:167:1: error: templates must have C++ linkage
template<class _Ep>
^~~~~~~~~~~~~~~~~~~
/usr/local/include/lapacke/lapack.h:16:1: note: extern "C" language linkage specification begins here
extern "C" {
^
In file included from calcpp.cpp:6:
In file included from ./calcpp.h:52:
In file included from /usr/local/include/lapacke/lapacke.h:37:
In file included from /usr/local/include/lapacke/lapack.h:55:
In file included from /usr/include/c++/v1/complex.h:28:
In file included from /usr/include/c++/v1/ccomplex:20:
In file included from /usr/include/c++/v1/complex:244:
In file included from /usr/include/c++/v1/stdexcept:45:
/usr/include/c++/v1/exception:250:1: error: templates must have C++ linkage

I have not been able to decide if we have to fix lapacke or treekin.
Yuri, what do you think?
Comment 1 Yuri Victorovich freebsd_committer freebsd_triage 2020-07-21 00:41:43 UTC
Hi Thierry,

/usr/local/include/lapacke.h installed by lapacke-3.5.0_8 contains 'extern "C"' but '#include <complex.h>' isn't within its scope.

This appears to be a bug in lapack-3.9.0 that it includes C++ headers inside of the extern "C" block (through putting #include <complex.h> into the extern "C" block).

IMO, you should generate a minimal testcase showcasing this problem and report it to the lapack's upstream.


Best,
Yuri
Comment 2 Thierry Thomas freebsd_committer freebsd_triage 2020-07-21 20:05:13 UTC
This problem has already been reported upstream: see
https://github.com/Reference-LAPACK/lapack/issues/320

and also in OpenBLAS, which installs the same lapacke.h: see
https://github.com/xianyi/OpenBLAS/pull/1999/commits/1391fc46d2c38bb74ed69b7a527ab8865161c915

I applied this proposed patch in math/lapack (files/patch-LAPACKE_include_lapack.h), but this is not sufficient, and I'm afraid that upstream does not about C++ (this is the reason for math/lapack++).

Thus a small patch must be added to Treekin:

--- src/calcpp.h.orig   2019-06-13 14:11:19 UTC
+++ src/calcpp.h
@@ -49,6 +49,9 @@
 # include <lapacke.h>
 #else
 # ifdef HAVE_LAPACKE_LAPACKE_H
+#   include <complex>
+#   define lapack_complex_float std::complex<float>
+#   define lapack_complex_double std::complex<double>
 #   include <lapacke/lapacke.h>
 # else
 #   ifdef HAVE_OPENBLAS_LAPACKE_H

It has been included in the global patch proposed in PR 247542, and thanks to  # ifdef HAVE_LAPACKE_LAPACKE_H it does not break the current port.