-
Couldn't load subscription status.
- Fork 10.6k
utils/build-script: add--test-with-wasm-runtime option #83573
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
base: main
Are you sure you want to change the base?
Conversation
--test-with-wasm-runtime for runtime selection--test-with-wasm-runtime option | @swift-ci smoke test |
| I'm not a big fan of adding more and more wasm specific options in build-script and test/CMakeLists.txt just for local development TBH as we have to propagate things from build-script to lit.cfg correctly. config.target_run = os.environ.get('SWIFT_TEST_WASM_RUNTIME', os.path.join(config.swift_utils, 'wasm-run.py'))This gives us the flexibility to experiment more runtimes while keeping the build stuff clean |
| IMO env vars are significantly worse than |
| @swift-ci smoke test macos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you feel strongly about this direction, I'm OK with going ahead as is.
| print("wasmstdlib testing: Wasm runtime not found") | ||
| sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
| if not os.path.exists(wasmkit_bin_path) or not self.should_test_executable(): | ||
| | ||
| wasm_runtime_bin_path = self.infer_wasm_runtime(host_target) | ||
| print(f"wasm_runtime_bin_path is {wasm_runtime_bin_path}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug code?
| command.append(f"{key}={envs[key]}") | ||
| command.append("--") | ||
| if args.runtime == 'nodejs': | ||
| command = [os.path.join(os.path.dirname(__file__), 'wasm', 'node-wasi-runner')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to forward env vars from collect_wasm_env and command line args as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't Node.js WASI inherit env vars by default? And args are passed below in command.extend(args)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, I missed the command args.
We need to set env vars prefixed with WASM_RUN_CHILD_ from host to guest while stripping the prefix. You can find it in collect_wasm_env.
utils/swift_build_support/swift_build_support/products/wasmstdlib.py Outdated Show resolved Hide resolved
utils/swift_build_support/swift_build_support/products/wasmstdlib.py Outdated Show resolved Hide resolved
| | ||
| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| sys.exit(1) | ||
| | ||
| def infer_wasm_runtime(self, host_target) -> str: | ||
| '''Return absolute path to the Wasm runtime used''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| '''Return absolute path to the Wasm runtime used''' | |
| '''Returns absolute path to the Wasm runtime used''' |
With this change, passing
--test-with-wasm-runtime=nodejs/--test-with-wasm-runtime=wasmkittobuild-scriptallows switching between WasmKit and Node.js for running Wasm tests locally. Existing presets keep using WasmKit, so CI behavior is not impacted. Potentially, availability of a JS runtime allows writing tests that exercise JS interop for custom concurrency executors.Differences between the runtimes:
with WasmKit on M4
check-swift-wasi-wasm32-customtarget completes in 115 seconds withstdlib/PrintFloat16.swiftthe slowest test (115 seconds):with Node.js on M4 there's ~5x speedup in
check-swift-wasi-wasm32-customtarget at a cost of one failing test (reason TBC):