Install occlum needed sgx-sdk tools to occlum dir
When installers are used, sgx-sdk of Occlum version could have conflicts with official sgx-sdk. This patch will make sure Occlum command use Occlum specific sgx-sdk. Also add symbolic links to PAL library of hardware mode when installing.
This commit is contained in:
parent
2c8c999d52
commit
617f75904f
23
Makefile
23
Makefile
@ -20,10 +20,15 @@ endif
|
||||
|
||||
# Occlum major version
|
||||
MAJOR_VER_NUM = $(shell grep '\#define OCCLUM_MAJOR_VERSION' ./src/pal/include/occlum_version.h | awk '{print $$3}')
|
||||
MINOR_VER_NUM = $(shell grep '\#define OCCLUM_MINOR_VERSION' ./src/pal/include/occlum_version.h | awk '{print $$3}')
|
||||
PATCH_VER_NUM = $(shell grep '\#define OCCLUM_PATCH_VERSION' ./src/pal/include/occlum_version.h | awk '{print $$3}')
|
||||
VERSION_NUM = $(MAJOR_VER_NUM).$(MINOR_VER_NUM).$(PATCH_VER_NUM)
|
||||
|
||||
# Exclude files when install
|
||||
EXCLUDE_FILES = "libocclum-libos.so.$(MAJOR_VER_NUM)\$$|libocclum-pal.so.$(MAJOR_VER_NUM)\$$|libocclum-pal.so\$$|.a\$$|occlum-protect-integrity.so.*"
|
||||
|
||||
SHELL := bash
|
||||
|
||||
submodule: githooks
|
||||
git submodule init
|
||||
git submodule update $(OCCLUM_GIT_OPTIONS)
|
||||
@ -47,7 +52,7 @@ test:
|
||||
@$(MAKE) --no-print-directory -C test test
|
||||
|
||||
OCCLUM_PREFIX ?= /opt/occlum
|
||||
install:
|
||||
install: $(OCCLUM_PREFIX)/sgxsdk-tools/lib64/libsgx_uae_service_sim.so
|
||||
@# Install both libraries for HW mode and SIM mode
|
||||
@$(MAKE) SGX_MODE=HW --no-print-directory -C src
|
||||
@$(MAKE) SGX_MODE=SIM --no-print-directory -C src
|
||||
@ -58,6 +63,9 @@ install:
|
||||
@mkdir -p $(OCCLUM_PREFIX)/build/lib/
|
||||
@# Don't copy libos library and pal library symbolic files to install dir
|
||||
@cd build/lib && cp --no-dereference `ls | grep -Ev $(EXCLUDE_FILES)` $(OCCLUM_PREFIX)/build/lib/ && cd -
|
||||
@# Create symbolic for pal library of hardware mode
|
||||
@cd $(OCCLUM_PREFIX)/build/lib && ln -sf libocclum-pal.so.$(VERSION_NUM) libocclum-pal.so.$(MAJOR_VER_NUM) && \
|
||||
ln -sf libocclum-pal.so.$(MAJOR_VER_NUM) libocclum-pal.so
|
||||
|
||||
@echo "Install headers and miscs ..."
|
||||
@mkdir -p $(OCCLUM_PREFIX)/include/
|
||||
@ -66,8 +74,21 @@ install:
|
||||
@mkdir -p $(OCCLUM_PREFIX)/etc/template/
|
||||
@cp etc/template/* $(OCCLUM_PREFIX)/etc/template
|
||||
@chmod 444 $(OCCLUM_PREFIX)/etc/template/*
|
||||
|
||||
@echo "Installation is done."
|
||||
|
||||
# Install minimum sgx-sdk set to support Occlum cmd execution in non-customized sgx-sdk environment
|
||||
$(OCCLUM_PREFIX)/sgxsdk-tools/lib64/libsgx_uae_service_sim.so: /opt/intel/sgxsdk/lib64/libsgx_uae_service_sim.so
|
||||
@echo "Install needed sgx-sdk tools ..."
|
||||
@mkdir -p $(OCCLUM_PREFIX)/sgxsdk-tools/lib64
|
||||
@cp /opt/intel/sgxsdk/lib64/{libsgx_ptrace.so,libsgx_uae_service_sim.so} $(OCCLUM_PREFIX)/sgxsdk-tools/lib64
|
||||
@mkdir -p $(OCCLUM_PREFIX)/sgxsdk-tools/lib64/gdb-sgx-plugin
|
||||
@cd /opt/intel/sgxsdk/lib64/gdb-sgx-plugin/ && cp $$(ls -A | grep -v __pycache__) $(OCCLUM_PREFIX)/sgxsdk-tools/lib64/gdb-sgx-plugin
|
||||
@cd /opt/intel/sgxsdk && cp --parents {bin/sgx-gdb,bin/x64/sgx_sign,sdk_libs/libsgx_uae_service_sim.so} $(OCCLUM_PREFIX)/sgxsdk-tools/
|
||||
@# Delete SGX_LIBRARY_PATH env in sgx-gdb which are defined in etc/environment
|
||||
@sed -i '/^SGX_LIBRARY_PATH=/d' $(OCCLUM_PREFIX)/sgxsdk-tools/bin/sgx-gdb
|
||||
@cp etc/environment $(OCCLUM_PREFIX)/sgxsdk-tools/
|
||||
|
||||
format:
|
||||
@$(MAKE) --no-print-directory -C test format
|
||||
@$(MAKE) --no-print-directory -C tools format
|
||||
|
13
etc/environment
Normal file
13
etc/environment
Normal file
@ -0,0 +1,13 @@
|
||||
if [ -d "/opt/occlum/sgxsdk-tools" ]; then
|
||||
export SGX_SDK=/opt/occlum/sgxsdk-tools
|
||||
else
|
||||
export SGX_SDK=/opt/intel/sgxsdk
|
||||
fi
|
||||
export SGX_LIBRARY_PATH=$SGX_SDK/lib64
|
||||
export PATH=$SGX_SDK/bin:$SGX_SDK/bin/x64:$PATH
|
||||
export PKG_CONFIG_PATH=$SGX_SDK/pkgconfig:$PKG_CONFIG_PATH
|
||||
if [ -z "$LD_LIBRARY_PATH" ]; then
|
||||
export LD_LIBRARY_PATH=$SGX_SDK/sdk_libs
|
||||
else
|
||||
export LD_LIBRARY_PATH=$SGX_SDK/sdk_libs:$LD_LIBRARY_PATH
|
||||
fi
|
@ -6,8 +6,10 @@ build_makefile=$occlum_dir/build/bin/occlum_build.mk
|
||||
|
||||
if [[ "$occlum_dir" == "/opt/occlum" ]]; then
|
||||
version_header=$occlum_dir/include/occlum_version.h
|
||||
occlum_sgx_env=$occlum_dir/sgxsdk-tools/environment
|
||||
else
|
||||
version_header=$occlum_dir/src/pal/include/occlum_version.h
|
||||
occlum_sgx_env=$occlum_dir/etc/environment
|
||||
fi
|
||||
|
||||
major_ver=`grep '\#define OCCLUM_MAJOR_VERSION' $version_header | awk '{print $3}'`
|
||||
@ -19,7 +21,7 @@ instance_dir=`pwd`
|
||||
|
||||
status_file=$instance_dir/.__occlum_status
|
||||
|
||||
SGX_SDK="${SGX_SDK:-/opt/intel/sgxsdk}"
|
||||
source $occlum_sgx_env
|
||||
SGX_GDB="$SGX_SDK/bin/sgx-gdb"
|
||||
ENCLAVE_SIGN_TOOL="$SGX_SDK/bin/x64/sgx_sign"
|
||||
ENCLAVE_SIGN_KEY="$occlum_dir/etc/template/Enclave.pem"
|
||||
|
@ -1,4 +1,4 @@
|
||||
SGX_SDK ?= /opt/intel/sgxsdk
|
||||
SGX_SDK ?= /opt/occlum/sgxsdk-tools
|
||||
|
||||
IMAGE := $(instance_dir)/image
|
||||
SECURE_IMAGE := $(instance_dir)/build/mount/__ROOT/metadata
|
||||
|
Loading…
Reference in New Issue
Block a user