forked from vmware-labs/webassembly-language-runtimes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: allow to skip wasm-opt when invoked by clang
By exporting the WASMLABS_SKIP_WASM_OPT envvar, the wasm-opt wrapper present in the wasm-base container image will make the wasm-opt call a no-op. This is useful for cases when we don't desire wasm-opt to be called, for example when invoked directly by clang (llvm/llvm-project#55781).
- Loading branch information
Showing
6 changed files
with
88 additions
and
3 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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
FROM ubuntu:20.04 | ||
ARG BINARYEN_VERSION=111 | ||
ARG BINARYEN_VERSION | ||
ENV BINARYEN_PATH=/opt | ||
RUN apt update && \ | ||
DEBIAN_FRONTEND=noninteractive apt install -y \ | ||
wget && \ | ||
wget https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz && \ | ||
tar -xf binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz --strip-components=1 -C /opt && \ | ||
rm binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz | ||
ENV PATH="$PATH:/opt/bin" | ||
rm binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz && \ | ||
mkdir -p /opt/priority-bin | ||
# wasm-opt is called in unexpected contexts | ||
# (https://github.com/llvm/llvm-project/issues/55781). To avoid this, | ||
# we install a `wasm-opt` wrapper with a higher priority in the PATH | ||
# that can disable wasm-opt execution when desired. | ||
ADD images/wasm-base/wasm-opt /opt/priority-bin/ | ||
ENV PATH="/opt/priority-bin:$PATH:/opt/bin" |
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,42 @@ | ||
#!//usr/bin/env bash | ||
# Inspired by https://raw.githubusercontent.com/ruby/ruby/df6b72b8ff7af16a56fa48f3b4abb1d8850f4d1c/wasm/wasm-opt | ||
# | ||
# A fake wasm-opt, which does nothing at all | ||
# See also: tool/wasm-clangw | ||
|
||
if [[ -z "${WASMLABS_SKIP_WASM_OPT}" ]]; then | ||
exec $BINARYEN_PATH/bin/wasm-opt "$@" | ||
fi | ||
|
||
set -e | ||
input= | ||
output= | ||
while [ $# -ne 0 ]; do | ||
case "$1" in | ||
-o) | ||
shift | ||
output=$1 | ||
;; | ||
-*) | ||
# ignore other options | ||
;; | ||
*) | ||
input=$1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ -z "$input" ]; then | ||
echo "missing input binary" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$output" ]; then | ||
echo "missing output binary" | ||
exit 1 | ||
fi | ||
|
||
if [ "$input" != "$output" ]; then | ||
cp "$input" "$output" | ||
fi |
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
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
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
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