apache / incubator-teaclave

Apache Teaclave (incubating) is an open source universal secure computing platform, making computation on privacy-sensitive data safe and simple.
https://teaclave.apache.org
Apache License 2.0
764 stars 158 forks source link

build error while following the document #360

Closed yc-huang closed 4 years ago

yc-huang commented 4 years ago

I'm following the document to try to setup a teeclave environment but failed with build errors, any suggestions? Thanks.


docker run --rm -v $(pwd):/teaclave -w /teaclave \
>   -it teaclave/teaclave-build-ubuntu-1804-sgx-2.9.1:latest \
>    bash -c ". /root/.cargo/env && \
>      . /opt/sgxsdk/environment && \
>      mkdir -p build && cd build && \
>      cmake -DTEST_MODE=ON -DSGX_SIM_MODE=ON .. && \
>      make"
-- Submodule update
SGX_SDK=/opt/sgxsdk
SGX_MODE=SW
RUSTUP_TOOLCHAIN=nightly-2020-04-07
DCAP=OFF
BUILD_TYPE=debug
TEACLAVE_SYMLINKS=/tmp/teaclave_symlinks.viZpdRsKWSuz
-- ====== /teaclave/build/environment GENERATED ======
-- Configuring done
-- Generating done
-- Build files have been written to: /teaclave/build
[  0%] Built target prep
[ 12%] Built target pycomponent
[ 16%] Building sgxlib-teaclave_unit_tests, enclave info to /teaclave/build/intermediate/teaclave_unit_tests_enclave_info.toml
   Compiling sgx_build_helper v0.1.3 (https://github.com/apache/teaclave-sgx-sdk?rev=v1.1.2#31b32336)
   Compiling sgx_types v1.1.2 (https://github.com/apache/teaclave-sgx-sdk?rev=v1.1.2#31b32336)
   Compiling cc v1.0.52
   Compiling autocfg v1.0.0
   Compiling sgx_tstd v1.1.2 (https://github.com/apache/teaclave-sgx-sdk?rev=v1.1.2#31b32336)
   Compiling sgx_alloc v1.1.2 (https://github.com/apache/teaclave-sgx-sdk?rev=v1.1.2#31b32336)
   Compiling sgx_demangle v1.1.2 (https://github.com/apache/teaclave-sgx-sdk?rev=v1.1.2#31b32336)
   Compiling proc-macro2 v1.0.10
   Compiling unicode-xid v0.2.0
   Compiling syn v1.0.18
   Compiling autocfg v0.1.7
   Compiling cfg-if v0.1.10
   Compiling spin v0.5.2
   Compiling serde v1.0.105 (https://github.com/mesalock-linux/serde-sgx#3e1fcf4c)
   Compiling typenum v1.12.0
   Compiling byteorder v1.3.2 (https://github.com/mesalock-linux/byteorder-sgx#8ad66bc3)
   Compiling getrandom v0.1.14 (https://github.com/mesalock-linux/getrandom-sgx#66a998d6)
   Compiling ppv-lite86 v0.2.6 (https://github.com/mesalock-linux/cryptocorrosion-sgx#b31e8668)
   Compiling untrusted v0.7.0
   Compiling ryu v1.0.4
   Compiling log v0.4.8 (https://github.com/mesalock-linux/log-sgx#3503e4d9)
   Compiling inventory v0.1.6
   Compiling libc v0.2.69
   Compiling rand_core v0.4.2
   Compiling matches v0.1.8 (https://github.com/mesalock-linux/rust-std-candidates-sgx#5747bcf3)
   Compiling percent-encoding v2.1.0 (https://github.com/mesalock-linux/rust-url-sgx#ba94521f)
   Compiling either v1.5.3
   Compiling teaclave_config v0.1.0 (/teaclave/build/cmake_tomls/sgx_trusted_lib/config)
   Compiling httparse v1.3.4
   Compiling proc-macro2 v0.4.30
   Compiling hashbrown v0.3.1
   Compiling bit-vec v0.6.1
   Compiling unicode-xid v0.1.0
   Compiling quick-error v1.2.2 (https://github.com/mesalock-linux/quick-error-sgx#c77b8867)
   Compiling syn v0.15.44
   Compiling num-iter v0.1.39 (https://github.com/mesalock-linux/num-iter-sgx#08168b9a)
   Compiling anyhow v1.0.26 (https://github.com/mesalock-linux/anyhow-sgx#b4164eed)
   Compiling teaclave_binder v0.1.0 (/teaclave/build/cmake_tomls/sgx_trusted_lib/binder)
   Compiling teaclave_proto v0.1.0 (/teaclave/build/cmake_tomls/sgx_trusted_lib/services/proto)
   Compiling rawpointer v0.2.1
   Compiling crc v2.0.0
error: could not compile `crc`.

Caused by:
  process didn't exit successfully: `/teaclave/cmake/scripts/rustc_wrapper.sh --crate-name crc --edition=2018 /teaclave/build/cmake_tomls/sgx_trusted_lib/third_party/crates-sgx/vendor/crc/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=00442ba3caacd126 -C extra-filename=-00442ba3caacd126 --out-dir /teaclave/build/target/trusted/debug/deps -L dependency=/teaclave/build/target/trusted/debug/deps --cap-lints allow --cfg test_mode --cfg sgx_sim --cfg test_mode` (signal: 9, SIGKILL: kill)
/usr/bin/ld: cannot find -lteaclave_unit_tests_enclave
collect2: error: ld returned 1 exit status
CMakeFiles/sgxlib-teaclave_unit_tests.dir/build.make:57: recipe for target 'CMakeFiles/sgxlib-teaclave_unit_tests' failed
make[2]: *** [CMakeFiles/sgxlib-teaclave_unit_tests] Error 1
CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/sgxlib-teaclave_unit_tests.dir/all' failed
make[1]: *** [CMakeFiles/sgxlib-teaclave_unit_tests.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
mssun commented 4 years ago

Can you give me the log with VERBOSE=1? Like this:

docker run --rm -v $(pwd):/teaclave -w /teaclave \
   -it teaclave/teaclave-build-ubuntu-1804-sgx-2.9.1:latest \
    bash -c ". /root/.cargo/env && \
      . /opt/sgxsdk/environment && \
      mkdir -p build && cd build && \
      cmake -DTEST_MODE=ON -DSGX_SIM_MODE=ON .. && \
      make VERBOSE=1"
yc-huang commented 4 years ago

Following is the log with VERBOSE=1, thanks for you help:

docker run --rm -v $(pwd):/teaclave -w /teaclave \
>   -it teaclave/teaclave-build-ubuntu-1804-sgx-2.9.1:latest \
>    bash -c ". /root/.cargo/env && \
>      . /opt/sgxsdk/environment && \
>      mkdir -p build && cd build && \
>      cmake -DTEST_MODE=ON -DSGX_SIM_MODE=ON .. && \
>      make"
-- Submodule update
SGX_SDK=/opt/sgxsdk
SGX_MODE=SW
RUSTUP_TOOLCHAIN=nightly-2020-04-07
DCAP=OFF
BUILD_TYPE=debug
TEACLAVE_SYMLINKS=/tmp/teaclave_symlinks.3wK9WFJtKIG8
-- ====== /teaclave/build/environment GENERATED ======
-- Configuring done
-- Generating done
-- Build files have been written to: /teaclave/build
[  0%] Built target prep
[ 12%] Built target pycomponent
[ 16%] Building sgxlib-teaclave_unit_tests, enclave info to /teaclave/build/intermediate/teaclave_unit_tests_enclave_info.toml
   Compiling crc v2.0.0
error: could not compile `crc`.

Caused by:
  process didn't exit successfully: `/teaclave/cmake/scripts/rustc_wrapper.sh --crate-name crc --edition=2018 /teaclave/build/cmake_tomls/sgx_trusted_lib/third_party/crates-sgx/vendor/crc/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=00442ba3caacd126 -C extra-filename=-00442ba3caacd126 --out-dir /teaclave/build/target/trusted/debug/deps -L dependency=/teaclave/build/target/trusted/debug/deps --cap-lints allow --cfg test_mode --cfg sgx_sim --cfg test_mode` (signal: 9, SIGKILL: kill)
/usr/bin/ld: cannot find -lteaclave_unit_tests_enclave
collect2: error: ld returned 1 exit status
CMakeFiles/sgxlib-teaclave_unit_tests.dir/build.make:57: recipe for target 'CMakeFiles/sgxlib-teaclave_unit_tests' failed
make[2]: *** [CMakeFiles/sgxlib-teaclave_unit_tests] Error 1
CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/sgxlib-teaclave_unit_tests.dir/all' failed
make[1]: *** [CMakeFiles/sgxlib-teaclave_unit_tests.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
[centos@ip-172-31-19-164 incubator-teaclave]$ docker run --rm -v $(pwd):/teaclave -w /teaclave \
>    -it teaclave/teaclave-build-ubuntu-1804-sgx-2.9.1:latest \
>     bash -c ". /root/.cargo/env && \
>       . /opt/sgxsdk/environment && \
>       mkdir -p build && cd build && \
>       cmake -DTEST_MODE=ON -DSGX_SIM_MODE=ON .. && \
>       make VERBOSE=1"
-- Submodule update
SGX_SDK=/opt/sgxsdk
SGX_MODE=SW
RUSTUP_TOOLCHAIN=nightly-2020-04-07
DCAP=OFF
BUILD_TYPE=debug
TEACLAVE_SYMLINKS=/tmp/teaclave_symlinks.yV1IxJrrQAGG
-- ====== /teaclave/build/environment GENERATED ======
-- Configuring done
-- Generating done
-- Build files have been written to: /teaclave/build
/usr/bin/cmake -H/teaclave -B/teaclave/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /teaclave/build/CMakeFiles /teaclave/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/teaclave/build'
make -f CMakeFiles/prep.dir/build.make CMakeFiles/prep.dir/depend
make[2]: Entering directory '/teaclave/build'
cd /teaclave/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /teaclave /teaclave /teaclave/build /teaclave/build /teaclave/build/CMakeFiles/prep.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/teaclave/build'
make -f CMakeFiles/prep.dir/build.make CMakeFiles/prep.dir/build
make[2]: Entering directory '/teaclave/build'
/usr/bin/cmake -E env TEACLAVE_PROJECT_ROOT=/teaclave TEACLAVE_BUILD_ROOT=/teaclave/build TEACLAVE_OUT_DIR=/teaclave/build/intermediate TEACLAVE_SERVICE_INSTALL_DIR=/teaclave/release/services TEACLAVE_EXAMPLE_INSTALL_DIR=/teaclave/release/examples TEACLAVE_BIN_INSTALL_DIR=/teaclave/release/bin TEACLAVE_CLI_INSTALL_DIR=/teaclave/release/cli TEACLAVE_DCAP_INSTALL_DIR=/teaclave/release/dcap TEACLAVE_LIB_INSTALL_DIR=/teaclave/release/lib TEACLAVE_DOC_INSTALL_DIR=/teaclave/release/docs TEACLAVE_TEST_INSTALL_DIR=/teaclave/release/tests TEACLAVE_AUDITORS_DIR=/teaclave/release/services/auditors TEACLAVE_EXAMPLE_AUDITORS_DIR=/teaclave/release/examples/auditors TEACLAVE_TARGET_DIR=/teaclave/build/target TEACLAVE_CFG_DIR=/teaclave TEACLAVE_BUILD_CFG_DIR=/teaclave TEACLAVE_EDL_DIR=/teaclave/edl TEACLAVE_SYMLINKS=/tmp/teaclave_symlinks.yV1IxJrrQAGG SGX_SDK=/opt/sgxsdk SGX_MODE=SW DCAP=OFF ENCLAVE_OUT_DIR=/teaclave/build/intermediate RUSTUP_TOOLCHAIN=nightly-2020-04-07 RUST_SGX_SDK=/teaclave/third_party/rust-sgx-sdk MT_SCRIPT_DIR=/teaclave/cmake/scripts MT_SGXAPP_TOML_DIR=/teaclave/build/cmake_tomls/sgx_untrusted_app CARGO_INCREMENTAL= CMAKE_C_COMPILER=/usr/bin/cc CC=/teaclave/cmake/scripts/cc_wrapper.sh MT_RUSTC_WRAPPER=/teaclave/cmake/scripts/rustc_wrapper.sh CMAKE_SOURCE_DIR=/teaclave CMAKE_BINARY_DIR=/teaclave/build MESAPY_VERSION=eb769f13d6f9947b62aa04c2fb34496082bdadeb SGX_EDGER8R=/opt/sgxsdk/bin/x64/sgx_edger8r CMAKE_AR=/usr/bin/ar DCAP=OFF SGX_UNTRUSTED_CFLAGS=-m64\ -O2\ -fPIC\ -Wno-attributes\ -I/opt/sgxsdk/include\ -I/teaclave/third_party/rust-sgx-sdk/edl SGX_TRUSTED_CFLAGS=-m64\ -O2\ -nostdinc\ -fvisibility=hidden\ -fpie\ -fstack-protector\ -I/teaclave/third_party/rust-sgx-sdk/edl\ -I/teaclave/third_party/rust-sgx-sdk/common/inc\ -I/opt/sgxsdk/include\ -I/opt/sgxsdk/include/tlibc\ -I/opt/sgxsdk/include/stlport\ -I/opt/sgxsdk/include/epid /teaclave/cmake/scripts/prep.sh
make[2]: Leaving directory '/teaclave/build'
[  0%] Built target prep
make -f CMakeFiles/pycomponent.dir/build.make CMakeFiles/pycomponent.dir/depend
make[2]: Entering directory '/teaclave/build'
cd /teaclave/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /teaclave /teaclave /teaclave/build /teaclave/build /teaclave/build/CMakeFiles/pycomponent.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/teaclave/build'
make -f CMakeFiles/pycomponent.dir/build.make CMakeFiles/pycomponent.dir/build
make[2]: Entering directory '/teaclave/build'
make[2]: Nothing to be done for 'CMakeFiles/pycomponent.dir/build'.
make[2]: Leaving directory '/teaclave/build'
[ 12%] Built target pycomponent
make -f CMakeFiles/sgxlib-teaclave_unit_tests.dir/build.make CMakeFiles/sgxlib-teaclave_unit_tests.dir/depend
make[2]: Entering directory '/teaclave/build'
cd /teaclave/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /teaclave /teaclave /teaclave/build /teaclave/build /teaclave/build/CMakeFiles/sgxlib-teaclave_unit_tests.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/teaclave/build'
make -f CMakeFiles/sgxlib-teaclave_unit_tests.dir/build.make CMakeFiles/sgxlib-teaclave_unit_tests.dir/build
make[2]: Entering directory '/teaclave/build'
[ 16%] Building sgxlib-teaclave_unit_tests, enclave info to /teaclave/build/intermediate/teaclave_unit_tests_enclave_info.toml
cd /teaclave/build/cmake_tomls/sgx_trusted_lib && /usr/bin/cmake -E env TEACLAVE_PROJECT_ROOT=/teaclave TEACLAVE_BUILD_ROOT=/teaclave/build TEACLAVE_OUT_DIR=/teaclave/build/intermediate TEACLAVE_SERVICE_INSTALL_DIR=/teaclave/release/services TEACLAVE_EXAMPLE_INSTALL_DIR=/teaclave/release/examples TEACLAVE_BIN_INSTALL_DIR=/teaclave/release/bin TEACLAVE_CLI_INSTALL_DIR=/teaclave/release/cli TEACLAVE_DCAP_INSTALL_DIR=/teaclave/release/dcap TEACLAVE_LIB_INSTALL_DIR=/teaclave/release/lib TEACLAVE_DOC_INSTALL_DIR=/teaclave/release/docs TEACLAVE_TEST_INSTALL_DIR=/teaclave/release/tests TEACLAVE_AUDITORS_DIR=/teaclave/release/services/auditors TEACLAVE_EXAMPLE_AUDITORS_DIR=/teaclave/release/examples/auditors TEACLAVE_TARGET_DIR=/teaclave/build/target TEACLAVE_CFG_DIR=/teaclave TEACLAVE_BUILD_CFG_DIR=/teaclave TEACLAVE_EDL_DIR=/teaclave/edl TEACLAVE_SYMLINKS=/tmp/teaclave_symlinks.yV1IxJrrQAGG SGX_SDK=/opt/sgxsdk SGX_MODE=SW DCAP=OFF ENCLAVE_OUT_DIR=/teaclave/build/intermediate RUSTUP_TOOLCHAIN=nightly-2020-04-07 RUST_SGX_SDK=/teaclave/third_party/rust-sgx-sdk MT_SCRIPT_DIR=/teaclave/cmake/scripts MT_SGXAPP_TOML_DIR=/teaclave/build/cmake_tomls/sgx_untrusted_app CARGO_INCREMENTAL= CMAKE_C_COMPILER=/usr/bin/cc CC=/teaclave/cmake/scripts/cc_wrapper.sh MT_RUSTC_WRAPPER=/teaclave/cmake/scripts/rustc_wrapper.sh RUSTFLAGS=\ --cfg\ test_mode\ --cfg\ sgx_sim\ --cfg\ test_mode /teaclave/cmake/scripts/cargo_build_ex.sh -p teaclave_unit_tests_enclave --target-dir /teaclave/build/target/trusted -Z package-features --features mesalock_sgx
   Compiling crc v2.0.0
error: could not compile `crc`.

Caused by:
  process didn't exit successfully: `/teaclave/cmake/scripts/rustc_wrapper.sh --crate-name crc --edition=2018 /teaclave/build/cmake_tomls/sgx_trusted_lib/third_party/crates-sgx/vendor/crc/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=00442ba3caacd126 -C extra-filename=-00442ba3caacd126 --out-dir /teaclave/build/target/trusted/debug/deps -L dependency=/teaclave/build/target/trusted/debug/deps --cap-lints allow --cfg test_mode --cfg sgx_sim --cfg test_mode` (signal: 9, SIGKILL: kill)
cd /teaclave/build/cmake_tomls/sgx_trusted_lib && /usr/bin/cmake -E env TEACLAVE_PROJECT_ROOT=/teaclave TEACLAVE_BUILD_ROOT=/teaclave/build TEACLAVE_OUT_DIR=/teaclave/build/intermediate TEACLAVE_SERVICE_INSTALL_DIR=/teaclave/release/services TEACLAVE_EXAMPLE_INSTALL_DIR=/teaclave/release/examples TEACLAVE_BIN_INSTALL_DIR=/teaclave/release/bin TEACLAVE_CLI_INSTALL_DIR=/teaclave/release/cli TEACLAVE_DCAP_INSTALL_DIR=/teaclave/release/dcap TEACLAVE_LIB_INSTALL_DIR=/teaclave/release/lib TEACLAVE_DOC_INSTALL_DIR=/teaclave/release/docs TEACLAVE_TEST_INSTALL_DIR=/teaclave/release/tests TEACLAVE_AUDITORS_DIR=/teaclave/release/services/auditors TEACLAVE_EXAMPLE_AUDITORS_DIR=/teaclave/release/examples/auditors TEACLAVE_TARGET_DIR=/teaclave/build/target TEACLAVE_CFG_DIR=/teaclave TEACLAVE_BUILD_CFG_DIR=/teaclave TEACLAVE_EDL_DIR=/teaclave/edl TEACLAVE_SYMLINKS=/tmp/teaclave_symlinks.yV1IxJrrQAGG SGX_SDK=/opt/sgxsdk SGX_MODE=SW DCAP=OFF ENCLAVE_OUT_DIR=/teaclave/build/intermediate RUSTUP_TOOLCHAIN=nightly-2020-04-07 RUST_SGX_SDK=/teaclave/third_party/rust-sgx-sdk MT_SCRIPT_DIR=/teaclave/cmake/scripts MT_SGXAPP_TOML_DIR=/teaclave/build/cmake_tomls/sgx_untrusted_app CARGO_INCREMENTAL= CMAKE_C_COMPILER=/usr/bin/cc CC=/teaclave/cmake/scripts/cc_wrapper.sh MT_RUSTC_WRAPPER=/teaclave/cmake/scripts/rustc_wrapper.sh SGX_LIBRARY_PATH=/opt/sgxsdk/lib64 SGX_ENCLAVE_SIGNER=/opt/sgxsdk/bin/x64/sgx_sign Service_Library_Name=sgx_tservice_sim Trts_Library_Name=sgx_trts_sim TRUSTED_TARGET_DIR=/teaclave/build/target/trusted TARGET=debug SGX_COMMON_CFLAGS=-m64\ -O2 CUR_PKG_NAME=teaclave_unit_tests_enclave CUR_PKG_PATH=tests/unit/enclave CUR_INSTALL_DIR=/teaclave/release/tests /teaclave/cmake/scripts/sgx_link_sign.sh Enclave_fa_t
/usr/bin/ld: cannot find -lteaclave_unit_tests_enclave
collect2: error: ld returned 1 exit status
CMakeFiles/sgxlib-teaclave_unit_tests.dir/build.make:57: recipe for target 'CMakeFiles/sgxlib-teaclave_unit_tests' failed
make[2]: *** [CMakeFiles/sgxlib-teaclave_unit_tests] Error 1
make[2]: Leaving directory '/teaclave/build'
CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/sgxlib-teaclave_unit_tests.dir/all' failed
make[1]: *** [CMakeFiles/sgxlib-teaclave_unit_tests.dir/all] Error 2
make[1]: Leaving directory '/teaclave/build'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
yc-huang commented 4 years ago

not sure why it's SIGKILL, try start container with --oom-kill-disable and remain the same error...

mssun commented 4 years ago

Yes, this is very wired. I can compile it with the exact same command in a 32G memory PC.

How about directly build with the compilation command?

/teaclave/cmake/scripts/rustc_wrapper.sh --crate-name crc --edition=2018 /teaclave/build/cmake_tomls/sgx_trusted_lib/third_party/crates-sgx/vendor/crc/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=00442ba3caacd126 -C extra-filename=-00442ba3caacd126 --out-dir /teaclave/build/target/trusted/debug/deps -L dependency=/teaclave/build/target/trusted/debug/deps --cap-lints allow --cfg test_mode --cfg sgx_sim --cfg test_mode 
yc-huang commented 4 years ago

It runs with no output and then get killed...

I'm running this on a small aws node, I guess I might need to increase the hardware resource first...

yc-huang commented 4 years ago

Tried this on a new aws instance with 8GB memory and everything looks good now, thank you @mssun for your prompt help.