A sample code of how to use Eigen (C++ linear algebra template headers) in Intel SGX. This sample code modifies linux-sgx
's SampleEnclave.
-
Install Intel(R) SGX SDK for Linux* OS
-
Make sure your environment is set:
$ source ${sgx-sdk-install-path}/environment
-
Locate the following files in system directories and copy them over to
Include/intrinsic
. Usually, they are located in gcc's include directory (e.g./usr/lib/gcc/x86_64-linux-gnu/6.5.0/include
).emmintrin.h
mmintrin.h
mm_malloc.h
xmmintrin.h
-
Download Eigen and copy the header templates directory (i.e.
Eigen/
) intoInclude/
. -
Build the project with the prepared Makefile:
a. Hardware Mode, Debug build:
$ make
b. Hardware Mode, Pre-release build:
$ make SGX_PRERELEASE=1 SGX_DEBUG=0
c. Hardware Mode, Release build:
$ make SGX_DEBUG=0
d. Simulation Mode, Debug build:
$ make SGX_MODE=SIM
e. Simulation Mode, Pre-release build:
$ make SGX_MODE=SIM SGX_PRERELEASE=1 SGX_DEBUG=0
f. Simulation Mode, Release build:
$ make SGX_MODE=SIM SGX_DEBUG=0
-
Execute the binary directly:
$ ./app
-
Remember to
make clean
before switching build mode
Copy Include/shim.hpp
to your project. Make sure shim.hpp
, Eigen
, and the files listed in step 3 are all visible during compilation. Any time an Eigen header is #include
'd in a file, make sure to include shim.hpp
above it to expose the fake std
classes.