intel / linux-sgx

Intel SGX for Linux*
https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html
Other
1.32k stars 541 forks source link

I try to use eigen in sgx, but there is an error #848

Open Karssadin opened 2 years ago

Karssadin commented 2 years ago

I copy the code in there but when i run the make, there is an error:

make[1]: 进入目录“/home/liuzilong/Desktop/eigen-sgx”
GEN  =>  App/Enclave_u.h
CC   <=  App/Enclave_u.c
CXX  <=  App/App.cpp
CXX  <=  App/Edger8rSyntax/Types.cpp
CXX  <=  App/Edger8rSyntax/Pointers.cpp
CXX  <=  App/Edger8rSyntax/Arrays.cpp
CXX  <=  App/Edger8rSyntax/Functions.cpp
CXX  <=  App/TrustedLibrary/Thread.cpp
CXX  <=  App/TrustedLibrary/Libc.cpp
CXX  <=  App/TrustedLibrary/Libcxx.cpp
LINK =>  app
GEN  =>  Enclave/Enclave_t.h
CC   <=  Enclave/Enclave_t.c
In file included from Enclave/Enclave.cpp:37:
Include/shim.hpp:27:18: error: reference to ‘ostream’ is ambiguous
   27 |     void copyfmt(ostream& _);
      |                  ^~~~~~~
In file included from /opt/intel/sgxsdk/include/libcxx/string:438,
                 from Include/shim.hpp:4,
                 from Enclave/Enclave.cpp:37:
/opt/intel/sgxsdk/include/libcxx/iosfwd:147:38: note: candidates are: ‘typedef class std::__1::basic_ostream<char> std::__1::ostream’
  147 | typedef basic_ostream<char>          ostream;
      |                                      ^~~~~~~
