Skip to content

Update Emscripten to v3.1.1. #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ proto_library(
)

filegroup(
name = "jslib",
name = "proxy_wasm_intrinsics_js",
srcs = [
"proxy_wasm_intrinsics.js",
],
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ sudo make install
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk update-tags
./emsdk install 2.0.7
./emsdk activate 2.0.7
./emsdk install 3.1.1
./emsdk activate 3.1.1

source ./emsdk\_env.sh
```
Expand All @@ -189,7 +189,7 @@ It is possible later versions will work, e.g.
./emsdk activate latest
```

However 2.0.7 is known to work.
However 3.1.1 is known to work.

### Rebuilding the libprotobuf.a files

Expand Down
28 changes: 10 additions & 18 deletions bazel/dep/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,26 @@
# limitations under the License.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

def wasm_dependencies():
_http_archive(
maybe(
http_archive,
name = "emscripten_toolchain",
build_file = "@proxy_wasm_cpp_sdk//:emscripten-toolchain.BUILD",
patch_cmds = [
"./emsdk install 2.0.7",
"./emsdk activate --embedded 2.0.7",
"./emsdk install 3.1.1",
"./emsdk activate --embedded 3.1.1",
],
strip_prefix = "emsdk-2.0.7",
url = "https://github.com/emscripten-core/emsdk/archive/2.0.7.tar.gz",
sha256 = "ce7a5c76e8b425aca874cea329fd9ac44b203b777053453b6a37b4496c5ce34f"
strip_prefix = "emsdk-3.1.1",
url = "https://github.com/emscripten-core/emsdk/archive/3.1.1.tar.gz",
sha256 = "3a4893f0bb8203469e1197aa235fc49ed6f5dd2d490e9244a6899a8ad860f3e6"
)

_http_archive(
maybe(
http_archive,
name = "com_google_protobuf",
sha256 = "77ad26d3f65222fd96ccc18b055632b0bfedf295cb748b712a98ba1ac0b704b2",
strip_prefix = "protobuf-3.17.3",
url = "https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz",
)

def _http_archive(name, **kwargs):
existing_rule_keys = native.existing_rules().keys()
if name in existing_rule_keys:
# This repository has already been defined.
return

http_archive(
name = name,
**kwargs
)
16 changes: 14 additions & 2 deletions bazel/wasm/wasm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,27 @@ wasm_cc_binary_rule = rule(
attrs = _wasm_attrs(wasm_cc_transition),
)

def wasm_cc_binary(name, tags = [], **kwargs):
def wasm_cc_binary(name, additional_linker_inputs = [], linkopts = [], tags = [], deps = [], **kwargs):
wasm_name = "_wasm_" + name
kwargs.setdefault("visibility", ["//visibility:public"])
cc_binary(
name = wasm_name,
additional_linker_inputs = additional_linker_inputs + [
"@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js",
],
linkopts = linkopts + [
"--no-entry",
"--js-library=$(location @proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js)",
"-sSTANDALONE_WASM",
"-sEXPORTED_FUNCTIONS=_malloc",
],
# Adding manual tag it won't be built in non-Wasm (e.g. x86_64 config)
# when an wildcard is specified, but it will be built in Wasm configuration
# when the wasm_binary below is built.
tags = ["manual"],
tags = tags + ["manual"],
deps = deps + [
"@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics",
],
**kwargs
)

Expand Down
3 changes: 0 additions & 3 deletions example/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ licenses(["notice"]) # Apache 2
wasm_cc_binary(
name = "http_wasm_example.wasm",
srcs = ["http_wasm_example.cc"],
deps = [
"@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics",
],
)
4 changes: 2 additions & 2 deletions sdk_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ rm -rf protobuf
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk update-tags
./emsdk install 2.0.7
./emsdk activate 2.0.7
./emsdk install 3.1.1
./emsdk activate 3.1.1
source ./emsdk_env.sh
cd

Expand Down
8 changes: 4 additions & 4 deletions toolchain/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def _impl(ctx):
flag_group(
flags = [
"-isystem",
"external/emscripten_toolchain/upstream/emscripten/system/include/libcxx",
"external/emscripten_toolchain/upstream/emscripten/cache/sysroot/include/",
"-isystem",
"external/emscripten_toolchain/upstream/emscripten/system/include/libc",
"external/emscripten_toolchain/upstream/lib/clang/14.0.0/include/",
],
),
],
Expand Down Expand Up @@ -161,8 +161,8 @@ def _impl(ctx):
# we just need to include them here so that bazel doesn't complain on
# "this rule is missing dependency declarations for the following files included".
cxx_builtin_include_directories = [
"external/emscripten_toolchain/upstream/emscripten/system/include/libcxx",
"external/emscripten_toolchain/upstream/emscripten/system/include/libc",
"external/emscripten_toolchain/upstream/emscripten/cache/sysroot/include/",
"external/emscripten_toolchain/upstream/lib/clang/14.0.0/include/",
],
features = [cxx17_feature, no_canonical_prefixes_feature, opt_feature],
)
Expand Down
6 changes: 4 additions & 2 deletions toolchain/emcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -euo pipefail

. $(dirname $0)/common.sh

emcc --no-entry -s EXPORTED_FUNCTIONS=['_malloc'] "$@"
emcc "$@"

# clang doesn't support `-no-canonical-system-headers` so sed it
# find the .d file in the args and fix it:
Expand All @@ -27,7 +27,9 @@ for arg in "$@"
do
if [ "${arg: -2}" == ".d" ]; then
echo Fixing $arg
sed -e 's%[^ ]*/external/emscripten_toolchain/upstream/emscripten/system/%external/emscripten_toolchain/upstream/emscripten/system/%' $arg > $arg.tmp
sed -e 's%[^ ]*/tmp/emscripten_cache/sysroot/include/%external/emscripten_toolchain/upstream/emscripten/cache/sysroot/include/%' $arg > $arg.tmp
mv $arg.tmp $arg
sed -e 's%[^ ]*/external/emscripten_toolchain/upstream/lib/clang/%external/emscripten_toolchain/upstream/lib/clang/%' $arg > $arg.tmp
mv $arg.tmp $arg
# some zlib headers are treated as system headers
sed -e 's%[^ ]*/external/zlib/%external/zlib/%' $arg > $arg.tmp
Expand Down