Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
TerrorJack committed Jan 13, 2021
1 parent b36c433 commit 41fa329
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 15 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/asterius.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Asterius

on:
- push
- pull_request

jobs:

build:
name: build-threads-${{ matrix.threads }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
threads:
- ON
- OFF
env:
threads: ${{ matrix.threads }}
steps:

- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive

- name: build
run: |
if [ $threads == ON ]; then
git apply -v enable_threads.patch
fi
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-threads-${{ matrix.threads }}
path: dist
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -108,7 +105,7 @@ build/compiler-rt.BUILT: build/llvm.BUILT
-DCOMPILER_RT_ENABLE_IOS=OFF \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=On \
-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)/ \
Expand All @@ -134,7 +131,7 @@ LIBCXX_CMAKE_FLAGS = \
-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 \
Expand All @@ -150,8 +147,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
Expand All @@ -177,7 +174,7 @@ LIBCXXABI_CMAKE_FLAGS = \
-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 \
Expand All @@ -191,8 +188,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
Expand Down
14 changes: 14 additions & 0 deletions asterius_build.sh
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions enable_threads.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/Makefile b/Makefile
index 36350f1..bbcf62e 100644
--- a/Makefile
+++ b/Makefile
@@ -104,6 +104,7 @@ 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="-Oz -flto $(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \
-DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \
@@ -126,8 +127,8 @@ 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 \
@@ -166,8 +167,8 @@ 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 \
2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 29235 files
2 changes: 1 addition & 1 deletion src/wasi-libc

0 comments on commit 41fa329

Please sign in to comment.