In file included from Enclave/Enclave.cpp:37:
Include/shim.hpp:17:7: note:                 ‘class std::ostream’
   17 | class ostream {
      |       ^~~~~~~
Include/shim.hpp:27:18: error: ‘ostream’ has not been declared
   27 |     void copyfmt(ostream& _);
      |                  ^~~~~~~
In file included from Include/intrinsic/emmintrin.h:31,
                 from Include/Eigen/Core:195,
                 from Include/Eigen/Dense:1,
                 from Enclave/Enclave.cpp:38:
Include/intrinsic/xmmintrin.h: In function ‘__m128 _mm_load_ps(const float*)’:
Include/intrinsic/xmmintrin.h:927:21: warning: cast from type ‘const float*’ to type ‘__m128*’ {aka ‘__vector(4) float*’} casts away qualifiers [-Wcast-qual]
  927 |   return *(__m128 *)__P;
      |                     ^~~
Include/intrinsic/xmmintrin.h: In function ‘__m128 _mm_loadu_ps(const float*)’:
Include/intrinsic/xmmintrin.h:934:23: warning: cast from type ‘const float*’ to type ‘__m128_u*’ {aka ‘__vector(4) float*’} casts away qualifiers [-Wcast-qual]
  934 |   return *(__m128_u *)__P;
      |                       ^~~
Include/intrinsic/xmmintrin.h: In function ‘__m128 _mm_loadr_ps(const float*)’:
Include/intrinsic/xmmintrin.h:941:29: warning: cast from type ‘const float*’ to type ‘__v4sf*’ {aka ‘__vector(4) float*’} casts away qualifiers [-Wcast-qual]
  941 |   __v4sf __tmp = *(__v4sf *)__P;
      |                             ^~~
In file included from Include/Eigen/Core:195,
                 from Include/Eigen/Dense:1,
                 from Enclave/Enclave.cpp:38:
Include/intrinsic/emmintrin.h: In function ‘__m128d _mm_load_pd(const double*)’:
Include/intrinsic/emmintrin.h:124:22: warning: cast from type ‘const double*’ to type ‘__m128d*’ {aka ‘__vector(2) double*’} casts away qualifiers [-Wcast-qual]
  124 |   return *(__m128d *)__P;
      |                      ^~~
Include/intrinsic/emmintrin.h: In function ‘__m128d _mm_loadu_pd(const double*)’:
Include/intrinsic/emmintrin.h:131:24: warning: cast from type ‘const double*’ to type ‘__m128d_u*’ {aka ‘__vector(2) double*’} casts away qualifiers [-Wcast-qual]
  131 |   return *(__m128d_u *)__P;
      |                        ^~~
Include/intrinsic/emmintrin.h: In function ‘__m128i _mm_loadl_epi64(const __m128i_u*)’:
Include/intrinsic/emmintrin.h:709:49: warning: cast from type ‘const __m128i_u*’ {aka ‘const __vector(2) long long int*’} to type ‘__m64_u*’ {aka ‘__vector(2) int*’} casts away qualifiers [-Wcast-qual]
  709 |   return _mm_set_epi64 ((__m64)0LL, *(__m64_u *)__P);
      |                                                 ^~~
Include/intrinsic/emmintrin.h: In function ‘__m128i _mm_loadu_si64(const void*)’:
Include/intrinsic/emmintrin.h:715:40: warning: cast from type ‘const void*’ to type ‘__m128i_u*’ {aka ‘__vector(2) long long int*’} casts away qualifiers [-Wcast-qual]
  715 |   return _mm_loadl_epi64 ((__m128i_u *)__P);
      |                                        ^~~
In file included from Include/Eigen/Core:367,
                 from Include/Eigen/Dense:1,
                 from Enclave/Enclave.cpp:38:
Include/Eigen/src/Core/util/XprHelper.h: At global scope:
Include/Eigen/src/Core/util/XprHelper.h:226:55: warning: conversion from ‘long unsigned int’ to ‘int’ may change value [-Wconversion]
  226 |   enum { value = compute_default_alignment_helper<Size*sizeof(T),EIGEN_MAX_STATIC_ALIGN_BYTES>::value };
      |                                                   ~~~~^~~~~~~~~~
In file included from Include/Eigen/Core:411,
                 from Include/Eigen/Dense:1,
                 from Enclave/Enclave.cpp:38:
Include/Eigen/src/Core/arch/CUDA/Half.h:526:21: error: reference to ‘ostream’ is ambiguous
  526 | EIGEN_ALWAYS_INLINE std::ostream& operator << (std::ostream& os, const half& v) {
      |                     ^~~
In file included from /opt/intel/sgxsdk/include/libcxx/string:438,
                 from Include/shim.hpp:4,
                 from Enclave/Enclave.cpp:37:
/opt/intel/sgxsdk/include/libcxx/iosfwd:147:38: note: candidates are: ‘typedef class std::__1::basic_ostream<char> std::__1::ostream’
  147 | typedef basic_ostream<char>          ostream;
      |                                      ^~~~~~~
In file included from Enclave/Enclave.cpp:37:
Include/shim.hpp:17:7: note:                 ‘class std::ostream’
   17 | class ostream {
      |       ^~~~~~~
In file included from Include/Eigen/Core:433,
                 from Include/Eigen/Dense:1,
                 from Enclave/Enclave.cpp:38:
Include/Eigen/src/Core/IO.h:22:1: error: reference to ‘ostream’ is ambiguous
   22 | std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt);
      | ^~~
In file included from /opt/intel/sgxsdk/include/libcxx/string:438,
                 from Include/shim.hpp:4,
                 from Enclave/Enclave.cpp:37:
/opt/intel/sgxsdk/include/libcxx/iosfwd:147:38: note: candidates are: ‘typedef class std::__1::basic_ostream<char> std::__1::ostream’
  147 | typedef basic_ostream<char>          ostream;
      |                                      ^~~~~~~
In file included from Enclave/Enclave.cpp:37:
Include/shim.hpp:17:7: note:                 ‘class std::ostream’
   17 | class ostream {
      |       ^~~~~~~
In file included from Include/Eigen/Core:433,
                 from Include/Eigen/Dense:1,
                 from Enclave/Enclave.cpp:38:
Include/Eigen/src/Core/IO.h:102:12: error: reference to ‘ostream’ is ambiguous
  102 |     friend std::ostream & operator << (std::ostream & s, const WithFormat& wf)
      |            ^~~
In file included from /opt/intel/sgxsdk/include/libcxx/string:438,
                 from Include/shim.hpp:4,
                 from Enclave/Enclave.cpp:37:
/opt/intel/sgxsdk/include/libcxx/iosfwd:147:38: note: candidates are: ‘typedef class std::__1::basic_ostream<char> std::__1::ostream’
  147 | typedef basic_ostream<char>          ostream;
      |                                      ^~~~~~~
In file included from Enclave/Enclave.cpp:37:
Include/shim.hpp:17:7: note:                 ‘class std::ostream’
   17 | class ostream {
      |       ^~~~~~~
In file included from Include/Eigen/Core:433,
                 from Include/Eigen/Dense:1,
                 from Enclave/Enclave.cpp:38:
Include/Eigen/src/Core/IO.h:129:1: error: reference to ‘ostream’ is ambiguous
  129 | std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt)
      | ^~~
In file included from /opt/intel/sgxsdk/include/libcxx/string:438,
                 from Include/shim.hpp:4,
                 from Enclave/Enclave.cpp:37:
/opt/intel/sgxsdk/include/libcxx/iosfwd:147:38: note: candidates are: ‘typedef class std::__1::basic_ostream<char> std::__1::ostream’
  147 | typedef basic_ostream<char>          ostream;
      |                                      ^~~~~~~
In file included from Enclave/Enclave.cpp:37:
Include/shim.hpp:17:7: note:                 ‘class std::ostream’
   17 | class ostream {
      |       ^~~~~~~
In file included from Include/Eigen/Core:433,
                 from Include/Eigen/Dense:1,
                 from Enclave/Enclave.cpp:38:
Include/Eigen/src/Core/IO.h:216:1: error: reference to ‘ostream’ is ambiguous
  216 | std::ostream & operator <<
      | ^~~
In file included from /opt/intel/sgxsdk/include/libcxx/string:438,
                 from Include/shim.hpp:4,
                 from Enclave/Enclave.cpp:37:
/opt/intel/sgxsdk/include/libcxx/iosfwd:147:38: note: candidates are: ‘typedef class std::__1::basic_ostream<char> std::__1::ostream’
  147 | typedef basic_ostream<char>          ostream;
      |                                      ^~~~~~~
In file included from Enclave/Enclave.cpp:37:
Include/shim.hpp:17:7: note:                 ‘class std::ostream’
   17 | class ostream {
      |       ^~~~~~~
In file included from Include/Eigen/Geometry:47,
                 from Include/Eigen/Dense:6,
                 from Enclave/Enclave.cpp:38:
Include/Eigen/src/Geometry/Hyperplane.h:48:69: warning: conversion from ‘Eigen::Hyperplane<_Scalar, _AmbientDim, Options>::Index’ {aka ‘long int’} to ‘int’ may change value [-Wconversion]
   48 |                     : Index(AmbientDimAtCompileTime)+1,1,Options> Coefficients;
      |                                                                 ^

make[1]: *** [Makefile:255:Enclave/Enclave.o] 错误 1
make[1]: 离开目录“/home/liuzilong/Desktop/eigen-sgx”
make: *** [Makefile:184:all] 错误 2

how to fix it

llly commented 2 years ago

Try remove ‘ostream’ in Include/shim.hpp:27:18: because ‘ostream’ is already defined in SGX SDK headers. If it doesn't work, you need to update the code by yourself. It's years ago.

taserghar commented 1 year ago

To any future visitors, I want to share that I resolved all issues by removing classes from Shim that were already present in the latest SGX SDK. After doing so, everything worked perfectly.

Thanks