forked from ports/contrib
90 lines
3.5 KiB
Plaintext
90 lines
3.5 KiB
Plaintext
# Description: WASI libc++ implementation for WebAssembly
|
|
# URL: https://libcxx.llvm.org/
|
|
# Maintainer: Danny Rawlins, crux at romster dot me
|
|
# Depends on: clang wasi-libc wasi-compiler-rt
|
|
|
|
name=wasi-libc++
|
|
version=13.0.0
|
|
release=1
|
|
source=(https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/llvm-$version.src.tar.xz
|
|
https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/libcxx-$version.src.tar.xz
|
|
https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/libcxxabi-$version.src.tar.xz
|
|
WASI.cmake
|
|
wasi-toolchain.cmake)
|
|
|
|
build() {
|
|
# Platform files have been copied from https://github.com/WebAssembly/wasi-sdk
|
|
mkdir -p cmake/Platform
|
|
cp WASI.cmake cmake/Platform
|
|
mv libcxx-${version}.src libcxx
|
|
mv libcxxabi-${version}.src libcxxabi
|
|
mv llvm-${version}.src llvm
|
|
|
|
# Build options are derived from https://github.com/WebAssembly/wasi-sdk/blob/main/Makefile
|
|
# Currently, wasi-sdk requires C++ code be compiled with -fno-exceptions.
|
|
# libc++abi is currently compiled with exception-handling support disabled.
|
|
# https://github.com/WebAssembly/wasi-sdk/issues/52#issuecomment-530619365
|
|
cmake -S libcxx -B build-libcxx -G Ninja \
|
|
-D CMAKE_BUILD_TYPE=Release \
|
|
-D CMAKE_C_COMPILER_WORKS=ON \
|
|
-D CMAKE_CXX_COMPILER_WORKS=ON \
|
|
-D CMAKE_MODULE_PATH="$SRC/cmake" \
|
|
-D CMAKE_TOOLCHAIN_FILE="$SRC/wasi-toolchain.cmake" \
|
|
-D CMAKE_STAGING_PREFIX=/usr/share/wasi-sysroot \
|
|
-D LIBCXX_ENABLE_EXCEPTIONS:BOOL=OFF \
|
|
-D LIBCXX_ENABLE_SHARED:BOOL=OFF \
|
|
-D LIBCXX_ENABLE_THREADS:BOOL=OFF \
|
|
-D LIBCXX_HAS_PTHREAD_API:BOOL=OFF \
|
|
-D LIBCXX_HAS_EXTERNAL_THREAD_API:BOOL=OFF \
|
|
-D LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY:BOOL=OFF \
|
|
-D LIBCXX_HAS_WIN32_THREAD_API:BOOL=OFF \
|
|
-D LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY:BOOL=OFF \
|
|
-D LIBCXX_ENABLE_FILESYSTEM:BOOL=OFF \
|
|
-D LIBCXX_CXX_ABI=libcxxabi \
|
|
-D LIBCXX_CXX_ABI_INCLUDE_PATHS=libcxxabi/include \
|
|
-D LIBCXX_HAS_MUSL_LIBC:BOOL=ON \
|
|
-D LIBCXX_ABI_VERSION=2 \
|
|
-D WASI_SDK_PREFIX=/usr \
|
|
-D CMAKE_C_FLAGS_RELEASE="-fno-exceptions --sysroot=/usr/share/wasi-sysroot" \
|
|
-D CMAKE_CXX_FLAGS_RELEASE="-fno-exceptions --sysroot=/usr/share/wasi-sysroot" \
|
|
-D LIBCXX_LIBDIR_SUFFIX=/wasm32-wasi
|
|
|
|
cmake --build build-libcxx
|
|
|
|
cmake -S libcxxabi -B build-libcxxabi -G Ninja \
|
|
-D CMAKE_BUILD_TYPE=Release \
|
|
-D CMAKE_C_COMPILER_WORKS=ON \
|
|
-D CMAKE_CXX_COMPILER_WORKS=ON \
|
|
-D CMAKE_MODULE_PATH="$SRC/cmake" \
|
|
-D CMAKE_TOOLCHAIN_FILE="$SRC/wasi-toolchain.cmake" \
|
|
-D CMAKE_STAGING_PREFIX=/usr/share/wasi-sysroot \
|
|
-D LIBCXXABI_ENABLE_EXCEPTIONS:BOOL=OFF \
|
|
-D LIBCXXABI_ENABLE_SHARED:BOOL=OFF \
|
|
-D LIBCXXABI_ENABLE_THREADS:BOOL=OFF \
|
|
-D LIBCXXABI_HAS_PTHREAD_API:BOOL=OFF \
|
|
-D LIBCXXABI_HAS_EXTERNAL_THREAD_API:BOOL=OFF \
|
|
-D LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY:BOOL=OFF \
|
|
-D LIBCXXABI_HAS_WIN32_THREAD_API:BOOL=OFF \
|
|
-D LIBCXXABI_SILENT_TERMINATE:BOOL=ON \
|
|
-D LIBCXXABI_ENABLE_PIC:BOOL=OFF \
|
|
-D UNIX:BOOL=ON \
|
|
-D CXX_SUPPORTS_CXX11=ON \
|
|
-D LIBCXXABI_LIBCXX_PATH=libcxx \
|
|
-D LIBCXXABI_LIBCXX_INCLUDES="$SRC/build-libcxx/include/c++/v1" \
|
|
-D WASI_SDK_PREFIX=/usr \
|
|
-D CMAKE_C_FLAGS_RELEASE="-fno-exceptions --sysroot=/usr/share/wasi-sysroot" \
|
|
-D CMAKE_CXX_FLAGS_RELEASE="-fno-exceptions --sysroot=/usr/share/wasi-sysroot" \
|
|
-D LIBCXXABI_LIBDIR_SUFFIX=/wasm32-wasi
|
|
|
|
cmake --build build-libcxxabi -v
|
|
|
|
DESTDIR=$PKG cmake --install build-libcxx
|
|
DESTDIR=$PKG cmake --install build-libcxxabi
|
|
|
|
cd $PKG/usr/share/wasi-sysroot/lib/wasm32-wasi
|
|
for f in *.a; do
|
|
/usr/bin/llvm-ranlib $f
|
|
/usr/bin/llvm-strip --strip-debug $f
|
|
done
|
|
}
|