From 73641d83a83572a4bb4346be4d6761e39d80b563 Mon Sep 17 00:00:00 2001 From: Christopher Serr Date: Wed, 11 Dec 2024 21:34:46 +0100 Subject: [PATCH] Turn On WebAssembly Tail Calls With Safari 18.2 having shipped today, all browsers now support WebAssembly Tail Calls. This allows the compiler to call a function at the end of the current function by reusing the stack frame. This should be a tiny bit faster and allow for recursion without stack overflows... except that Rust doesn't have any way of guaranteeing this yet, so you can't really rely on it. --- .github/workflows/ci.yml | 1 + buildCore.js | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e83f3b89..908287f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,6 +188,7 @@ jobs: --enable-extended-const \ --enable-multivalue \ --enable-reference-types \ + --enable-tail-call \ --strip-dwarf \ --strip-producers \ --strip-target-features \ diff --git a/buildCore.js b/buildCore.js index 0313e805..69821aa0 100644 --- a/buildCore.js +++ b/buildCore.js @@ -6,7 +6,7 @@ let profile = "debug"; let cargoFlags = ""; // Keep .github/workflows/ci.yml in sync with these flags, so wasm-opt works. let rustFlags = - "-C target-feature=+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext,+simd128,+extended-const,+multivalue,+reference-types"; + "-C target-feature=+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext,+simd128,+extended-const,+multivalue,+reference-types,+tail-call"; let wasmBindgenFlags = "--encode-into always --target web --reference-types"; let target = "wasm32-unknown-unknown"; let targetFolder = target; @@ -28,9 +28,6 @@ if (process.argv.some((v) => v === "--max-opt")) { if (process.argv.some((v) => v === "--unstable")) { // Relaxed SIMD is not supported by Firefox and Safari yet. rustFlags += ",+relaxed-simd"; - - // Tail calls are not supported by Safari yet until 18.2 (early December). - rustFlags += ",+tail-call"; } // Use the nightly toolchain, which enables some more optimizations.