README 2.0 KB

123456789101112131415161718192021222324252627282930
  1. Please, download the latest gperftools code from: https://github.com/gperftools/gperftools
  2. The Intel(R) Software Guard Extensions (Intel(R) SGX) tcmalloc is based on gperftools-2.5 (the latest version avaialble at the release date).
  3. Do the following to enable tcmalloc in Intel(R) SGX:
  4. 1. Copy libsgx_tcmalloc.a to the Intel(R) SGX SDK installation directory.
  5. 2. Add "-Wl,--whole-archive -lsgx_tcmalloc -Wl,--no-whole-archive" into enclave linking options in the Makefile.
  6. For example:
  7. Enclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \
  8. -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
  9. -Wl,--whole-archive -lsgx_tcmalloc -Wl,--no-whole-archive \
  10. -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \
  11. -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \
  12. -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \
  13. -Wl,--defsym,__ImageBase=0 \
  14. -Wl,--version-script=Enclave/Enclave.lds
  15. NOTE: The flags "-Wl,--whole-archive -lsgx_tcmalloc -Wl,--no-whole-archive" must be inserted before "-Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -Wl,--end-group".
  16. Otherwise, the enclave build will fail.
  17. 3. Set the enclave HeapMaxSize equal or larger than 0x900000 in Enclave.config.xml. For example:
  18. <HeapMaxSize>0x900000</HeapMaxSize>
  19. Intel(R) SGX includes two C++ libs - C++ 11 and C++ stlport.
  20. Intel(R) SGX tcmalloc build uses one of the C++ libs and can be configured by editing "./gperftools-2.5/autogen-linux.sh".
  21. 1. Build with C++ 11:
  22. CPPFLAGS="-I../../../common/inc -I../../../common/inc/tlibc -I../../../common/inc/internal/ -I../../../sdk/tlibcxx/include -I../../../sdk/trts/"
  23. 2. Build with C++ stlport:
  24. CPPFLAGS="-I../../../common/inc -I../../../common/inc/tlibc -I../../../common/inc/internal/ -I../../../sdk/tlibstdcxx/stlport -I../../../sdk/trts/"
  25. NOTE: The target Enclave project's link C++ lib must the same as Intel(R) SGX tcmalloc build C++ lib. Otherwise, the target enclave build will fail.