Polish gRPC and remote attestation demos

1. Disable zlib _explictly_ when building libcurl in remote attestaion demo.
The reason for this is that zlib may be implictly linked by the build system of
libcurl but not the zlib library is not copied into the Occlum FS image.
2. Use `make -j$(nproc)`
3. Fix typos
This commit is contained in:
He Sun 2019-12-16 16:18:49 +08:00 committed by Tate, Hongliang Tian
parent 0f08fbf962
commit 6d7597c25e
8 changed files with 45 additions and 44 deletions

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
install_dir=/usr/local/occlum/x86_64-linux-musl/ INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl/
export PATH=$PATH:$install_dir/bin GRPC_SRC_DIR=$PWD/grpc
export PATH=$PATH:$INSTALL_DIR/bin
git clone https://github.com/grpc/grpc.git git clone https://github.com/grpc/grpc.git
cd grpc cd grpc
@ -12,54 +13,52 @@ then
fi fi
# Install c-ares # Install c-ares
cd third_party/cares/cares cd $GRPC_SRC_DIR/third_party/cares/cares
git submodule update --init . git submodule update --init .
git checkout tags/cares-1_15_0 git checkout tags/cares-1_15_0
mkdir -p build mkdir -p build
cd build cd build
cmake ../ \ cmake ../ \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \
-DCMAKE_INSTALL_PREFIX=$install_dir -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "cares cmake failed" echo "cares cmake failed"
exit 1 exit 1
fi fi
make -j8 make -j$(nproc)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "cares make failed" echo "cares make failed"
exit 1 exit 1
fi fi
make install make install
cd ../../../..
# Install zlib # Install zlib
cd third_party/zlib cd $GRPC_SRC_DIR/third_party/zlib
git submodule update --init . git submodule update --init .
git checkout tags/v1.2.11 git checkout tags/v1.2.11
mkdir -p build mkdir -p build
cd build cd build
cmake ../ \ cmake ../ \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \
-DCMAKE_CXX_COMPILER=occlum-g++ -DCMAKE_INSTALL_PREFIX=$install_dir \ -DCMAKE_CXX_COMPILER=occlum-g++ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE -DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "zlib cmake failed" echo "zlib cmake failed"
exit 1 exit 1
fi fi
make -j8 make -j$(nproc)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "zlib make failed" echo "zlib make failed"
exit 1 exit 1
fi fi
make install make install
cd ../../..
# Install protobuf # Install protobuf
cd third_party/protobuf cd $GRPC_SRC_DIR/third_party/protobuf
git submodule update --init . git submodule update --init .
git checkout tags/v3.10.0 git checkout tags/v3.10.0
cd cmake cd cmake
@ -68,7 +67,7 @@ cd build
cmake ../ \ cmake ../ \
-Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=TRUE \ -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=TRUE \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \
-DCMAKE_CXX_COMPILER=occlum-g++ -DCMAKE_INSTALL_PREFIX=$install_dir \ -DCMAKE_CXX_COMPILER=occlum-g++ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE -DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE
if [ $? -ne 0 ] if [ $? -ne 0 ]
@ -77,27 +76,26 @@ then
exit 1 exit 1
fi fi
make -j8 make -j$(nproc)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "protobuf make failed" echo "protobuf make failed"
exit 1 exit 1
fi fi
make install make install
cd ../../../..
cp $install_dir/bin/protoc /usr/bin cp $INSTALL_DIR/bin/protoc /usr/bin
# Install gRPC # Install gRPC
cd cmake cd $GRPC_SRC_DIR/cmake
mkdir -p build mkdir -p build
cd build cd build
cmake ../.. \ cmake ../.. \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \
-DCMAKE_CXX_COMPILER=occlum-g++ -DgRPC_INSTALL=ON -DgRPC_PROTOBUF_PROVIDER=package \ -DCMAKE_CXX_COMPILER=occlum-g++ -DgRPC_INSTALL=ON -DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package \ -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package \
-DgRPC_SSL_PROVIDER=package -DCMAKE_PREFIX_PATH=$install_dir \ -DgRPC_SSL_PROVIDER=package -DCMAKE_PREFIX_PATH=$INSTALL_DIR \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE -DCMAKE_INSTALL_PREFIX=$install_dir -DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
@ -105,7 +103,7 @@ then
exit 1 exit 1
fi fi
make -j8 make -j$(nproc)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "grpc make failed" echo "grpc make failed"

@ -14,7 +14,7 @@ then
echo "./config command failed." echo "./config command failed."
exit 1 exit 1
fi fi
make -j8 make -j$(nproc)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "make command failed." echo "make command failed."

