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

Official servers will not load wasm binaries compiled using Rust >=1.70 #391

Open
shanemadden opened this issue Apr 15, 2023 · 2 comments
Open
Labels
C-upstream Issue blocked by an upstream problem/feature.

Comments

@shanemadden
Copy link
Collaborator

Current nightly builds of rust use new wasm opcodes for sign-extension which will not load under the LLVM running on the official servers. Private servers tested appear to have no problem with the new opcodes.

Errors like Compiling wasm function #1389:<screeps::constants::small_enums::Direction as ... failed: Invalid opcode (enable with --experimental-wasm-se) @+1009670 will occur on attempt to load the module.

Ideally we'll be able to have a setting to control disabling these newer opcodes (possibly integrated into cargo-screeps) but a working workaround has not yet been identified - see rust-lang/rust#109807

@shanemadden
Copy link
Collaborator Author

shanemadden commented May 30, 2023

The workaround that we've identified to this issue using the resources in the linked issue requires nightly rust. To work around:

  1. Add build flags with set the target cpu to mvp, and rebuild std, which is usually used from the distribution pre-compiled. Example from my screeps.toml:

     [ptr.build]
      extra_options = ["--features=mmo", "--config", "build.rustflags=['-Ctarget-cpu=mvp']", "-Z", "build-std=std,panic_abort"]
    
  2. Additionally (and technically a separate issue), add the --disable-sign-ext to the options passed to wasm-opt, as current versions will add the new opcodes even when rustc does not. Example from my Cargo.toml:

    [package.metadata.wasm-pack.profile.release]
    wasm-opt = ["-O4", "--disable-sign-ext"]
    

@shanemadden
Copy link
Collaborator Author

An alternative workaround identified in the linked rust issue, that doesn't require build-std (but does require wasm-opt), is to add --signext-lowering to your wasm-opt options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-upstream Issue blocked by an upstream problem/feature.
Projects
None yet
Development

No branches or pull requests

1 participant