From 5e8f997d4d9ae187fc7994b237c622e0a66c0c48 Mon Sep 17 00:00:00 2001 From: "Tate, Hongliang Tian" Date: Tue, 11 Aug 2020 04:30:18 +0000 Subject: [PATCH] Make PIE the default mode for Go toolchain Occlum-compatible executable binaries must be Position-Independent Executable (PIE). Previously, to build such binaries, the users need to explicitly give `-buildmode=pie` flag to `occlum-go`. Apparently, this is error-prone. This commit sets `-buildmode=pie` by default for `occlum-go`. In addition, this commit upgrades the Go version to 1.13.7. --- demos/golang/README.md | 2 +- tools/toolchains/golang/build.sh | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/demos/golang/README.md b/demos/golang/README.md index 7f52fa44..ad999847 100644 --- a/demos/golang/README.md +++ b/demos/golang/README.md @@ -9,7 +9,7 @@ occlum-go get -u -v github.com/gin-gonic/gin Step 2: Build the Golang web server using the Occlum Golang toolchain(i.e., `occlum-go`) ``` -occlum-go build -o web_server -buildmode=pie ./web_server.go +occlum-go build -o web_server ./web_server.go ``` Step 3: You can run the web server demo on Occlum via diff --git a/tools/toolchains/golang/build.sh b/tools/toolchains/golang/build.sh index 8c64a15b..a404ec85 100755 --- a/tools/toolchains/golang/build.sh +++ b/tools/toolchains/golang/build.sh @@ -16,8 +16,8 @@ cd ${BUILD_DIR} # Download Golang git clone https://github.com/golang/go . -# Swtich to Golang 1.13.4 -git checkout -b go1.13.4 tags/go1.13.4 +# Swtich to Golang 1.13.7 +git checkout -b go1.13.7 tags/go1.13.7 # Apply the patch to adapt Golang to Occlum git apply ${THIS_DIR}/0001-adapt-golang-to-occlum-libos.patch @@ -30,7 +30,8 @@ mv ${BUILD_DIR} ${INSTALL_DIR} cat > ${INSTALL_DIR}/bin/occlum-go <