Skip to content
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

--enable-simd feature is present in wasm32-unknown-unknown target, not enabled by target-feature=+simd128 #133290

Open
dj8yfo opened this issue Nov 21, 2024 · 2 comments
Labels
A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. C-discussion Category: Discussion or questions that doesn't represent real issues. O-wasm Target: WASM (WebAssembly), http://webassembly.org/

Comments

@dj8yfo
Copy link

dj8yfo commented Nov 21, 2024

I tried this code:

https://github.com/dj8yfo/abstract-dao/tree/056f74e16fbaba84b75c49522c1176c477a975d1

git clone https://github.com/dj8yfo/abstract-dao.git
cd abstract-dao/
git checkout origin/1.82_plus_simd128_bug
cargo build --target wasm32-unknown-unknown --release

I expected to see this happen:

: wasm-opt --print-features target/wasm32-unknown-unknown/release/near_abstract_dao.wasm
--enable-mutable-globals
--enable-sign-ext
--enable-reference-types
--enable-multivalue

In fact, this behaves as expected on previous version of Cargo.lock in https://github.com/dj8yfo/abstract-dao/tree/fe9d16797bf582f0ea24380c1e4ad6bdb8c97283 ,
before running cargo update

Instead, this happened:
Additional --enable-simd feature is present in output wasm,
which wasn't enabled with RUSTFLAGS = "-C target-feature=+simd128"

: wasm-opt --print-features target/wasm32-unknown-unknown/release/near_abstract_dao.wasm
--enable-mutable-globals
--enable-simd
--enable-sign-ext
--enable-reference-types
--enable-multivalue

Meta

Present on rustc 1.84.0-nightly (3fee0f12e 2024-11-20)
and rustc 1.83.0-beta.6 (4ff8ff0ec 2024-11-16)
and on rustc 1.81.0 (eeb90cda1 2024-09-04) if moving backwards

rustc --version --verbose:

❯ : rustc -vV
rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1

this is also reproduced on aarch64-apple-darwin , more discussion/context is present in nearuaguild/abstract-dao#9

Backtrace

<backtrace>

@dj8yfo dj8yfo added the C-bug Category: This is a bug. label Nov 21, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 21, 2024
@jieyouxu jieyouxu added O-wasm Target: WASM (WebAssembly), http://webassembly.org/ A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. labels Nov 21, 2024
@dj8yfo
Copy link
Author

dj8yfo commented Nov 21, 2024

on this version https://github.com/dj8yfo/abstract-dao/tree/056f74e16fbaba84b75c49522c1176c477a975d1
both 1.81 and 1.82 emit:

 : wasm2wat target/wasm32-unknown-unknown/release/near_abstract_dao.wasm o+e>| grep v128.store
        v128.store align=4
        v128.store align=4
        v128.store align=4
    v128.store align=8
    v128.store offset=16 align=8
    v128.store align=1
    v128.store align=1
        v128.store align=4

and on https://github.com/dj8yfo/abstract-dao/tree/fe9d16797bf582f0ea24380c1e4ad6bdb8c97283
v128.store aren't present

@jieyouxu jieyouxu added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Nov 21, 2024
@hanna-kruppe
Copy link
Contributor

It’s very likely that this is caused by one of the new/updated libraries in your lockfile, not a bug in the Rust compiler. Like instruction set extensions for physical CPU instruction sets, wasm target_features can be enabled for individual functions even if they’re not globally enabled. This is almost never correct for wasm because wasm engines validate the entire module up-front so you can’t do dynamic feature detection (the main use case for per-function target features) but library authors aren’t always aware of this. The lockfile diff is too large to pin down the culprit but you could look at the names of the functions that contain SIMD instructions, and/or update dependencies one-by-one with cargo update foo to narrow it down.

@jieyouxu jieyouxu added C-discussion Category: Discussion or questions that doesn't represent real issues. and removed C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. C-discussion Category: Discussion or questions that doesn't represent real issues. O-wasm Target: WASM (WebAssembly), http://webassembly.org/
Projects
None yet
Development

No branches or pull requests

4 participants