Skip to content

Commit cfb60f4

Browse files
committed
wasm: review-pass cleanup
- Rebase onto main (dissolves the example bzl_library targets removed by #1826 and the embedded file_prefix_map disables removed by #1824). - Use @bazel_tools//src/conditions for the wasmtime host select instead of bespoke config_settings. - Drop web/README.md (covered by the BUILD file) and trim comments. Claude-Session: https://claude.ai/code/session_01SmG1kqA3qB4WsLGU2xavuJ
1 parent 7f3bbfc commit cfb60f4

5 files changed

Lines changed: 12 additions & 93 deletions

File tree

examples/cross_compilation/wasm/BUILD.bazel

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -66,45 +66,13 @@ sh_test(
6666
alias(
6767
name = "wasmtime",
6868
actual = select({
69-
":darwin_arm64": "@wasmtime_darwin_aarch64//:wasmtime",
70-
":darwin_x86_64": "@wasmtime_darwin_x86_64//:wasmtime",
71-
":linux_arm64": "@wasmtime_linux_aarch64//:wasmtime",
72-
":linux_x86_64": "@wasmtime_linux_x86_64//:wasmtime",
69+
"@bazel_tools//src/conditions:darwin_arm64": "@wasmtime_darwin_aarch64//:wasmtime",
70+
"@bazel_tools//src/conditions:darwin_x86_64": "@wasmtime_darwin_x86_64//:wasmtime",
71+
"@bazel_tools//src/conditions:linux_aarch64": "@wasmtime_linux_aarch64//:wasmtime",
72+
"@bazel_tools//src/conditions:linux_x86_64": "@wasmtime_linux_x86_64//:wasmtime",
7373
}),
7474
)
7575

76-
config_setting(
77-
name = "darwin_arm64",
78-
constraint_values = [
79-
"@platforms//cpu:arm64",
80-
"@platforms//os:macos",
81-
],
82-
)
83-
84-
config_setting(
85-
name = "darwin_x86_64",
86-
constraint_values = [
87-
"@platforms//cpu:x86_64",
88-
"@platforms//os:macos",
89-
],
90-
)
91-
92-
config_setting(
93-
name = "linux_arm64",
94-
constraint_values = [
95-
"@platforms//cpu:arm64",
96-
"@platforms//os:linux",
97-
],
98-
)
99-
100-
config_setting(
101-
name = "linux_x86_64",
102-
constraint_values = [
103-
"@platforms//cpu:x86_64",
104-
"@platforms//os:linux",
105-
],
106-
)
107-
10876
# A static web app embedding the reactor: `index.html` + `Reactor.wasm` in one
10977
# directory. Serve it (e.g. `python3 -m http.server -d
11078
# bazel-bin/examples/cross_compilation/wasm/web_app`) and open it — the page

examples/cross_compilation/wasm/web/README.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

swift/internal/extensions/swift_sdks.bzl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,10 @@ def _swift_wasm_sdk_impl(repository_ctx):
377377
"-lwasi-emulated-mman",
378378
"-lwasi-emulated-signal",
379379
"-lwasi-emulated-process-clocks",
380-
# Place the linear-memory data and the indirect function table at the
381-
# same bases `swiftc` uses for its own wasm links. The Swift driver
382-
# always passes these to wasm-ld; in particular `--table-base=4096`
383-
# is required — optimized (`-O`) Swift relies on the indirect
384-
# function table starting where the runtime/codegen expects it, and
385-
# without it generic-metadata instantiation reads out of bounds at
386-
# runtime (`__swift_instantiateGenericMetadata` faults). `-Onone`
387-
# happens to tolerate the default base, which masks the bug.
380+
# The Swift driver always passes these bases to wasm-ld.
381+
# `--table-base=4096` in particular is required: without it,
382+
# optimized (`-O`) generic-metadata instantiation reads out of
383+
# bounds at runtime (`-Onone` happens to tolerate the default).
388384
"-Wl,--global-base=4096",
389385
"-Wl,--table-base=4096",
390386
]),

swift/internal/extensions/toolchains.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ toolchain(
5555
)
5656
"""
5757

58-
# Unlike Android (whose C/C++ toolchain comes from a separately registered
59-
# Android cc toolchain), the WebAssembly SDK repository also generates a
60-
# rules_cc cc_toolchain that drives the paired toolchain's clang.
6158
_WASM_SDK_TOOLCHAIN_PLATFORM = """
6259
# Swift SDK toolchains from repository: `{sdk_repository}`
6360
toolchain(

swift/swift_binary.bzl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,10 @@ def _swift_binary_impl(ctx):
203203
else:
204204
name = ctx.label.name
205205

206-
# When targeting WebAssembly a `linkshared` binary is a "reactor" module: it
207-
# is still produced as an `executable`-shaped wasm file (not a `-shared`
208-
# dynamic library), but linked with the reactor execution model so it has no
209-
# `_start`/`main` and instead exports functions for a host to call.
210-
# Everywhere else, `linkshared` produces a real dynamic library
211-
# (`lib<name>.so` / `.dylib`), matching `cc_binary`'s `linkshared`.
206+
# On WebAssembly a `linkshared` binary is a "reactor": an executable-shaped
207+
# wasm module linked with `-mexec-model=reactor` (no `main`; it exports
208+
# functions for a host to call). Everywhere else `linkshared` produces a
209+
# real dynamic library, matching `cc_binary`.
212210
shared_link_flags = []
213211
if ctx.attr.linkshared and not is_wasm:
214212
output_type = "dynamic_library"

0 commit comments

Comments
 (0)