[toolchains] Add grpc ra_tls into toolchains
This commit is contained in:
		
							parent
							
								
									7809658233
								
							
						
					
					
						commit
						fa5dfc690d
					
				| @ -14,7 +14,6 @@ function build_ratls() | ||||
|     pushd ${RATLS_DIR} | ||||
|     ./download_and_prepare.sh | ||||
|     ./build_and_install.sh musl | ||||
|     ./build_occlum_instance.sh musl | ||||
| 
 | ||||
|     cp ./grpc-src/examples/cpp/ratls/build/libgrpc_ratls_client.so ${DEP_LIBS_DIR}/ | ||||
|     cp ./grpc-src/examples/cpp/ratls/build/libhw_grpc_proto.so ${DEP_LIBS_DIR}/ | ||||
|  | ||||
							
								
								
									
										34
									
								
								tools/toolchains/grpc_ratls/build.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										34
									
								
								tools/toolchains/grpc_ratls/build.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,34 @@ | ||||
| #!/bin/bash | ||||
| set -e | ||||
| 
 | ||||
| script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}"  )" >/dev/null 2>&1 && pwd )" | ||||
| INSTALL_DIR=/opt/occlum/toolchains/grpc_ratls | ||||
| RATLS_DIR=${script_dir}/ra_tls | ||||
| 
 | ||||
| pushd ${RATLS_DIR} | ||||
| echo "Download and prepare grpc ra_tls" | ||||
| ./download_and_prepare.sh | ||||
| 
 | ||||
| echo "Build and install musl-libc grpc ra_tls" | ||||
| ./build_and_install.sh musl | ||||
| mkdir -p ${INSTALL_DIR}/musl | ||||
| cp ./grpc-src/examples/cpp/ratls/build/libgrpc_ratls_client.so ${INSTALL_DIR}/musl/ | ||||
| cp ./grpc-src/examples/cpp/ratls/build/libgrpc_ratls_server.so ${INSTALL_DIR}/musl/ | ||||
| cp ./grpc-src/examples/cpp/ratls/build/libhw_grpc_proto.so ${INSTALL_DIR}/musl/ | ||||
| cp ./grpc-src/examples/cpp/ratls/build/server ${INSTALL_DIR}/musl/ | ||||
| 
 | ||||
| echo "Build and install glibc grpc ra_tls" | ||||
| ./build_and_install.sh | ||||
| mkdir -p ${INSTALL_DIR}/glibc | ||||
| cp ./grpc-src/examples/cpp/ratls/build/libgrpc_ratls_client.so ${INSTALL_DIR}/glibc/ | ||||
| cp ./grpc-src/examples/cpp/ratls/build/libgrpc_ratls_server.so ${INSTALL_DIR}/glibc/ | ||||
| cp ./grpc-src/examples/cpp/ratls/build/libhw_grpc_proto.so ${INSTALL_DIR}/glibc/ | ||||
| cp ./grpc-src/examples/cpp/ratls/build/server ${INSTALL_DIR}/glibc/ | ||||
| 
 | ||||
| # Do clean | ||||
| rm -rf grpc-src | ||||
| rm -f *.tar.gz | ||||
| rm -rf cJSON* | ||||
| popd | ||||
| 
 | ||||
| 
 | ||||
| @ -6,17 +6,19 @@ source ./env.sh | ||||
| BUILD_TYPE=Release | ||||
| 
 | ||||
| if [[ $1 == "musl" ]]; then | ||||
|     echo "*** Build and run musl-libc demo ***" | ||||
|     echo "*** Build musl-libc grpc_ratls ***" | ||||
|     CC=occlum-gcc | ||||
|     CXX=occlum-g++ | ||||
|     DCAP_LIB_PATH="/opt/occlum/toolchains/dcap_lib/musl" | ||||
|     INSTALL_PREFIX="/usr/local/occlum/x86_64-linux-musl" | ||||
|     GRPC_INSTALL_PATH="/tmp/grpc_ratls/musl" | ||||
| else | ||||
|     echo "*** Build and run glibc demo ***" | ||||
|     echo "*** Build glibc grpc_ratls ***" | ||||
|     CC=gcc | ||||
|     CXX=g++ | ||||
|     DCAP_LIB_PATH="/opt/occlum/toolchains/dcap_lib/glibc" | ||||
|     INSTALL_PREFIX="/usr/local" | ||||
|     GRPC_INSTALL_PATH="/tmp/grpc_ratls/glibc" | ||||
| fi | ||||
| 
 | ||||
| # Build and install cJSON | ||||
| @ -30,9 +32,9 @@ function build_cjson() { | ||||
| } | ||||
| 
 | ||||
