taskcluster/scripts/misc/build-sysroot-wasi.sh
author Andrew McCreight <continuation@gmail.com>
Fri, 27 May 2022 13:15:11 +0000
changeset 619075 cf40e7b79bb18c1e4c18726eb603702304cc531e
parent 617319 d983e2ef8ee9704618a3c7b4d1c468bb29f6c84c
permissions -rwxr-xr-x
Bug 1771381 - Use entries in TabAttributesInternal.set(). r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D147457

#!/bin/bash
set -x -e -v

artifact=$(basename $TOOLCHAIN_ARTIFACT)
sysroot=${artifact%.tar.*}

cd $MOZ_FETCHES_DIR/wasi-sdk
LLVM_PROJ_DIR=$MOZ_FETCHES_DIR/llvm-project

mkdir -p build/install/wasi
# The wasi-sdk build system wants to build clang itself. We trick it into
# thinking it did, and put our own clang where it would have built its own.
ln -s $MOZ_FETCHES_DIR/clang build/llvm
touch build/llvm.BUILT

# The wasi-sdk build system has a dependency on compiler-rt for libcxxabi,
# but that's not actually necessary. Pretend it's already built
touch build/compiler-rt.BUILT

# The wasi-sdk build system wants a clang and an ar binary in
# build/install/$PREFIX/bin
ln -s $MOZ_FETCHES_DIR/clang/bin build/install/wasi/bin
ln -s llvm-ar build/install/wasi/bin/ar

# Build wasi-libc, libc++ and libc++abi.
make \
  LLVM_PROJ_DIR=$LLVM_PROJ_DIR \
  PREFIX=/wasi \
  build/wasi-libc.BUILT \
  build/libcxx.BUILT \
  -j$(nproc)

mv build/install/wasi/share/wasi-sysroot $sysroot
tar --zstd -cf $artifact $sysroot
mkdir -p $UPLOAD_DIR
mv $artifact $UPLOAD_DIR/