File tree Expand file tree Collapse file tree 10 files changed +108
-9
lines changed Expand file tree Collapse file tree 10 files changed +108
-9
lines changed Original file line number Diff line number Diff line change 1- ARG WASM_BASE=20220116
1+ ARG WASM_BASE
22FROM ghcr.io/vmware-labs/wasm-base:${WASM_BASE}
3- ARG WASI_SDK_VERSION=19
3+ ARG WASI_SDK_VERSION
44ENV WASI_SDK=wasi-sdk-${WASI_SDK_VERSION}
55ENV WASI_SDK_ROOT=/wasi-sdk
66ENV WASI_SDK_PATH=${WASI_SDK_ROOT}
Original file line number Diff line number Diff line change 11FROM ubuntu:20.04
2- ARG BINARYEN_VERSION=111
2+ ARG BINARYEN_VERSION
3+ ENV BINARYEN_PATH=/opt
34RUN apt update && \
45 DEBIAN_FRONTEND=noninteractive apt install -y \
56 wget && \
67 wget https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz && \
78 tar -xf binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz --strip-components=1 -C /opt && \
8- rm binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz
9- ENV PATH="$PATH:/opt/bin"
9+ rm binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz && \
10+ mkdir -p /opt/priority-bin
11+ # wasm-opt is called in unexpected contexts
12+ # (https://github.com/llvm/llvm-project/issues/55781). To avoid this,
13+ # we install a `wasm-opt` wrapper with a higher priority in the PATH
14+ # that can disable wasm-opt execution when desired.
15+ ADD images/wasm-base/wasm-opt /opt/priority-bin/
16+ ENV PATH="/opt/priority-bin:$PATH:/opt/bin"
Original file line number Diff line number Diff line change 11BUILDER_ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
22
3+ WASM_BASE_TAG ?= $(shell git rev-parse --short HEAD)
4+
35.PHONY: wasm-base
46wasm-base:
5- docker build --build-arg BINARYEN_VERSION=111 -f ${BUILDER_ROOT_DIR}/Dockerfile.wasm-base -t ghcr.io/vmware-labs/wasm-base:20220116 ${BUILDER_ROOT_DIR}
7+ docker build --build-arg BINARYEN_VERSION=111 -f ${BUILDER_ROOT_DIR}/Dockerfile.wasm-base -t ghcr.io/vmware-labs/wasm-base:$(WASM_BASE_TAG) ${BUILDER_ROOT_DIR}
68
79.PHONY: wasi-builder-19
810wasi-builder-19: wasm-base
9- docker build --build-arg WASI_SDK_VERSION=19 -f ${BUILDER_ROOT_DIR}/Dockerfile.wasi-builder -t ghcr.io/vmware-labs/wasi-builder:19 ${BUILDER_ROOT_DIR}
11+ docker build --build-arg WASM_BASE=$(WASM_BASE_TAG) --build-arg WASI_SDK_VERSION=19 -f ${BUILDER_ROOT_DIR}/Dockerfile.wasi-builder -t ghcr.io/vmware-labs/wasi-builder:19 ${BUILDER_ROOT_DIR}
Original file line number Diff line number Diff line change 1+ #! //usr/bin/env bash
2+ # Inspired by
3+ # https://raw.githubusercontent.com/ruby/ruby/df6b72b8ff7af16a56fa48f3b4abb1d8850f4d1c/wasm/wasm-opt
4+ #
5+ # A fake wasm-opt, which does nothing at all
6+ # See also: tool/wasm-clangw
7+
8+ function logStatus {
9+ if [[ -n " ${WASMLABS_OUTPUT} " ]]; then
10+ echo " $( date --iso-8601=ns) | $@ " >> $WASMLABS_OUTPUT /wasmlabs-progress.log
11+ else
12+ echo " $( date --iso-8601=ns) | $@ "
13+ fi
14+ }
15+
16+ if [[ -z " ${WASMLABS_SKIP_WASM_OPT} " ]]; then
17+ logStatus " wasm-opt (with args \" $@ \" ) was intercepted; executing $BINARYEN_PATH /bin/wasm-opt"
18+ exec $BINARYEN_PATH /bin/wasm-opt " $@ "
19+ fi
20+
21+ logStatus " wasm-opt (with args \" $@ \" ) was intercepted; this invocation will be a no-op"
22+
23+ set -e
24+ input=
25+ output=
26+ while [ $# -ne 0 ]; do
27+ case " $1 " in
28+ -o)
29+ shift
30+ output=$1
31+ ;;
32+ -* )
33+ # ignore other options
34+ ;;
35+ * )
36+ input=$1
37+ ;;
38+ esac
39+ shift
40+ done
41+
42+ if [ -z " $input " ]; then
43+ echo " missing input binary"
44+ exit 1
45+ fi
46+
47+ if [ -z " $output " ]; then
48+ echo " missing output binary"
49+ exit 1
50+ fi
51+
52+ if [ " $input " != " $output " ]; then
53+ cp " $input " " $output "
54+ fi
Original file line number Diff line number Diff line change 1- ARG WASI_SDK_VERSION=19
1+ ARG WASI_SDK_VERSION
22FROM ghcr.io/vmware-labs/wasi-builder:${WASI_SDK_VERSION}
33RUN DEBIAN_FRONTEND=noninteractive apt install -y \
44 bison \
Original file line number Diff line number Diff line change @@ -31,7 +31,16 @@ logStatus "Configuring build with '${PHP_CONFIGURE}'... "
3131./configure --host=wasm32-wasi host_alias=wasm32-musl-wasi --target=wasm32-wasi target_alias=wasm32-musl-wasi ${PHP_CONFIGURE} || exit 1
3232
3333logStatus " Building php-cgi... "
34+ # By exporting WASMLABS_SKIP_WASM_OPT envvar during the build, the
35+ # wasm-opt wrapper in the wasm-base image will be a dummy wrapper that
36+ # is effectively a NOP.
37+ #
38+ # This is due to https://github.com/llvm/llvm-project/issues/55781, so
39+ # that we get to choose which optimization passes are executed after
40+ # the artifacts have been built.
41+ export WASMLABS_SKIP_WASM_OPT=1
3442make cgi || exit 1
43+ unset WASMLABS_SKIP_WASM_OPT
3544
3645logStatus " Preparing artifacts... "
3746mkdir -p ${WASMLABS_OUTPUT} /bin 2> /dev/null || exit 1
Original file line number Diff line number Diff line change 4343fi
4444
4545logStatus " Building '${MAKE_TARGETS} '... "
46+ # By exporting WASMLABS_SKIP_WASM_OPT envvar during the build, the
47+ # wasm-opt wrapper in the wasm-base image will be a dummy wrapper that
48+ # is effectively a NOP.
49+ #
50+ # This is due to https://github.com/llvm/llvm-project/issues/55781, so
51+ # that we get to choose which optimization passes are executed after
52+ # the artifacts have been built.
53+ export WASMLABS_SKIP_WASM_OPT=1
4654make -j ${MAKE_TARGETS} || exit 1
55+ unset WASMLABS_SKIP_WASM_OPT
4756
4857logStatus " Preparing artifacts... "
4958mkdir -p ${WASMLABS_OUTPUT} /bin 2> /dev/null || exit 1
Original file line number Diff line number Diff line change @@ -35,7 +35,16 @@ logStatus "Configuring build with '${PHP_CONFIGURE}'... "
3535./configure --host=wasm32-wasi host_alias=wasm32-musl-wasi --target=wasm32-wasi target_alias=wasm32-musl-wasi ${PHP_CONFIGURE} || exit 1
3636
3737logStatus " Building php-cgi... "
38+ # By exporting WASMLABS_SKIP_WASM_OPT envvar during the build, the
39+ # wasm-opt wrapper in the wasm-base image will be a dummy wrapper that
40+ # is effectively a NOP.
41+ #
42+ # This is due to https://github.com/llvm/llvm-project/issues/55781, so
43+ # that we get to choose which optimization passes are executed after
44+ # the artifacts have been built.
45+ export WASMLABS_SKIP_WASM_OPT=1
3846make cgi || exit 1
47+ unset WASMLABS_SKIP_WASM_OPT
3948
4049logStatus " Preparing artifacts... "
4150mkdir -p ${WASMLABS_OUTPUT} /bin 2> /dev/null || exit 1
Original file line number Diff line number Diff line change 4646fi
4747
4848logStatus " Building '${MAKE_TARGETS} '... "
49+ # By exporting WASMLABS_SKIP_WASM_OPT envvar during the build, the
50+ # wasm-opt wrapper in the wasm-base image will be a dummy wrapper that
51+ # is effectively a NOP.
52+ #
53+ # This is due to https://github.com/llvm/llvm-project/issues/55781, so
54+ # that we get to choose which optimization passes are executed after
55+ # the artifacts have been built.
56+ export WASMLABS_SKIP_WASM_OPT=1
4957make -j ${MAKE_TARGETS} || exit 1
58+ unset WASMLABS_SKIP_WASM_OPT
5059
5160logStatus " Preparing artifacts... "
5261mkdir -p ${WASMLABS_OUTPUT} /bin 2> /dev/null || exit 1
Original file line number Diff line number Diff line change 1- ARG WASI_SDK_VERSION=19
1+ ARG WASI_SDK_VERSION
22FROM ghcr.io/vmware-labs/wasi-builder:${WASI_SDK_VERSION}
33RUN DEBIAN_FRONTEND=noninteractive apt install -y \
44 ruby \
You can’t perform that action at this time.
0 commit comments