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.
This commit is contained in:
parent
bec8bf5e8b
commit
5e8f997d4d
@ -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
|
||||
|
@ -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 <<EOF
|
||||
#!/bin/bash
|
||||
OCCLUM_GCC="\$(which occlum-gcc)"
|
||||
CC=\$OCCLUM_GCC ${INSTALL_DIR}/bin/go "\$@"
|
||||
OCCLUM_GOFLAGS="-buildmode=pie \$GOFLAGS"
|
||||
CC=\$OCCLUM_GCC GOFLAGS=\$OCCLUM_GOFLAGS ${INSTALL_DIR}/bin/go "\$@"
|
||||
EOF
|
||||
|
||||
chmod +x ${INSTALL_DIR}/bin/occlum-go
|
||||
|
Loading…
Reference in New Issue
Block a user