Skip to content

Commit

Permalink
Add -mcpu=mvp flag to Wasm builds for compatibility
Browse files Browse the repository at this point in the history
Starting from clang 16, the default Wasm features used silently include
sign-extension which is not part of MVP and is not supported by some old
browsers/devices like iPhone 6. This currently only affects
meshopt_encoder module which is typically not used on device, but a
future C++ or a compiler code change could silently introduce these
instructions in a way that is difficult to test.

For now just disable this since it's not helpful for performance or code
size. We could revisit this in a few years, but clang's policy of
updating features seems irresponsible as it is not actually favoring
compatibility by default.

This change doesn't rebuild js/ binaries, that can happen separately.
  • Loading branch information
zeux committed Jul 23, 2024
1 parent 72486be commit 2660c95
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ WASIROOT?=$(WASI_SDK)/share/wasi-sysroot

WASM_FLAGS=--target=wasm32-wasi --sysroot=$(WASIROOT)
WASM_FLAGS+=-O3 -DNDEBUG -nostartfiles -nostdlib -Wl,--no-entry -Wl,-s
WASM_FLAGS+=-mcpu=mvp # make sure clang doesn't use post-MVP features like sign extension
WASM_FLAGS+=-fno-slp-vectorize -fno-vectorize -fno-unroll-loops
WASM_FLAGS+=-Wl,-z -Wl,stack-size=24576 -Wl,--initial-memory=65536
WASM_EXPORT_PREFIX=-Wl,--export
Expand Down

0 comments on commit 2660c95

Please sign in to comment.