Skip to content

Commit 27dbe2e

Browse files
authored
Update Emscripten to v3.1.1. (#133)
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
1 parent c17bf82 commit 27dbe2e

File tree

8 files changed

+46
-38
lines changed

8 files changed

+46
-38
lines changed

‎BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ proto_library(
104104
)
105105

106106
filegroup(
107-
name = "jslib",
107+
name = "proxy_wasm_intrinsics_js",
108108
srcs = [
109109
"proxy_wasm_intrinsics.js",
110110
],

‎README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ sudo make install
175175
git clone https://github.com/emscripten-core/emsdk.git
176176
cd emsdk
177177
./emsdk update-tags
178-
./emsdk install 2.0.7
179-
./emsdk activate 2.0.7
178+
./emsdk install 3.1.1
179+
./emsdk activate 3.1.1
180180

181181
source ./emsdk\_env.sh
182182
```
@@ -189,7 +189,7 @@ It is possible later versions will work, e.g.
189189
./emsdk activate latest
190190
```
191191

192-
However 2.0.7 is known to work.
192+
However 3.1.1 is known to work.
193193

194194
### Rebuilding the libprotobuf.a files
195195

‎bazel/dep/deps.bzl

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,27 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
15+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
16+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
1617

1718
def wasm_dependencies():
18-
_http_archive(
19+
maybe(
20+
http_archive,
1921
name = "emscripten_toolchain",
2022
build_file = "@proxy_wasm_cpp_sdk//:emscripten-toolchain.BUILD",
2123
patch_cmds = [
22-
"./emsdk install 2.0.7",
23-
"./emsdk activate --embedded 2.0.7",
24+
"./emsdk install 3.1.1",
25+
"./emsdk activate --embedded 3.1.1",
2426
],
25-
strip_prefix = "emsdk-2.0.7",
26-
url = "https://github.com/emscripten-core/emsdk/archive/2.0.7.tar.gz",
27-
sha256 = "ce7a5c76e8b425aca874cea329fd9ac44b203b777053453b6a37b4496c5ce34f"
27+
strip_prefix = "emsdk-3.1.1",
28+
url = "https://github.com/emscripten-core/emsdk/archive/3.1.1.tar.gz",
29+
sha256 = "3a4893f0bb8203469e1197aa235fc49ed6f5dd2d490e9244a6899a8ad860f3e6",
2830
)
2931

30-
_http_archive(
32+
maybe(
33+
http_archive,
3134
name = "com_google_protobuf",
3235
sha256 = "77ad26d3f65222fd96ccc18b055632b0bfedf295cb748b712a98ba1ac0b704b2",
3336
strip_prefix = "protobuf-3.17.3",
3437
url = "https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz",
3538
)
36-
37-
def _http_archive(name, **kwargs):
38-
existing_rule_keys = native.existing_rules().keys()
39-
if name in existing_rule_keys:
40-
# This repository has already been defined.
41-
return
42-
43-
http_archive(
44-
name = name,
45-
**kwargs
46-
)

‎bazel/wasm/wasm.bzl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,32 @@ wasm_cc_binary_rule = rule(
6868
attrs = _wasm_attrs(wasm_cc_transition),
6969
)
7070

71-
def wasm_cc_binary(name, tags = [], **kwargs):
71+
def wasm_cc_binary(**kwargs):
72+
fail("`wasm_cc_binary` is deprecated. Please use `proxy_wasm_cc_binary`.")
73+
74+
def proxy_wasm_cc_binary(name, additional_linker_inputs = [], linkopts = [], tags = [], deps = [], **kwargs):
7275
wasm_name = "_wasm_" + name
7376
kwargs.setdefault("visibility", ["//visibility:public"])
7477
cc_binary(
7578
name = wasm_name,
79+
additional_linker_inputs = additional_linker_inputs + [
80+
"@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js",
81+
],
82+
linkopts = linkopts + [
83+
"--no-entry",
84+
"--js-library=$(location @proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js)",
85+
"-sSTANDALONE_WASM",
86+
"-sEXPORTED_FUNCTIONS=_malloc",
87+
],
7688
# Adding manual tag it won't be built in non-Wasm (e.g. x86_64 config)
7789
# when an wildcard is specified, but it will be built in Wasm configuration
7890
# when the wasm_binary below is built.
79-
tags = ["manual"],
91+
tags = tags + [
92+
"manual",
93+
],
94+
deps = deps + [
95+
"@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics",
96+
],
8097
**kwargs
8198
)
8299

‎example/BUILD

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
load("//bazel/wasm:wasm.bzl", "wasm_cc_binary")
1+
load("//bazel/wasm:wasm.bzl", "proxy_wasm_cc_binary")
22

33
licenses(["notice"]) # Apache 2
44

5-
wasm_cc_binary(
5+
proxy_wasm_cc_binary(
66
name = "http_wasm_example.wasm",
77
srcs = ["http_wasm_example.cc"],
8-
deps = [
9-
"@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics",
10-
],
118
)

‎sdk_container.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ rm -rf protobuf
5151
git clone https://github.com/emscripten-core/emsdk.git
5252
cd emsdk
5353
./emsdk update-tags
54-
./emsdk install 2.0.7
55-
./emsdk activate 2.0.7
54+
./emsdk install 3.1.1
55+
./emsdk activate 3.1.1
5656
source ./emsdk_env.sh
5757
cd
5858

‎toolchain/cc_toolchain_config.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def _impl(ctx):
7979
flag_group(
8080
flags = [
8181
"-isystem",
82-
"external/emscripten_toolchain/upstream/emscripten/system/include/libcxx",
82+
"external/emscripten_toolchain/upstream/emscripten/cache/sysroot/include/",
8383
"-isystem",
84-
"external/emscripten_toolchain/upstream/emscripten/system/include/libc",
84+
"external/emscripten_toolchain/upstream/lib/clang/14.0.0/include/",
8585
],
8686
),
8787
],
@@ -161,8 +161,8 @@ def _impl(ctx):
161161
# we just need to include them here so that bazel doesn't complain on
162162
# "this rule is missing dependency declarations for the following files included".
163163
cxx_builtin_include_directories = [
164-
"external/emscripten_toolchain/upstream/emscripten/system/include/libcxx",
165-
"external/emscripten_toolchain/upstream/emscripten/system/include/libc",
164+
"external/emscripten_toolchain/upstream/emscripten/cache/sysroot/include/",
165+
"external/emscripten_toolchain/upstream/lib/clang/14.0.0/include/",
166166
],
167167
features = [cxx17_feature, no_canonical_prefixes_feature, opt_feature],
168168
)

‎toolchain/emcc.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -euo pipefail
1818

1919
. $(dirname $0)/common.sh
2020

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

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

0 commit comments

Comments
 (0)