1 (edited by pc_magas 2017-12-31 07:51:21)

Topic: SGX Compilation issues

I try to compile the wolf ssl with GSX support with SIM mode uver Ubuntu GNU/Linux 16.04 LTS in order to build & run the example in https://github.com/wolfSSL/wolfssl-exam … /SGX_Linux

So far according to the documentation I must compile first the dependency located in https://github.com/wolfSSL/wolfssl/tree … /LINUX-SGX and to do that I must compile the library first in https://github.com/wolfSSL/wolfssl as single threaded according to the documentation. Also I have installed all the SGX dependencies from intel and generally I can run and build applications that run sgx enclaves.

So I order to build the main wolfssl library run the following commands:

./autogen.sh
./configure --enable-examples --enable-crypttests --enable-all --enable-singlethreaded
make

But on the last command I get the follwing error:

make -j2  all-am
make[1]: Entering directory '/home/user/wolfssl'
  CC       src/src_libwolfssl_la-crl.lo
  CC       examples/echoserver/echoserver.o
  CC       examples/server/server.o
src/crl.c: In function ‘InitCRL’:
src/crl.c:62:9: error: implicit declaration of function ‘pthread_cond_init’ [-Werror=implicit-function-declaration]
     if (pthread_cond_init(&crl->cond, 0) != 0) {
         ^
src/crl.c:62:5: error: nested extern declaration of ‘pthread_cond_init’ [-Werror=nested-externs]
     if (pthread_cond_init(&crl->cond, 0) != 0) {
     ^
src/crl.c: In function ‘FreeCRL’:
src/crl.c:174:13: error: implicit declaration of function ‘pthread_join’ [-Werror=implicit-function-declaration]
             pthread_join(crl->tid, NULL);
             ^
src/crl.c:174:13: error: nested extern declaration of ‘pthread_join’ [-Werror=nested-externs]
src/crl.c:179:5: error: implicit declaration of function ‘pthread_cond_destroy’ [-Werror=implicit-function-declaration]
     pthread_cond_destroy(&crl->cond);
     ^
src/crl.c:179:5: error: nested extern declaration of ‘pthread_cond_destroy’ [-Werror=nested-externs]
src/crl.c: In function ‘SignalSetup’:
src/crl.c:506:15: error: implicit declaration of function ‘pthread_cond_signal’ [-Werror=implicit-function-declaration]
         ret = pthread_cond_signal(&crl->cond);
               ^
src/crl.c:506:9: error: nested extern declaration of ‘pthread_cond_signal’ [-Werror=nested-externs]
         ret = pthread_cond_signal(&crl->cond);
         ^
src/crl.c: In function ‘StartMonitorCRL’:
src/crl.c:899:9: error: implicit declaration of function ‘pthread_create’ [-Werror=implicit-function-declaration]
     if (pthread_create(&crl->tid, NULL, DoMonitor, crl) != 0) {
         ^
src/crl.c:899:5: error: nested extern declaration of ‘pthread_create’ [-Werror=nested-externs]
     if (pthread_create(&crl->tid, NULL, DoMonitor, crl) != 0) {
     ^
src/crl.c:911:17: error: implicit declaration of function ‘pthread_cond_wait’ [-Werror=implicit-function-declaration]
             if (pthread_cond_wait(&crl->cond, &crl->crlLock) != 0) {
                 ^
src/crl.c:911:13: error: nested extern declaration of ‘pthread_cond_wait’ [-Werror=nested-externs]
             if (pthread_cond_wait(&crl->cond, &crl->crlLock) != 0) {
             ^
  CC       wolfcrypt/test/testsuite_testsuite_test-test.o
cc1: all warnings being treated as errors
Makefile:3572: recipe for target 'src/src_libwolfssl_la-crl.lo' failed
make[1]: *** [src/src_libwolfssl_la-crl.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/user/wolfssl'
Makefile:2247: recipe for target 'all' failed
make: *** [all] Error 2

So I would like to answer me on these questions:

  • Why I get the error?

  • How to overcome it?

  • Did I use wrong flags in the first place?

Thank you beforehand for your help?

Share

Re: SGX Compilation issues

Hi pc_magas,

It's actually quite simple! We have a define WOLFSSL_SGX that will do the configuration for you see <wolfssl-root>/wolfssl/wolfcrypt/settings.h look for WOLFSSL_SGX section. That is where SINGLE_THREADED will get defined.

All you have to do is browse to <wolfssl-root>/IDE/LINUX_SGX/ directory and run the build or clean commands. I have some simple bash scripts I use to expedite this process when I work with our SGX solution but be sure to checkout the README in that directory so you know what settings I am using and why:

Here is the script I use, I just name is build.sh and then run ./build.sh whenever I need to remake

#!/bin/sh


CFLAGS="-DDEBUG_WOLFSSL"
export CFLAGS=${CFLAGS}

make -f sgx_t_static.mk HAVE_WOLFSSL_BENCHMARK=1 HAVE_WOLFSSL_TEST=1

Here is my clean.sh:

#!/bin/sh

make -f sgx_t_static.mk clean

If you checkout the file sgx_t_static.mk you will see that we are already defining WOLFSSL_SGX for you:

Wolfssl_C_Extra_Flags := -DWOLFSSL_SGX

So just go to that directory, create the file build.sh and then give it executable permissions (chmod 755 build.sh), run it and you will have a static library.

Then go to the wolfssl-examples directory and you can create a similar build-examples.sh and clean-examples.sh, here are the contents of the ones I use, again review the README so you understand what is being set and why.

NOTE: UPDATE ANY LINE CONTAINING <PATH-TO... wolfSSL Root Directory> to match your environment!

build-examples.sh:

#!/bin/sh

make SGX_MODE=HW SGX_PRERELEASE=0 SGX_WOLFSSL_LIB=<PATH-TO... wolfSSL Root Directory>/IDE/LINUX-SGX/ WOLFSSL_ROOT=<PATH-TO... wolfSSL Root Directory> SGX_DEBUG=1 HAVE_WOLFSSL_TEST=1 HAVE_WOLFSSL_BENCHMARK=1 SGX_SDK=/opt/intel/sgxsdk

contents of clean-examples.sh

#!/bin/sh

make clean SGX_MODE=HW SGX_PRERELEASE=0 SGX_WOLFSSL_LIB=<PATH-TO... wolfSSL Root Directory>/IDE/LINUX-SGX/ WOLFSSL_ROOT=<PATH-TO... wolfSSL Root Directory> SGX_DEBUG=1 HAVE_WOLFSSL_TEST=1 HAVE_WOLFSSL_BENCHMARK=1 SGX_SDK=/opt/intel/sgxsdk

Best Regards,

Kaleb