From b368b8b12ee6321d92f07c7d67f994aa09bc64a3 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Tue, 27 Oct 2020 13:37:08 +0000 Subject: [PATCH] Update llvm & wasi-libc Enable LTO Add Asterius CI job --- .github/workflows/asterius.yml | 35 ++++++++++++++++++++++++++++++++++ .gitmodules | 2 +- Makefile | 30 ++++++++++++++--------------- asterius_build.sh | 14 ++++++++++++++ src/llvm-project | 2 +- src/wasi-libc | 2 +- 6 files changed, 66 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/asterius.yml create mode 100755 asterius_build.sh diff --git a/.github/workflows/asterius.yml b/.github/workflows/asterius.yml new file mode 100644 index 000000000..fb9296171 --- /dev/null +++ b/.github/workflows/asterius.yml @@ -0,0 +1,35 @@ +name: Asterius + +on: + - push + - pull_request + +jobs: + + build: + name: build + runs-on: ubuntu-20.04 + steps: + + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: recursive + + - name: build + run: | + podman run \ + --network host \ + --pull always \ + --rm \ + --volume $(pwd):$(pwd) \ + --workdir $(pwd) \ + debian:sid-slim \ + ./asterius_build.sh + + - name: upload-artifact + uses: actions/upload-artifact@v2 + with: + name: dist-asterius + path: dist diff --git a/.gitmodules b/.gitmodules index e8b2eace4..70d05071c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,7 @@ url = https://github.com/llvm/llvm-project [submodule "src/wasi-libc"] path = src/wasi-libc - url = https://github.com/CraneStation/wasi-libc + url = https://github.com/TerrorJack/wasi-libc [submodule "src/config"] path = src/config url = https://git.savannah.gnu.org/git/config.git diff --git a/Makefile b/Makefile index fcf8ab85f..1725fc575 100644 --- a/Makefile +++ b/Makefile @@ -59,15 +59,12 @@ build/llvm.BUILT: -DCMAKE_INSTALL_PREFIX=$(PREFIX) \ -DLLVM_TARGETS_TO_BUILD=WebAssembly \ -DLLVM_DEFAULT_TARGET_TRIPLE=wasm32-wasi \ - -DLLVM_ENABLE_PROJECTS="lld;clang;clang-tools-extra" \ + -DLLVM_ENABLE_PROJECTS="lld;clang" \ -DDEFAULT_SYSROOT=$(PREFIX)/share/wasi-sysroot \ -DLLVM_INSTALL_BINUTILS_SYMLINKS=TRUE \ $(LLVM_PROJ_DIR)/llvm DESTDIR=$(DESTDIR) ninja $(NINJA_FLAGS) -v -C build/llvm \ install-clang \ - install-clang-format \ - install-clang-tidy \ - install-clang-apply-replacements \ install-lld \ install-llvm-ranlib \ install-llvm-strip \ @@ -99,7 +96,7 @@ build/compiler-rt.BUILT: build/llvm.BUILT -DCMAKE_CXX_COMPILER_WORKS=ON \ -DCMAKE_AR=$(BUILD_PREFIX)/bin/ar \ -DCMAKE_MODULE_PATH=$(ROOT_DIR)/cmake \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ -DCMAKE_TOOLCHAIN_FILE=$(ROOT_DIR)/wasi-sdk.cmake \ -DCOMPILER_RT_BAREMETAL_BUILD=On \ -DCOMPILER_RT_BUILD_XRAY=OFF \ @@ -107,8 +104,9 @@ build/compiler-rt.BUILT: build/llvm.BUILT -DCOMPILER_RT_HAS_FPIC_FLAG=OFF \ -DCOMPILER_RT_ENABLE_IOS=OFF \ -DCOMPILER_RT_DEFAULT_TARGET_ONLY=On \ + -DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF \ -DWASI_SDK_PREFIX=$(BUILD_PREFIX) \ - -DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ + -DCMAKE_C_FLAGS="-Oz -flto $(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ -DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \ -DCOMPILER_RT_OS_DIR=wasi \ -DCMAKE_INSTALL_PREFIX=$(PREFIX)/lib/clang/$(CLANG_VERSION)/ \ @@ -129,12 +127,12 @@ LIBCXX_CMAKE_FLAGS = \ -DCMAKE_STAGING_PREFIX=$(PREFIX)/share/wasi-sysroot \ -DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ - -DLIBCXX_ENABLE_THREADS:BOOL=OFF \ - -DLIBCXX_HAS_PTHREAD_API:BOOL=OFF \ + -DLIBCXX_ENABLE_THREADS:BOOL=ON \ + -DLIBCXX_HAS_PTHREAD_API:BOOL=ON \ -DLIBCXX_HAS_EXTERNAL_THREAD_API:BOOL=OFF \ -DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY:BOOL=OFF \ -DLIBCXX_HAS_WIN32_THREAD_API:BOOL=OFF \ - -DCMAKE_BUILD_TYPE=RelWithDebugInfo \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ -DLIBCXX_ENABLE_SHARED:BOOL=OFF \ -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY:BOOL=OFF \ -DLIBCXX_ENABLE_EXCEPTIONS:BOOL=OFF \ @@ -150,8 +148,8 @@ build/libcxx.BUILT: build/llvm.BUILT build/compiler-rt.BUILT build/wasi-libc.BUI # Do the build. mkdir -p build/libcxx cd build/libcxx && cmake -G Ninja $(LIBCXX_CMAKE_FLAGS) \ - -DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ - -DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ + -DCMAKE_C_FLAGS="-Oz -flto $(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ + -DCMAKE_CXX_FLAGS="-Oz -flto $(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ -DLIBCXX_LIBDIR_SUFFIX=$(ESCAPE_SLASH)/wasm32-wasi \ $(LLVM_PROJ_DIR)/libcxx ninja $(NINJA_FLAGS) -v -C build/libcxx @@ -169,15 +167,15 @@ LIBCXXABI_CMAKE_FLAGS = \ -DLIBCXXABI_ENABLE_EXCEPTIONS:BOOL=OFF \ -DLIBCXXABI_ENABLE_SHARED:BOOL=OFF \ -DLIBCXXABI_SILENT_TERMINATE:BOOL=ON \ - -DLIBCXXABI_ENABLE_THREADS:BOOL=OFF \ - -DLIBCXXABI_HAS_PTHREAD_API:BOOL=OFF \ + -DLIBCXXABI_ENABLE_THREADS:BOOL=ON \ + -DLIBCXXABI_HAS_PTHREAD_API:BOOL=ON \ -DLIBCXXABI_HAS_EXTERNAL_THREAD_API:BOOL=OFF \ -DLIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY:BOOL=OFF \ -DLIBCXXABI_HAS_WIN32_THREAD_API:BOOL=OFF \ -DLIBCXXABI_ENABLE_PIC:BOOL=OFF \ -DCXX_SUPPORTS_CXX11=ON \ -DLLVM_COMPILER_CHECKED=ON \ - -DCMAKE_BUILD_TYPE=RelWithDebugInfo \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ -DLIBCXXABI_LIBCXX_PATH=$(LLVM_PROJ_DIR)/libcxx \ -DLIBCXXABI_LIBCXX_INCLUDES=$(BUILD_PREFIX)/share/wasi-sysroot/include/c++/v1 \ -DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \ @@ -191,8 +189,8 @@ build/libcxxabi.BUILT: build/libcxx.BUILT build/llvm.BUILT # Do the build. mkdir -p build/libcxxabi cd build/libcxxabi && cmake -G Ninja $(LIBCXXABI_CMAKE_FLAGS) \ - -DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ - -DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ + -DCMAKE_C_FLAGS="-Oz -flto $(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ + -DCMAKE_CXX_FLAGS="-Oz -flto $(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \ -DLIBCXXABI_LIBDIR_SUFFIX=$(ESCAPE_SLASH)/wasm32-wasi \ $(LLVM_PROJ_DIR)/libcxxabi ninja $(NINJA_FLAGS) -v -C build/libcxxabi diff --git a/asterius_build.sh b/asterius_build.sh new file mode 100755 index 000000000..c796fb37f --- /dev/null +++ b/asterius_build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euo pipefail + +apt update +apt full-upgrade -y +apt install -y \ + build-essential \ + cmake \ + git \ + ninja-build \ + python3 + +make package diff --git a/src/llvm-project b/src/llvm-project index 176249bd6..99eb0f16c 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 176249bd6732a8044d457092ed932768724a6f06 +Subproject commit 99eb0f16c35cdaa04dea4c5bbad4f86408e9dcfd diff --git a/src/wasi-libc b/src/wasi-libc index 378fd4b21..44191df4f 160000 --- a/src/wasi-libc +++ b/src/wasi-libc @@ -1 +1 @@ -Subproject commit 378fd4b21aab6d390f3a1c1817d53c422ad00a62 +Subproject commit 44191df4f1578c18242dc1fac086183c7871c966