| function build_grpc_ratls() { | ||||
|     # Copy occlum dcap lib first | ||||
|     rm -rf ${GRPC_INSTALL_PATH} && mkdir -p ${GRPC_INSTALL_PATH} | ||||
|     # Copy occlum dcap lib first to ease linking | ||||
|     cp ${DCAP_LIB_PATH}/libocclum_dcap.so* ${INSTALL_PREFIX}/lib | ||||
|     cp /opt/occlum/toolchains/dcap_lib/inc/occlum_dcap.h ${INSTALL_PREFIX}/include/ | ||||
| 
 | ||||
|     # Copy ratls added/updated files to grpc source | ||||
|     cp -rf grpc/${GRPC_VERSION}/* ${GRPC_PATH}/ | ||||
| @ -44,7 +46,7 @@ function build_grpc_ratls() { | ||||
|     pushd ${ABSEIL_PATH} | ||||
|     rm -rf build && mkdir build && cd build | ||||
|     cmake -DCMAKE_CXX_STANDARD=11 -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \ | ||||
|             -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \ | ||||
|             -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${GRPC_INSTALL_PATH} \ | ||||
|             -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_C_COMPILER=${CC} .. | ||||
|     make -j `nproc` | ||||
|     make install | ||||
| @ -58,7 +60,8 @@ function build_grpc_ratls() { | ||||
|         -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF \ | ||||
|         -DDEFINE_SGX_RA_TLS_OCCLUM_BACKEND=ON \ | ||||
|         -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_C_COMPILER=${CC} \ | ||||
|         -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} .. | ||||
|         -DCMAKE_PREFIX_PATH=${GRPC_INSTALL_PATH} \ | ||||
|         -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${GRPC_INSTALL_PATH} .. | ||||
|     make -j `nproc` | ||||
|     make install | ||||
|     popd | ||||
| @ -67,10 +70,14 @@ function build_grpc_ratls() { | ||||
|     pushd ${GRPC_PATH}/examples/cpp/ratls | ||||
|     rm -rf build && mkdir -p build | ||||
|     cd build | ||||
|     cmake -D CMAKE_PREFIX_PATH=${INSTALL_PREFIX} -D CMAKE_BUILD_TYPE=${BUILD_TYPE} \ | ||||
|     cmake -DCMAKE_PREFIX_PATH=${GRPC_INSTALL_PATH} \ | ||||
|         -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ | ||||
|         -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_C_COMPILER=${CC} .. | ||||
|     make -j `nproc` | ||||
|     popd | ||||
| 
 | ||||
|     # Clean temp occlum dcap lib | ||||
|     rm ${INSTALL_PREFIX}/lib/libocclum_dcap.so* | ||||
| } | ||||
| 
 | ||||
| build_cjson | ||||
							
								
								
									
										3
									
								
								demos/ra_tls/build_occlum_instance.sh → tools/toolchains/grpc_ratls/ra_tls/build_occlum_instance.sh
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										3
									
								
								demos/ra_tls/build_occlum_instance.sh → tools/toolchains/grpc_ratls/ra_tls/build_occlum_instance.sh
									
									
									
									
									
								
							| @ -1,6 +1,8 @@ | ||||
| #!/bin/bash | ||||
| set -e | ||||
| 
 | ||||
| script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}"  )" >/dev/null 2>&1 && pwd )" | ||||
| 
 | ||||
| function get_mr() { | ||||
|     cd ${script_dir}/occlum_$1 && occlum print $2 | ||||
| } | ||||
| @ -55,6 +57,7 @@ function build_instance() { | ||||
| 
 | ||||
| if [[ $1 == "musl" ]]; then | ||||
|     echo "*** Build musl-libc Occlum instance ***" | ||||
|     cp /opt/occlum/toolchains/dcap_lib/musl/libocclum_dcap.so.0.1.0 /usr/local/occlum/x86_64-linux-musl/lib/ | ||||
| else | ||||
|     echo "*** Build glibc Occlum instance ***" | ||||
|     # glibc version requires libnss | ||||
| @ -55,6 +55,7 @@ option(DEFINE_SGX_RA_TLS_OCCLUM_BACKEND "SGX Occlum Backend" OFF) | ||||
| if(DEFINE_SGX_RA_TLS_OCCLUM_BACKEND) | ||||
|   message("SGX_RA_TLS_OCCLUM_BACKEND is defined") | ||||
|   include_directories(/opt/intel/sgxsdk/include) | ||||
|   include_directories(/opt/occlum/toolchains/dcap_lib/inc) | ||||
|   add_definitions(-DSGX_RA_TLS_OCCLUM_BACKEND) | ||||
| endif() | ||||
| 
 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user