remove cholmod header from extern "C" warpper

Summary

remove cholmod header from extern "C" warpper in CholmodSupport file:

diff --git a/Eigen/CholmodSupport b/Eigen/CholmodSupport
index bed8924d3..78f15598c 100644
--- a/Eigen/CholmodSupport
+++ b/Eigen/CholmodSupport
@@ -12,9 +12,7 @@
 
 #include "src/Core/util/DisableStupidWarnings.h"
 
-extern "C" {
-  #include <cholmod.h>
-}
+#include <cholmod.h>
 
 /** \ingroup Support_modules
   * \defgroup CholmodSupport_Module CholmodSupport module

Environment

  • Operating System : Linux
  • Architecture : x64
  • Eigen Version : 3.4.0
  • Compiler Version : clang-12
  • Compile Flags : -O3 -march=native
  • Vector Extension : SSE/AVX/NEON ...

Minimal Example

//show your code here
#include <Eigen/CholmodSupport>
int main(int argc, char *argv[]) {

  return 0;
}

Steps to reproduce

  1. Build Cholmod with GPU support.
  2. Compile the minimal example.

What is the current bug behavior?

Due to the use of extern "C" wrapper when including cholmod, cublas is included in the block of extern "C" causing compilation issues, which had been reported as a bug in CompilationIssue.

What is the expected correct behavior?

Actually, cholmod has its own way to deal with C++ compilers, see https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/stable/CHOLMOD/Include/cholmod.h. Therefore, just remove extern "C" warpper for cholmod.h at CholmodSupport.

Under Ubuntu22.04 with clang-12 and CUDA 11.3, with the warpper, there will be errors; without the warpper, I could get the minimal demo complied.

Relevant logs

In file included from /tmp//minimal-cholmod-example/main.cc:1:
In file included from /usr/include/eigen3/Eigen/CholmodSupport:16:
In file included from /tmp//minimal-cholmod-example/3rd/include/SuiteSparse/CHOLMOD/cholmod.h:84:
In file included from /tmp//minimal-cholmod-example/3rd/include/SuiteSparse/CHOLMOD/cholmod_core.h:285:
In file included from /usr/include/cublas_v2.h:65:
In file included from /usr/include/cublas_api.h:75:
In file included from /usr/include/cuda_fp16.h:3673:
In file included from /usr/include/cuda_fp16.hpp:67:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/utility:68:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_relops.h:86:5: error: templates must have C++ linkage
    template <class _Tp>
    ^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/CholmodSupport:15:1: note: extern "C" language linkage specification begins here
extern "C" {
^
In file included from /tmp//minimal-cholmod-example/main.cc:1:
In file included from /usr/include/eigen3/Eigen/CholmodSupport:16:
In file included from /tmp//minimal-cholmod-example/3rd/include/SuiteSparse/CHOLMOD/cholmod.h:84:
In file included from /tmp//minimal-cholmod-example/3rd/include/SuiteSparse/CHOLMOD/cholmod_core.h:285:
In file included from /usr/include/cublas_v2.h:65:
In file included from /usr/include/cublas_api.h:75:
In file included from /usr/include/cuda_fp16.h:3673:
In file included from /usr/include/cuda_fp16.hpp:67:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/utility:68:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_relops.h:99:5: error: templates must have C++ linkage
    template <class _Tp>
    ^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/CholmodSupport:15:1: note: extern "C" language linkage specification begins here
extern "C" {
^
  • Have a plan to fix this issue.