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

Don't enable SSE for wasm compilation #7650

Closed
akhi3030 opened this issue Sep 20, 2022 · 4 comments · Fixed by #8305
Closed

Don't enable SSE for wasm compilation #7650

akhi3030 opened this issue Sep 20, 2022 · 4 comments · Fixed by #8305
Assignees
Labels
T-contract-runtime Team: issues relevant to the contract runtime team

Comments

@akhi3030
Copy link
Collaborator

In #7130 we had disabled setting SSE for WASM compilation which helped in removing a bunch of warnings for WASM compilation.

We discovered that this PR causes some performance regressions (in effect it actually disabled SSE for x86 compilation as well) and did some investigation in rust-lang/cargo#11114. For now we have reverted the above PR. This issue is to track the work to disable setting SSE for WASM in a way that does not cause a performance regression.

CC: @matklad, @mm-near

@matklad matklad added the T-contract-runtime Team: issues relevant to the contract runtime team label Sep 21, 2022
@matklad
Copy link
Contributor

matklad commented Oct 25, 2022

Status: this is fixed in Cargo, so we probably should just wait 10-ish weeks for fix to land the stable and then revert the revert.

If someone feels strongly about this, we can try to apply some work-around faster.

@akhi3030
Copy link
Collaborator Author

I don't think this is pressing. We can wait for a clean fix.

@akhi3030
Copy link
Collaborator Author

akhi3030 commented Dec 5, 2022

Looks like rust-lang/cargo#11114 was now merged and the fix is planned to be released as part of 1.66 cargo release.

@pugachAG
Copy link
Contributor

pugachAG commented Jan 3, 2023

$ rustup update
...
   stable-aarch64-apple-darwin updated - rustc 1.66.0 (69f9c33d7 2022-12-12) (from rustc 1.65.0 (897e37553 2022-11-02))

it seems like 1.66 was released and we can proceed with this

near-bulldozer bot pushed a commit that referenced this issue Jan 6, 2023
https://blog.rust-lang.org/2022/12/15/Rust-1.66.0.html

Updated the same files as in the previous version bump: #7993

This enables #7650 (see [this comment](#7650 (comment))).

Also includes fixes for the following warning:
```
warning: for loop over an `Option`. This is more readably written as an `if let` statement
     ...
     = note: `#[warn(for_loops_over_fallibles)]` on by default
```
@pugachAG pugachAG self-assigned this Jan 6, 2023
near-bulldozer bot pushed a commit that referenced this issue Jan 9, 2023
)

With #8284 we upgraded cargo version to `1.66`, so rust-lang/cargo#11114 is available. This PR is the same as #7130, but we can safely merge it now.

See #7650 for more context.

In order to test it I've used the code from [`librocksdb-sys/build.rs`](https://github.com/rust-rocksdb/rust-rocksdb/blob/master/librocksdb-sys/build.rs#L111) as part of `neard/build.rs`:
```
 fn main() {
-    if let Err(err) = try_main() {
-        eprintln!("{}", err);
-        std::process::exit(1);
+    let target_feature = std::env::var("CARGO_CFG_TARGET_FEATURE").unwrap();
+    let target_features: Vec<_> = target_feature.split(',').collect();
+    if target_features.contains(&"neon") {
+        panic!("FAIL: {target_feature}");
+    } else {
+        panic!("OK: {target_feature}");
     }
 }
```

It was was tested on M1 macbook, so I've changed the feature to `neon` (which is enabled by default), my `.cargo/config.toml` is as follows:
```
-[target.'cfg(target_arch = "x86_64")']
-rustflags = ["-Ctarget-feature=+sse4.1,+sse4.2", "-Cforce-unwind-tables=y"]
+[target.'cfg(target_arch = "aarch64")']
+rustflags = ["-Ctarget-feature=-neon", "-Cforce-unwind-tables=y"]
```

`neon` was successfully removed when using `1.66` toolchain:
```
OK: crc,...,vh
```

while it was still present with `1.65`:
```
FAIL: aes,..,neon,...,vh
```

This proves that rustflags are passed as env variable to `build.rs` in `1.66`, which was not the case in `1.65`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-contract-runtime Team: issues relevant to the contract runtime team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants