-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8f78ed9
Showing
8 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
patreon: whitequark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
on: [push, pull_request] | ||
name: Build & publish | ||
jobs: | ||
build: | ||
if: ${{ !contains(github.event.head_commit.message, 'skip ci') }} | ||
runs-on: ubuntu-latest | ||
env: | ||
RELEASE_BRANCH: ${{ startsWith(github.event.ref, 'refs/heads/develop-') || startsWith(github.event.ref, 'refs/heads/release-') }} | ||
steps: | ||
- name: Check out source code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip build | ||
sudo apt update | ||
sudo apt-get install flex bison ccache | ||
- name: Set up caching | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/ccache | ||
key: llvm-${{ hashFiles('llvm-src', 'build.sh') }} | ||
restore-keys: | | ||
llvm-${{ hashFiles('llvm-src', 'build.sh') }} | ||
llvm- | ||
- name: Set up ccache | ||
run: | | ||
ccache --max-size=2G -z | ||
- name: Build WASM binaries | ||
run: | | ||
./build.sh | ||
- name: Upload WASM artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist-bare | ||
path: | | ||
llvm-build/bin/clang | ||
llvm-build/bin/lld | ||
# ... snip... | ||
- name: Print ccache statistics | ||
run: | | ||
ccache -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/wasi-sdk-* | ||
*.wasm | ||
|
||
/*-build | ||
/Toolchain-WASI.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "llvm-src"] | ||
path = llvm-src | ||
url = https://github.com/YoWASP/llvm-project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
YoWASP Clang packages | ||
===================== | ||
|
||
Building | ||
-------- | ||
|
||
The primary build environment for this repository is the `ubuntu-latest` GitHub CI runner; packages are built on every push and automatically published from the `release` branch to PyPI. | ||
|
||
To reduce maintenance overhead, the only development environment we will support for this repository is x86_64 Linux. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ISC License | ||
|
||
Copyright (C) Catherine <[email protected]> | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/bin/sh -ex | ||
|
||
export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) | ||
|
||
WASI_SDK=wasi-sdk-22.0 | ||
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz | ||
if ! [ -d ${WASI_SDK} ]; then curl -L ${WASI_SDK_URL} | tar xzf -; fi | ||
WASI_SDK_PATH=$(pwd)/${WASI_SDK} | ||
|
||
WASI_TARGET="wasm32-wasi" | ||
WASI_SYSROOT="--sysroot ${WASI_SDK_PATH}/share/wasi-sysroot" | ||
WASI_CFLAGS="-flto" | ||
WASI_LDFLAGS="-flto -Wl,--strip-all" | ||
# LLVM doesn't build without <mutex>, etc, even with -DLLVM_ENABLE_THREADS=OFF. | ||
WASI_TARGET="${WASI_TARGET}-threads" | ||
WASI_CFLAGS="${WASI_CFLAGS} -pthread" | ||
WASI_LDFLAGS="${WASI_LDFLAGS} -Wl,--max-memory=4294967296" | ||
# LLVM assumes the existence of mmap. | ||
WASI_CFLAGS="${WASI_CFLAGS} -D_WASI_EMULATED_MMAN" | ||
WASI_LDFLAGS="${WASI_LDFLAGS} -lwasi-emulated-mman" | ||
|
||
cat >Toolchain-WASI.cmake <<END | ||
cmake_minimum_required(VERSION 3.4.0) | ||
set(WASI TRUE) | ||
set(CMAKE_SYSTEM_NAME Generic) | ||
set(CMAKE_SYSTEM_VERSION 1) | ||
set(CMAKE_SYSTEM_PROCESSOR wasm32) | ||
set(CMAKE_C_COMPILER ${WASI_SDK_PATH}/bin/clang) | ||
set(CMAKE_CXX_COMPILER ${WASI_SDK_PATH}/bin/clang++) | ||
set(CMAKE_LINKER ${WASI_SDK_PATH}/bin/wasm-ld CACHE STRING "wasienv build") | ||
set(CMAKE_AR ${WASI_SDK_PATH}/bin/ar CACHE STRING "wasienv build") | ||
set(CMAKE_RANLIB ${WASI_SDK_PATH}/bin/ranlib CACHE STRING "wasienv build") | ||
set(CMAKE_C_COMPILER_TARGET ${WASI_TARGET}) | ||
set(CMAKE_CXX_COMPILER_TARGET ${WASI_TARGET}) | ||
set(CMAKE_C_FLAGS "${WASI_SYSROOT} ${WASI_CFLAGS}" CACHE STRING "wasienv build") | ||
set(CMAKE_CXX_FLAGS "${WASI_SYSROOT} ${WASI_CFLAGS}" CACHE STRING "wasienv build") | ||
set(CMAKE_EXE_LINKER_FLAGS "${WASI_LDFLAGS}" CACHE STRING "wasienv build") | ||
set(CMAKE_EXECUTABLE_SUFFIX ".wasm") | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | ||
END | ||
|
||
# The clang binary built as `Debug` doesn't pass Wasm validation. | ||
# (This has cost me a hour of my life.) | ||
|
||
if ! [ -f llvm-tblgen-build/bin/llvm-tblgen -a -f llvm-tblgen-build/bin/clang-tblgen ]; then | ||
mkdir -p llvm-tblgen-build | ||
cmake -B llvm-tblgen-build -S llvm-src/llvm \ | ||
-DLLVM_CCACHE_BUILD=ON \ | ||
-DCMAKE_BUILD_TYPE=MinSizeRel \ | ||
-DLLVM_BUILD_RUNTIME=OFF \ | ||
-DLLVM_BUILD_TOOLS=OFF \ | ||
-DLLVM_INCLUDE_UTILS=OFF \ | ||
-DLLVM_INCLUDE_RUNTIMES=OFF \ | ||
-DLLVM_INCLUDE_EXAMPLES=OFF \ | ||
-DLLVM_INCLUDE_TESTS=OFF \ | ||
-DLLVM_INCLUDE_BENCHMARKS=OFF \ | ||
-DLLVM_INCLUDE_DOCS=OFF \ | ||
-DLLVM_TARGETS_TO_BUILD=WebAssembly \ | ||
-DLLVM_DEFAULT_TARGET_TRIPLE=wasm32-wasi \ | ||
-DLLVM_ENABLE_PROJECTS="clang" \ | ||
-DCLANG_BUILD_EXAMPLES=OFF \ | ||
-DCLANG_BUILD_TOOLS=OFF \ | ||
-DCLANG_INCLUDE_TESTS=OFF | ||
cmake --build llvm-tblgen-build --target llvm-tblgen --target clang-tblgen | ||
fi | ||
|
||
mkdir -p llvm-build | ||
cmake -B llvm-build -S llvm-src/llvm \ | ||
-DCMAKE_TOOLCHAIN_FILE=../Toolchain-WASI.cmake \ | ||
-DLLVM_CCACHE_BUILD=ON \ | ||
-DLLVM_NATIVE_TOOL_DIR=$(pwd)/llvm-tblgen-build/bin \ | ||
-DCMAKE_BUILD_TYPE=MinSizeRel \ | ||
-DLLVM_ENABLE_ASSERTIONS=ON \ | ||
-DLLVM_BUILD_SHARED_LIBS=OFF \ | ||
-DLLVM_ENABLE_PIC=OFF \ | ||
-DLLVM_BUILD_STATIC=ON \ | ||
-DLLVM_ENABLE_THREADS=OFF \ | ||
-DLLVM_BUILD_RUNTIME=OFF \ | ||
-DLLVM_BUILD_TOOLS=OFF \ | ||
-DLLVM_INCLUDE_UTILS=OFF \ | ||
-DLLVM_BUILD_UTILS=OFF \ | ||
-DLLVM_INCLUDE_RUNTIMES=OFF \ | ||
-DLLVM_INCLUDE_EXAMPLES=OFF \ | ||
-DLLVM_INCLUDE_TESTS=OFF \ | ||
-DLLVM_INCLUDE_BENCHMARKS=OFF \ | ||
-DLLVM_INCLUDE_DOCS=OFF \ | ||
-DLLVM_TARGETS_TO_BUILD=WebAssembly \ | ||
-DLLVM_DEFAULT_TARGET_TRIPLE=wasm32-wasi \ | ||
-DLLVM_ENABLE_PROJECTS="clang;lld" \ | ||
-DCLANG_ENABLE_ARCMT=OFF \ | ||
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \ | ||
-DCLANG_BUILD_TOOLS=OFF \ | ||
-DCLANG_BUILD_EXAMPLES=OFF \ | ||
-DCLANG_LINKS_TO_CREATE="clang;clang++" \ | ||
-DLLD_BUILD_TOOLS=OFF | ||
cmake --build llvm-build --target clang --target lld |