@ -1,15 +1,17 @@
#!/bin/sh #!/bin/sh
DEMO_DIR=$PWD
cd grpc/examples/cpp/helloworld cd $DEMO_DIR/grpc/examples/cpp/helloworld
git apply ../../../../Makefile.patch git apply $DEMO_DIR/Makefile.patch
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "patch failed" echo "patch failed"
exit 1 exit 1
fi fi
cp ../../protos/helloworld.proto .
cd ../../../../ cp $DEMO_DIR/grpc/examples/protos/helloworld.proto .
cd $DEMO_DIR
mkdir -p client mkdir -p client
mkdir -p server mkdir -p server

@ -1,12 +1,12 @@
#!/bin/sh #!/bin/sh
install_dir=/usr/local/occlum/x86_64-linux-musl INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl
export PATH=$PATH:$install_dir/bin export PATH=$PATH:$INSTALL_DIR/bin
cd client cd client
make -j8 make -j$(nproc)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "demo make failed" echo "demo make failed"

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
install_dir=/usr/local/occlum/x86_64-linux-musl INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl
export PATH=$PATH:$install_dir/bin export PATH=$PATH:$INSTALL_DIR/bin
cd client cd client
make -j8 make -j$(nproc)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "demo make failed" echo "demo make failed"
@ -26,9 +26,9 @@ fi
mkdir -p image/etc mkdir -p image/etc
cp /etc/resolv.conf image/etc cp /etc/resolv.conf image/etc
cp ../greeter_client image/bin cp ../greeter_client image/bin
cp $install_dir/lib/libprotobuf.so.3.10.0.0 image/lib cp $INSTALL_DIR/lib/libprotobuf.so.3.10.0.0 image/lib
cp $install_dir/lib/libcares.so.2 image/lib cp $INSTALL_DIR/lib/libcares.so.2 image/lib
cp $install_dir/lib/libz.so.1 image/lib cp $INSTALL_DIR/lib/libz.so.1 image/lib
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "libraries copied failed" echo "libraries copied failed"

@ -1,12 +1,12 @@
#!/bin/sh #!/bin/sh
install_dir=/usr/local/occlum/x86_64-linux-musl INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl
export PATH=$PATH:$install_dir/bin export PATH=$PATH:$INSTALL_DIR/bin
cd server cd server
make -j8 make -j$(nproc)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "demo make failed" echo "demo make failed"

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
install_dir=/usr/local/occlum/x86_64-linux-musl INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl
export PATH=$PATH:$install_dir/bin export PATH=$PATH:$INSTALL_DIR/bin
cd server cd server
make -j8 make -j$(nproc)
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "demo make failed" echo "demo make failed"
@ -25,9 +25,9 @@ fi
mkdir -p image/etc mkdir -p image/etc
cp /etc/resolv.conf image/etc cp /etc/resolv.conf image/etc
cp ../greeter_server image/bin cp ../greeter_server image/bin
cp $install_dir/lib/libprotobuf.so.3.10.0.0 image/lib cp $INSTALL_DIR/lib/libprotobuf.so.3.10.0.0 image/lib
cp $install_dir/lib/libcares.so.2 image/lib cp $INSTALL_DIR/lib/libcares.so.2 image/lib
cp $install_dir/lib/libz.so.1 image/lib cp $INSTALL_DIR/lib/libz.so.1 image/lib
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "libraries copied failed" echo "libraries copied failed"

@ -32,7 +32,7 @@ if [ ! -d "$CURLDIR" ] ; then
mv curl-curl-7_29_0 curl && \ mv curl-curl-7_29_0 curl && \
echo "Download curl successfully" || exit 1 echo "Download curl successfully" || exit 1
else else
echo "The openssl code is already existent" echo "The curl code is already existent"
fi fi
# Download other dependencies # Download other dependencies
@ -88,7 +88,8 @@ if [ ! -f "$INSTALLDIR/lib/libcurl.so" ] ; then
echo "Building curl ..." echo "Building curl ..."
CC=occlum-gcc CXX=occlum-g++ ./configure \ CC=occlum-gcc CXX=occlum-g++ ./configure \
--prefix=$INSTALLDIR \ --prefix=$INSTALLDIR \
--with-ssl=$INSTALLDIR && \ --with-ssl=$INSTALLDIR \
--without-zlib && \
make -j${nproc} && \ make -j${nproc} && \
sudo make install && \ sudo make install && \
echo "Build curl successfully" || exit 1 echo "Build curl successfully" || exit 1