【Docker/SGX】fatal error: inc/stat.h: No such file or directory


#1

When I followed the instruction(https://github.com/dmlc/tvm/tree/master/apps/sgx) to run the SGX demo with docker, I successfully pulled the docker image and entered the container, but when I use the make -j4 command, I got a fatal error:

fatal error: inc/stat.h: No such file or directory

This makes me very confused, what should I do?


#2

Hi, I’ve hit this issue before myself. My recollection is that:

The docker build runs ubuntu_install_sgx.sh to install SGX. This script installs two different components:
/opt/sgxsdk
and
/opt/rust-sgx-sdk/

The inc/stat.h file appears to be installed as /opt/rust-sgx-sdk/edl/inc/stat.h.

However in the build system cmake/modules/SGX.cmake has an include_directories declaration that adds $USE_SGX/include but not $RUST_SGX_SDK/edl hence the build fails to find stat.h in the installed location.

It is simple to add ${USE_SGX}/edl to the include_directories directive, but I’m not sure if this is a correct solution, specifically I’m not sure if /opt/sgxsdk is supposed to be exposing a stat.h and that for some reason it is missing from the install.


#3

@nhynes may be able to shed light on this thread.


#4

Thank you so much! @mjs
I don’t understand what you mean by “add ${USE_SGX}/edl to the include_directories”, I made a attempt by adding the code -I${USE_SGX}/edl \, into the 44th line of makefile in tvm/apps/sgx.

just like this:
%E5%9B%BE%E7%89%87

but I when I paste the command
cmake .. -DUSE_LLVM=ON -DUSE_SGX=/opt/sgxsdk -DRUST_SGX_SDK=/opt/rust-sgx-sdk
I got the error
CMake Error: The source directory “/” does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

I did’t see the error in the first time when running the command.

then I paste
make -j4
and got the same error
fatal error: inc/stat.h: No such file or directory

Can you give me a detailed step of how to add ${USE_SGX}/edl to the include_directories, I am new to TVM.
Thank you!


#5

I am having the same error when trying to use the tvmai/ci-cpu Docker image for TVM SGX, using the instructions at: https://github.com/dmlc/tvm/tree/master/apps/sgx

Could you please advise? Thanks in advance!


#6

@mjs or @nhynes could you please help with this issue?
Thanks again!


#7

Hey @xplorer, my sincerest apologies for not replying sooner. I’ve been unusually hosed these last few weeks. I think that you may have found a bug in the current TVM SGX implementation. My suggestion would be to run git checkout d08941f and try running the commands in the SGX README from there. (d08941f is the commit before the frontend was merged). Please let me know if that doesn’t work. Note that, if you need Relay, you can compile the Relay module graph/lib/params using a newer version of TVM and build the enclave using the old version of TVM.

In any case, rust-sgx-sdk is less preferable now that the fortanix sgx target has been upstreamed to rustc, itself. I think that I’ll take a whack at porting the sgx build soon. That’ll make the build process much much less brittle.


#8

Thank you very much !@nhynes @xplorer
I have downloaded the new version of TVM and run the readme command again. Everything goes well but the last command ./run_example.sh,


I don’t understand the patch failed error. What should I do?


#9

The issue now is that the runtime fails to compile under SGX now that the frontend is also in there.
Since tvm#2878 has been merged, you can use tvm:master again if you modify apps/sgx/enclave/Cargo.toml:

- tvm = { path = "../../../rust", default-features = false, features = ["sgx"] }
+ tvm = { git = "https://github.com/dmlc/tvm", default-features = false, features = ["sgx"], rev="d08941f" }

If you need to modify the TVM Rust runtime, you can run

$ cd /path/to/tvm && git worktree add ../tvm_sgx_old d08941f

and then add the following lines to apps/sgx/enclave/Cargo.toml

[patch."https://github.com/dmlc/tvm"]
tvm = { path = "/path/to/tvm_sgx_old", default-features = false, features = ["sgx"], rev="d08941f" }

I’m looking forward to properly fixing up the TVM SGX integration in the coming days, but hopefully this patch gets you going in the meantime. Many thanks for your extreme patience!