Set SONAME for Occlum DCAP library

This commit is contained in:
Zheng, Qi 2022-02-10 13:16:32 +08:00 committed by Zongmin.Gu
parent eb0fce79bf
commit 477ae99880
3 changed files with 33 additions and 16 deletions

@ -12,5 +12,5 @@ targets:
- target: /lib - target: /lib
copy: copy:
- files: - files:
- /opt/occlum/toolchains/dcap_lib/musl/libocclum_dcap.so - /opt/occlum/toolchains/dcap_lib/musl/libocclum_dcap.so.0.1.0

@ -12,5 +12,5 @@ targets:
- target: /opt/occlum/glibc/lib - target: /opt/occlum/glibc/lib
copy: copy:
- files: - files:
- /opt/occlum/toolchains/dcap_lib/glibc/libocclum_dcap.so - /opt/occlum/toolchains/dcap_lib/glibc/libocclum_dcap.so.0.1.0

@ -2,23 +2,40 @@
set -e set -e
INSTALL_DIR=/opt/occlum/toolchains/dcap_lib INSTALL_DIR=/opt/occlum/toolchains/dcap_lib
SONAME=libocclum_dcap.so.0.1.0
echo "*** Build and install musl-libc dcap ***" function build_lib() {
occlum-cargo clean if [[ $1 == "musl" ]]; then
occlum-cargo build --all-targets --release echo "*** Build and install musl-libc dcap ***"
CARGO=occlum-cargo
TARGET_PATH=target/x86_64-unknown-linux-musl/release
LIB_PATH=${INSTALL_DIR}/musl/
else
echo "*** Build and install glibc dcap ***"
CARGO=cargo
TARGET_PATH=target/release
LIB_PATH=${INSTALL_DIR}/glibc/
fi
mkdir -p ${INSTALL_DIR}/musl # cargo build libs and rust example
cp target/x86_64-unknown-linux-musl/release/libocclum_dcap.a ${INSTALL_DIR}/musl/ $CARGO clean
cp target/x86_64-unknown-linux-musl/release/libocclum_dcap.so ${INSTALL_DIR}/musl/ $CARGO rustc --release -- -Clink-arg=-Wl,-soname,$SONAME
cp target/x86_64-unknown-linux-musl/release/examples/dcap_test ${INSTALL_DIR}/musl/ $CARGO build --release --examples
echo "*** Build and install glibc dcap ***" # Copy files
cargo clean mkdir -p ${LIB_PATH}
cargo build --all-targets --release cp ${TARGET_PATH}/libocclum_dcap.a ${LIB_PATH}
cp ${TARGET_PATH}/examples/dcap_test ${LIB_PATH}
mkdir -p ${INSTALL_DIR}/glibc # Create SO links
cp target/release/libocclum_dcap.a ${INSTALL_DIR}/glibc/ pushd ${TARGET_PATH}
cp target/release/libocclum_dcap.so ${INSTALL_DIR}/glibc/ mv libocclum_dcap.so $SONAME
cp target/release/examples/dcap_test ${INSTALL_DIR}/glibc/ ln -s $SONAME libocclum_dcap.so
popd
cp -Pf ${TARGET_PATH}/libocclum_dcap.so* ${LIB_PATH}
}
build_lib musl
build_lib glibc
cp -r inc ${INSTALL_DIR}/ cp -r inc ${INSTALL_DIR}/