forked from crypto-com/thaler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem(Fix crypto-com#869): Duplicate enclave makefiles
Other related problems: - (Fix crypto-com#868) compiled enclave file names collide - (Fix crypto-com#870) enclave code not covered by cargo tools - (Fix crypto-com#871) debug/release build result files conflict Solution: - Move compile steps into `build.rs`, only link and sign of enclave so are handled by make. So on linux with sgx sdk setup, all the rust code are built with cargo. - Don't exclude enclave crates from workspace anymore, but not included in default-members, to keep default `cargo build` runnable on mac. After this, - share makefile between tx-validation and tx-query. - use the enclave crate package name as enclave signed so name. - build directory seperated by cargo atomitically - `Cargo.lock` and build directory are shared, faster building. cargo fmt fix integration tests
- Loading branch information
Showing
37 changed files
with
835 additions
and
746 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,5 @@ | ||
**/target/ | ||
**/*.rs.bk | ||
.vscode | ||
.DS_Store | ||
|
||
**/lib/libEnclave_u.* | ||
**/lib/libcompiler-rt-patch.a | ||
**/lib/libenclave.a | ||
**/bin/tx-validation-app | ||
**/bin/enclave.signed.so | ||
**/bin/tx-query-app | ||
**/enclave/Enclave_t.* | ||
**/enclave/enclave.so | ||
**/app/Enclave_u.* | ||
**/app/libEnclave_u.* | ||
|
||
rust-sgx-sdk/compiler-rt/libcompiler-rt-patch.a | ||
rust-sgx-sdk/compiler-rt/muloti4.o | ||
|
||
enclave-u-common/Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in | ||
# the documentation and/or other materials provided with the | ||
# distribution. | ||
# * Neither the name of Baidu, Inc., nor the names of its | ||
# contributors may be used to endorse or promote products derived | ||
# from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
# | ||
# Modifications Copyright 2019 Foris Limited (licensed under the Apache License, Version 2.0) | ||
|
||
######## Update SGX SDK ######## | ||
# include ../UpdateRustSGXSDK.mk | ||
######## SGX SDK Settings ######## | ||
|
||
SGX_SDK ?= /opt/intel/sgxsdk | ||
SGX_MODE ?= SW | ||
SGX_ARCH ?= x64 | ||
SGX_DEBUG ?= 1 | ||
|
||
ifeq ($(shell getconf LONG_BIT), 32) | ||
SGX_ARCH := x86 | ||
else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) | ||
SGX_ARCH := x86 | ||
endif | ||
|
||
ifeq ($(SGX_ARCH), x86) | ||
SGX_LIBRARY_PATH := $(SGX_SDK)/lib | ||
SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign | ||
else | ||
SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 | ||
SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign | ||
endif | ||
|
||
CARGO_FLAGS := | ||
ifeq ($(SGX_DEBUG), 1) | ||
OUTPUT_PATH := debug | ||
else | ||
OUTPUT_PATH := release | ||
CARGO_FLAGS += --release | ||
endif | ||
|
||
ifeq ($(SGX_TEST), 1) | ||
CARGO_FLAGS += --features "sgx-test" | ||
endif | ||
|
||
######## Enclave Files ############ | ||
CARGO_TARGET_DIR ?= ../../target | ||
Enclave_Static_Lib := $(CARGO_TARGET_DIR)/$(OUTPUT_PATH)/lib$(Enclave_Name).a | ||
Enclave_Shared_Lib := $(CARGO_TARGET_DIR)/$(OUTPUT_PATH)/lib$(Enclave_Name).so | ||
Enclave_Signed_Lib := $(CARGO_TARGET_DIR)/$(OUTPUT_PATH)/$(Enclave_Name).signed.so | ||
|
||
######## Compiler Flags ######## | ||
|
||
ifneq ($(SGX_MODE), HW) | ||
Trts_Library_Name := sgx_trts_sim | ||
Service_Library_Name := sgx_tservice_sim | ||
else | ||
Trts_Library_Name := sgx_trts | ||
Service_Library_Name := sgx_tservice | ||
endif | ||
Crypto_Library_Name := sgx_tcrypto | ||
KeyExchange_Library_Name := sgx_tkey_exchange | ||
ProtectedFs_Library_Name := sgx_tprotected_fs | ||
|
||
Compiler_RT_Lib := ../rust-sgx-sdk/compiler-rt/libcompiler-rt-patch.a | ||
RustEnclave_Link_Flags := -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ | ||
-Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ | ||
-Wl,--start-group -lsgx_tcxx -lsgx_tstdc -l$(Service_Library_Name) -l$(Crypto_Library_Name) \ | ||
$(Compiler_RT_Lib) $(Enclave_Static_Lib) -Wl,--end-group \ | ||
-Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ | ||
-Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ | ||
-Wl,--defsym,__ImageBase=0 \ | ||
-Wl,--gc-sections \ | ||
-Wl,--version-script=enclave/Enclave.lds | ||
|
||
.PHONY: all | ||
all: $(Enclave_Signed_Lib) | ||
|
||
$(Enclave_Shared_Lib): $(Enclave_Static_Lib) $(Compiler_RT_Lib) | ||
@$(CXX) -o $@ $(RustEnclave_Link_Flags) | ||
@echo "LINK => $@" | ||
|
||
$(Enclave_Signed_Lib): $(Enclave_Shared_Lib) | ||
@$(SGX_ENCLAVE_SIGNER) sign -key enclave/Enclave_private.pem -enclave $< -out $@ -config enclave/Enclave.config.xml | ||
@echo "SIGN => $@" | ||
|
||
$(Enclave_Static_Lib): FORCE | ||
@cd ./enclave/ && cargo build ${CARGO_FLAGS} | ||
@echo "CARGO => $@" | ||
|
||
$(Compiler_RT_Lib): | ||
$(MAKE) -C ../rust-sgx-sdk/compiler-rt | ||
|
||
.PHONY: clean | ||
clean: | ||
@rm -f $(Enclave_Shared_Lib) $(Enclave_Signed_Lib) | ||
$(MAKE) -C ../rust-sgx-sdk/compiler-rt clean | ||
|
||
FORCE: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.