diff --git a/tools/installer/README.md b/tools/installer/README.md index ae84fdee..aad6082a 100644 --- a/tools/installer/README.md +++ b/tools/installer/README.md @@ -26,7 +26,7 @@ If a user wants to build his application on a platform installed with Occlum ins cd tools/installer/deb make ``` -Now, only `musl-gcc` and `golang` options are supported. And the installer can be found under `build/debs`. +Now, only `musl-gcc`, `glibc` and `golang` options are supported. And the installer can be found under `build/debs`. ### How to Use @@ -36,7 +36,7 @@ To run Occlum on clean Ubuntu 18.04, please follow below steps: **Step 1. Install Prerequisites** ``` apt-get update -DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libcurl4-openssl-dev libssl-dev libprotobuf-dev libfuse-dev autoconf automake make cmake libtool gdb python jq ca-certificates gnupg wget vim +DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libcurl4-openssl-dev libssl-dev libprotobuf-dev libfuse-dev autoconf automake make cmake libtool gdb python jq ca-certificates gnupg wget vim rsync ``` **Step 2. Install IntelĀ® SGX driver and IntelĀ® SGX PSW** @@ -65,11 +65,16 @@ apt install -y ./occlum-sgx-tools*.deb ``` 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: +To install musl C/C++ toolchain, just run the command: ``` apt install -y ./occlum-toolchains-gcc*.deb ``` +Also, users can install glibc to support glibc based applications. +``` +apt install -y ./occlum-toolchains-glibc*.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 diff --git a/tools/installer/deb/Makefile b/tools/installer/deb/Makefile index 75e07c14..83140ce5 100644 --- a/tools/installer/deb/Makefile +++ b/tools/installer/deb/Makefile @@ -18,10 +18,11 @@ C_TOOLCHAIN_PACKAGE_NAME := occlum-toolchains-gcc # update the "changelog" file accordingly. MUSL_VERSION := 0.27.0 GOLAN_VERSION := 0.16.0 +GLIBC_VERSION := 2.31 GO_PATCH = $(PROJECT_DIR)/tools/toolchains/golang/adapt-golang-to-occlum.patch -.PHONY: all main config_files main_deps musl-gcc deps_c clean clean-build +.PHONY: all main config_files main_deps musl-gcc deps_c glibc deps_glibc clean clean-build all: main @@ -78,6 +79,17 @@ deps_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 +glibc: deps_glibc + cd $(DEB_BUILD_DIR)/occlum-toolchains-glibc ; \ + dpkg-buildpackage -us -uc + cp -t $(TARGET_DIR) $(DEB_BUILD_DIR)/occlum-toolchains-glibc*.deb + +deps_glibc: + mkdir -p $(TARGET_DIR) + mkdir -p $(DEB_BUILD_DIR)/occlum-toolchains-glibc + cp -r toolchains/glibc $(DEB_BUILD_DIR)/occlum-toolchains-glibc/debian + sed -i -e 's/$$GLIBC_VERSION/$(GLIBC_VERSION)/g' $(DEB_BUILD_DIR)/occlum-toolchains-glibc/debian/changelog + clean-build: rm -rf $(DEB_BUILD_DIR) clean: clean-build diff --git a/tools/installer/deb/toolchains/glibc/changelog b/tools/installer/deb/toolchains/glibc/changelog new file mode 100644 index 00000000..6acfd548 --- /dev/null +++ b/tools/installer/deb/toolchains/glibc/changelog @@ -0,0 +1,5 @@ +occlum-toolchains-glibc (2.31-1) unstable; urgency=medium + + * Initial release + + -- Qi Zheng Tue, 13 Sep 2022 14:37:39 +0000 diff --git a/tools/installer/deb/toolchains/glibc/compat b/tools/installer/deb/toolchains/glibc/compat new file mode 100644 index 00000000..f599e28b --- /dev/null +++ b/tools/installer/deb/toolchains/glibc/compat @@ -0,0 +1 @@ +10 diff --git a/tools/installer/deb/toolchains/glibc/control b/tools/installer/deb/toolchains/glibc/control new file mode 100644 index 00000000..c8aaf0a1 --- /dev/null +++ b/tools/installer/deb/toolchains/glibc/control @@ -0,0 +1,12 @@ +Source: occlum-toolchains-glibc +Section: libs +Priority: optional +Maintainer: Qi Zheng +Build-Depends: debhelper (>=9), autoconf, automake, build-essential, cmake, libtool, ocaml, ocamlbuild, python, libssl-dev, libcurl4-openssl-dev, libprotobuf-dev, git, protobuf-compiler +Standards-Version: 4.1.2 +Homepage: https://github.com/occlum/glibc + +Package: occlum-toolchains-glibc +Architecture: amd64 +Depends: ${misc:Depends}, ${shlibs:Depends} +Description: Occlum glibc libraries diff --git a/tools/installer/deb/toolchains/glibc/rules b/tools/installer/deb/toolchains/glibc/rules new file mode 100755 index 00000000..e4b070aa --- /dev/null +++ b/tools/installer/deb/toolchains/glibc/rules @@ -0,0 +1,61 @@ +#!/usr/bin/make -f +export DH_VERBOSE = 1 +export deb_build_dir = /tmp/deb_build +export name = occlum-toolchains-glibc +export buildroot := $(deb_build_dir)/$(name)/debian/$(name) + +export tmp_build_dir = $(deb_build_dir)/$(name)/tmp_build +export src_dir = $(tmp_build_dir)/glibc +export install_dir = $(buildroot)/opt/occlum/glibc + +SHELL = /bin/bash + +export DEB_BUILD_MAINT_OPTIONS=hardening=+pie,-fortify + +# Users can pass "-j$(nproc)" by specifying this env. +# This is not enabled by default because under certain scenarios, +# make will use too many jobs and gcc will be killed because out +# of memory. +BUILD_OPTIONS += + +.ONESHELL: prepare_glibc override_dh_install + +%: + dh $@ + +# All rules executed in one shell +prepare_glibc: + rm -rf $(tmp_build_dir) + rm -rf $(install_dir) + mkdir -p $(src_dir) + cd $(src_dir) + git clone -b occlum-glibc-2.31 https://github.com/occlum/glibc . + + +override_dh_auto_build: prepare_glibc + mkdir -p $(tmp_build_dir)/build + cd $(tmp_build_dir)/build + unset LD_LIBRARY_PATH + ${src_dir}/configure \ + --prefix=${install_dir} --with-tls --without-selinux \ + --disable-nscd + make + + +# We create symlinks in /usr/local +override_dh_usrlocal: + echo "Skip ..." + +override_dh_fixperms: + dh_fixperms + +override_dh_install: + cd $(tmp_build_dir)/build + make install + +clean: + dh_clean + rm -f $(buildroot) + +override_dh_shlibdeps: + echo "skip ..." diff --git a/tools/installer/deb/toolchains/glibc/source/format b/tools/installer/deb/toolchains/glibc/source/format new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tools/installer/deb/toolchains/glibc/source/format @@ -0,0 +1 @@ +1.0