Add Golang installer
This commit is contained in:
parent
f4e1352b41
commit
8fbd6295bf
@ -26,7 +26,7 @@ If a user wants to build his application on a platform installed with Occlum ins
|
|||||||
cd tools/installer/rpm
|
cd tools/installer/rpm
|
||||||
make <language option>
|
make <language option>
|
||||||
```
|
```
|
||||||
Now, only `c/c++` option is supported. And the installer can be found under `build/rpms`.
|
Now, only `c/c++` and `golang` options are supported. And the installer can be found under `build/rpms`.
|
||||||
|
|
||||||
### How to Use
|
### How to Use
|
||||||
|
|
||||||
@ -59,11 +59,19 @@ rpm -i occlum-pal-*.rpm
|
|||||||
rpm -i occlum-runtime-*.rpm
|
rpm -i occlum-runtime-*.rpm
|
||||||
```
|
```
|
||||||
|
|
||||||
Toolchains are needed when compiling applications and also during runtime. Choose to install the toolchain installer based on the application's language. Currently, we only supports `C/C++`. More language toolchain installers are on the way. To install `C/C++` toolchain, just run the command:
|
Toolchains are needed when compiling applications and also during runtime. C/C++ toolchain is a must for Occlum commands.
|
||||||
|
To install C/C++ toolchain, just run the command:
|
||||||
```
|
```
|
||||||
rpm -i occlum-toolchains-gcc-*.rpm
|
rpm -i occlum-toolchains-gcc-*.rpm
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Besides, users can choose to install the toolchain installer based on the application's language. Currently, we also supports Golang. More language toolchain installers are on the way. To install Golang toolchain, run the below commands:
|
||||||
|
```
|
||||||
|
yum install -y epel-release
|
||||||
|
yum install -y rc
|
||||||
|
rpm -i occlum-toolchains-golang-*.rpm
|
||||||
|
```
|
||||||
|
|
||||||
At last, install `occlum` package to get complete support of Occlum:
|
At last, install `occlum` package to get complete support of Occlum:
|
||||||
```
|
```
|
||||||
rpm -i occlum_*.rpm
|
rpm -i occlum_*.rpm
|
||||||
@ -99,7 +107,7 @@ If a user wants to build his application on a platform installed with Occlum ins
|
|||||||
cd tools/installer/deb
|
cd tools/installer/deb
|
||||||
make <language option>
|
make <language option>
|
||||||
```
|
```
|
||||||
Now, only `c/c++` option is supported. And the installer can be found under `build/debs`.
|
Now, only `c/c++` and `golang` options are supported. And the installer can be found under `build/debs`.
|
||||||
|
|
||||||
### How to Use
|
### How to Use
|
||||||
|
|
||||||
@ -137,11 +145,17 @@ apt install -y ./occlum-pal*.deb
|
|||||||
apt install -y ./occlum-sgx-tools*.deb
|
apt install -y ./occlum-sgx-tools*.deb
|
||||||
```
|
```
|
||||||
|
|
||||||
Currently, we only supports `C/C++`. More language toolchain installers are on the way. To install `C/C++` toolchain, just run the command:
|
Toolchains are needed when compiling applications and also during runtime. C/C++ toolchain is a must for Occlum commands.
|
||||||
|
To install C/C++ toolchain, just run the command:
|
||||||
```
|
```
|
||||||
apt install -y ./occlum-toolchains-gcc*.deb
|
apt install -y ./occlum-toolchains-gcc*.deb
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Besides, users can choose to install the toolchain installer based on the application's language. Currently, we also supports Golang. More language toolchain installers are on the way. To install Golang toolchain, run the below commands:
|
||||||
|
```
|
||||||
|
apt install -y ./occlum-toolchains-golang*.deb
|
||||||
|
```
|
||||||
|
|
||||||
At last, install `occlum` package to get complete support of Occlum:
|
At last, install `occlum` package to get complete support of Occlum:
|
||||||
```
|
```
|
||||||
apt install -y ./occlum_*.deb
|
apt install -y ./occlum_*.deb
|
||||||
|
@ -10,6 +10,8 @@ VERSION_NUM = $(MAJOR_VER_NUM).$(MINOR_VER_NUM).$(PATCH_VER_NUM)
|
|||||||
DEB_BUILD_DIR := /tmp/deb_build
|
DEB_BUILD_DIR := /tmp/deb_build
|
||||||
PACKAGE_DIR := /tmp
|
PACKAGE_DIR := /tmp
|
||||||
|
|
||||||
|
GO_PATCH = $(PROJECT_DIR)/tools/toolchains/golang/adapt-golang-to-occlum.patch
|
||||||
|
|
||||||
.PHONY: all main config_files main_deps c/c++ deps_c clean clean-build
|
.PHONY: all main config_files main_deps c/c++ deps_c clean clean-build
|
||||||
|
|
||||||
all: main
|
all: main
|
||||||
@ -53,6 +55,17 @@ deps_c:
|
|||||||
cp $(PROJECT_DIR)/tools/installer/rpm/toolchains/gcc/occlum-gcc.sh $(DEB_BUILD_DIR)/occlum-toolchains-gcc/debian
|
cp $(PROJECT_DIR)/tools/installer/rpm/toolchains/gcc/occlum-gcc.sh $(DEB_BUILD_DIR)/occlum-toolchains-gcc/debian
|
||||||
echo " echo 'Please execute command \"source /etc/profile\" to validate envs immediately' " > $(DEB_BUILD_DIR)/occlum-toolchains-gcc/debian/occlum-gcc.postinst
|
echo " echo 'Please execute command \"source /etc/profile\" to validate envs immediately' " > $(DEB_BUILD_DIR)/occlum-toolchains-gcc/debian/occlum-gcc.postinst
|
||||||
|
|
||||||
|
golang: deps_golang
|
||||||
|
cd $(DEB_BUILD_DIR)/occlum-toolchains-golang ; \
|
||||||
|
dpkg-buildpackage -us -uc
|
||||||
|
cp -t $(TARGET_DIR) $(DEB_BUILD_DIR)/occlum-toolchains-golang*.deb
|
||||||
|
|
||||||
|
deps_golang:
|
||||||
|
mkdir -p $(TARGET_DIR)
|
||||||
|
mkdir -p $(DEB_BUILD_DIR)/occlum-toolchains-golang
|
||||||
|
cp -r toolchains/golang $(DEB_BUILD_DIR)/occlum-toolchains-golang/debian
|
||||||
|
cp -t $(DEB_BUILD_DIR)/occlum-toolchains-golang/debian $(GO_PATCH) $(PROJECT_DIR)/tools/installer/rpm/toolchains/golang/occlum-go.sh
|
||||||
|
|
||||||
clean-build:
|
clean-build:
|
||||||
rm -rf $(DEB_BUILD_DIR)
|
rm -rf $(DEB_BUILD_DIR)
|
||||||
clean: clean-build
|
clean: clean-build
|
||||||
|
@ -40,7 +40,6 @@ prepare_musl:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
override_dh_auto_build: prepare_musl
|
override_dh_auto_build: prepare_musl
|
||||||
cd $(tmp_build_dir)/musl-cross-make
|
|
||||||
cd $(tmp_build_dir)/musl-cross-make; \
|
cd $(tmp_build_dir)/musl-cross-make; \
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
|
|
||||||
|
5
tools/installer/deb/toolchains/golang/changelog
Normal file
5
tools/installer/deb/toolchains/golang/changelog
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
occlum-toolchains-golang (0.16.0-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Initial release
|
||||||
|
|
||||||
|
-- Chunyang Hui <sanqian.hcy@antfin.com> Tue, 18 Aug 2020 14:37:39 +0000
|
1
tools/installer/deb/toolchains/golang/compat
Normal file
1
tools/installer/deb/toolchains/golang/compat
Normal file
@ -0,0 +1 @@
|
|||||||
|
10
|
12
tools/installer/deb/toolchains/golang/control
Normal file
12
tools/installer/deb/toolchains/golang/control
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Source: occlum-toolchains-golang
|
||||||
|
Section: libs
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Chunyang Hui <sanqian.hcy@antfin.com>
|
||||||
|
Build-Depends: debhelper (>=9), libfile-stripnondeterminism-perl (>= 0.028~), autoconf, automake, cmake, libtool, ocaml, ocamlbuild, python, libssl-dev, libcurl4-openssl-dev, libprotobuf-dev, git, protobuf-compiler
|
||||||
|
Standards-Version: 4.1.2
|
||||||
|
Homepage: https://github.com/golang/go
|
||||||
|
|
||||||
|
Package: occlum-toolchains-golang
|
||||||
|
Architecture: amd64
|
||||||
|
Depends: ${misc:Depends}, ${shlibs:Depends}
|
||||||
|
Description: Occlum go toolchains
|
64
tools/installer/deb/toolchains/golang/rules
Executable file
64
tools/installer/deb/toolchains/golang/rules
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
export DH_VERBOSE = 1
|
||||||
|
export deb_build_dir = /tmp/deb_build
|
||||||
|
export name = occlum-toolchains-golang
|
||||||
|
export buildroot := $(deb_build_dir)/$(name)/debian/$(name)
|
||||||
|
|
||||||
|
export tmp_build_dir = $(deb_build_dir)/$(name)/tmp_build
|
||||||
|
export install_dir = $(buildroot)/opt/occlum/toolchains/golang
|
||||||
|
|
||||||
|
SHELL = /bin/bash
|
||||||
|
|
||||||
|
# Needed by musl-cross-make config
|
||||||
|
TARGET = x86_64-linux-musl
|
||||||
|
GCC_VER = 8.3.0
|
||||||
|
GO_VERSION = 1.13.7
|
||||||
|
GO_REPO = https://github.com/golang/go/archive/go$(GO_VERSION).tar.gz
|
||||||
|
GO_PATCH = adapt-golang-to-occlum.patch
|
||||||
|
|
||||||
|
.ONESHELL: prepare override_dh_install
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
|
|
||||||
|
# All rules executed in one shell
|
||||||
|
prepare:
|
||||||
|
rm -rf $(tmp_build_dir)
|
||||||
|
rm -rf $(install_dir)
|
||||||
|
mkdir -p $(tmp_build_dir)
|
||||||
|
cd $(tmp_build_dir)
|
||||||
|
wget $(GO_REPO)
|
||||||
|
tar -xvzf go$(GO_VERSION).tar.gz
|
||||||
|
cd go-go$(GO_VERSION)
|
||||||
|
patch -p1 < $(deb_build_dir)/$(name)/debian/$(GO_PATCH)
|
||||||
|
|
||||||
|
override_dh_auto_build: prepare
|
||||||
|
cd $(tmp_build_dir)/go-go$(GO_VERSION)/src; \
|
||||||
|
export GO_LDFLAGS="-compressdwarf=false"; \
|
||||||
|
./make.bash
|
||||||
|
|
||||||
|
override_dh_install:
|
||||||
|
mkdir -p $(buildroot)/opt/occlum/toolchains
|
||||||
|
mv $(tmp_build_dir)/go-go$(GO_VERSION)/ $(install_dir)
|
||||||
|
rm -rf $(install_dir)/.git*
|
||||||
|
cat > $(install_dir)/bin/occlum-go <<EOF
|
||||||
|
#!/bin/bash
|
||||||
|
OCCLUM_GCC="\$$(which occlum-gcc)"
|
||||||
|
OCCLUM_GOFLAGS="-buildmode=pie \$$GOFLAGS"
|
||||||
|
CC=\$$OCCLUM_GCC GOFLAGS=\$$OCCLUM_GOFLAGS /opt/occlum/toolchains/golang/bin/go "\$$@"
|
||||||
|
EOF
|
||||||
|
chmod +x $(install_dir)/bin/occlum-go
|
||||||
|
|
||||||
|
mkdir -p $(buildroot)/etc/profile.d
|
||||||
|
cp $(deb_build_dir)/$(name)/debian/occlum-go.sh $(buildroot)/etc/profile.d
|
||||||
|
chmod 644 $(buildroot)/etc/profile.d/occlum-go.sh
|
||||||
|
|
||||||
|
clean:
|
||||||
|
dh_clean
|
||||||
|
rm -f $(buildroot)
|
||||||
|
|
||||||
|
# Skip stripping
|
||||||
|
override_dh_strip_nondeterminism:
|
||||||
|
override_dh_strip:
|
||||||
|
override_dh_shlibdeps:
|
||||||
|
echo "skip ..."
|
1
tools/installer/deb/toolchains/golang/source/format
Normal file
1
tools/installer/deb/toolchains/golang/source/format
Normal file
@ -0,0 +1 @@
|
|||||||
|
1.0
|
@ -16,9 +16,12 @@ EXPORT_SCRIPT = occlum-pal.sh occlum-runtime.sh
|
|||||||
GCC_PATCH = toolchains/gcc/musl-cross-make-disable-download.patch
|
GCC_PATCH = toolchains/gcc/musl-cross-make-disable-download.patch
|
||||||
GCC_SCRIPT = toolchains/gcc/occlum-gcc.sh
|
GCC_SCRIPT = toolchains/gcc/occlum-gcc.sh
|
||||||
|
|
||||||
|
GO_PATCH = $(PROJECT_DIR)/tools/toolchains/golang/adapt-golang-to-occlum.patch
|
||||||
|
GO_SCRIPT = toolchains/golang/occlum-go.sh
|
||||||
|
|
||||||
PACKAGE_DIR = /tmp
|
PACKAGE_DIR = /tmp
|
||||||
|
|
||||||
.PHONY: all main main_deps c/c++ deps_c clean
|
.PHONY: all main main_deps c/c++ deps_c clean golang
|
||||||
|
|
||||||
all: main
|
all: main
|
||||||
|
|
||||||
@ -61,7 +64,23 @@ $$HOME/rpmbuild/SOURCES/$(GCC_PATCH):
|
|||||||
@spectool -g -R --define '_musl_version $(MUSL_VERSION)' toolchains/gcc/occlum-toolchains-gcc.spec
|
@spectool -g -R --define '_musl_version $(MUSL_VERSION)' toolchains/gcc/occlum-toolchains-gcc.spec
|
||||||
@cp -t $$HOME/rpmbuild/SOURCES $(GCC_PATCH) $(GCC_SCRIPT)
|
@cp -t $$HOME/rpmbuild/SOURCES $(GCC_PATCH) $(GCC_SCRIPT)
|
||||||
|
|
||||||
|
golang: $$HOME/rpmbuild/SOURCES/$(GO_PATCH)
|
||||||
|
@rpmbuild -ba toolchains/golang/occlum-toolchains-golang.spec
|
||||||
|
@mv $$HOME/rpmbuild $$HOME/rpmbuild-occlum-toolchains-golang
|
||||||
|
@cp $$HOME/rpmbuild-occlum-toolchains-golang/RPMS/x86_64/*.rpm $(TARGET_DIR)
|
||||||
|
@echo "$$(ls $$HOME/rpmbuild-occlum-toolchains-golang/RPMS/x86_64) can be found at $(TARGET_DIR)"
|
||||||
|
|
||||||
|
$$HOME/rpmbuild/SOURCES/$(GO_PATCH):
|
||||||
|
@mkdir -p $(TARGET_DIR)
|
||||||
|
@yum install -y rpmdevtools
|
||||||
|
@if [ -d $$HOME/rpmbuild ]; then \
|
||||||
|
mv $$HOME/rpmbuild $$HOME/rpmbuild-old-$$(date +%Y%m%d-%T); fi
|
||||||
|
@rm -rf $$HOME/rpmbuild/{BUILD,RPMS,SPECS,SRPMS} # tmp
|
||||||
|
@mkdir -p $$HOME/rpmbuild/{BUILD,RPMS,SPECS,SOURCES,SRPMS}
|
||||||
|
@spectool -g -R toolchains/golang/occlum-toolchains-golang.spec
|
||||||
|
@cp -t $$HOME/rpmbuild/SOURCES $(GO_PATCH) $(GO_SCRIPT)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -rf $(PACKAGE_DIR)/occlum-$(VERSION_NUM)
|
@rm -rf $(PACKAGE_DIR)/occlum-$(VERSION_NUM)
|
||||||
@rm -rf $$HOME/rpmbuild $$HOME/rpmbuild-occlum-toolchains-gcc $$HOME/rpmbuild-occlum
|
@rm -rf $$HOME/rpmbuild $$HOME/rpmbuild-occlum-toolchains* $$HOME/rpmbuild-occlum
|
||||||
@rm -rf $(TARGET_DIR)
|
@rm -rf $(TARGET_DIR)
|
||||||
|
1
tools/installer/rpm/toolchains/golang/occlum-go.sh
Normal file
1
tools/installer/rpm/toolchains/golang/occlum-go.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
export PATH="$PATH:/opt/occlum/toolchains/golang/bin"
|
@ -0,0 +1,70 @@
|
|||||||
|
%define centos_base_release 1
|
||||||
|
|
||||||
|
%define INSTALL_DIR /opt/occlum/toolchains
|
||||||
|
%define GO_VERSION 1.13.7
|
||||||
|
|
||||||
|
# Skip no build id error
|
||||||
|
%undefine _missing_build_ids_terminate_build
|
||||||
|
|
||||||
|
# Skip stripping and building debug packages
|
||||||
|
%define __strip /bin/true
|
||||||
|
%define debug_package %{nil}
|
||||||
|
%define _unpackaged_files_terminate_build 0
|
||||||
|
|
||||||
|
Name: occlum-toolchains-golang
|
||||||
|
Version: 0.16.0
|
||||||
|
Release: %{centos_base_release}%{?dist}
|
||||||
|
Summary: occlum toolchains golang
|
||||||
|
|
||||||
|
Group: Development/Libraries
|
||||||
|
License: BSD License
|
||||||
|
URL: https://github.com/occlum/occlum
|
||||||
|
Source0: https://github.com/golang/go/archive/go%{GO_VERSION}.tar.gz
|
||||||
|
Source1: adapt-golang-to-occlum.patch
|
||||||
|
Source2: occlum-go.sh
|
||||||
|
|
||||||
|
ExclusiveArch: x86_64
|
||||||
|
|
||||||
|
BuildRequires: golang
|
||||||
|
|
||||||
|
%description
|
||||||
|
Occlum toolchains golang
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q -c -n go-go%{GO_VERSION}
|
||||||
|
#%setup -q -c -T -D -a 1
|
||||||
|
|
||||||
|
# Apply the patch to adapt Golang to Occlum
|
||||||
|
cd go-go%{GO_VERSION}
|
||||||
|
patch -p1 < %{SOURCE1}
|
||||||
|
|
||||||
|
%build
|
||||||
|
cd go-go%{GO_VERSION}/src
|
||||||
|
# Disable compressed debug info
|
||||||
|
./make.bash
|
||||||
|
|
||||||
|
%install
|
||||||
|
mkdir -p %{buildroot}%{INSTALL_DIR}
|
||||||
|
mv go-go%{GO_VERSION} %{buildroot}%{INSTALL_DIR}/golang
|
||||||
|
rm -rf %{buildroot}%{INSTALL_DIR}/golang/.git*
|
||||||
|
cat > %{buildroot}%{INSTALL_DIR}/golang/bin/occlum-go <<EOF
|
||||||
|
#!/bin/bash
|
||||||
|
OCCLUM_GCC="\$(which occlum-gcc)"
|
||||||
|
OCCLUM_GOFLAGS="-buildmode=pie \$GOFLAGS"
|
||||||
|
CC=\$OCCLUM_GCC GOFLAGS=\$OCCLUM_GOFLAGS %{INSTALL_DIR}/golang/bin/go "\$@"
|
||||||
|
EOF
|
||||||
|
chmod +x %{buildroot}%{INSTALL_DIR}/golang/bin/occlum-go
|
||||||
|
|
||||||
|
# install occlum-go.sh
|
||||||
|
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
|
||||||
|
install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/
|
||||||
|
|
||||||
|
%files
|
||||||
|
/opt/occlum/toolchains/golang/*
|
||||||
|
/etc/profile.d/occlum-go.sh
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Fri Sep 11 2020 Chunyang Hui <sanqian.hcy@antgroup.com> - 0.15.1-1
|
||||||
|
- package init
|
||||||
|
* Wed Jul 22 2020 Chunmei Xu <xuchunmei@linux.alibaba.com> - 0.14.0-1
|
||||||
|
- package init
|
Loading…
Reference in New Issue
Block a user