Open shanemadden opened 1 year ago
The workaround that we've identified to this issue using the resources in the linked issue requires nightly rust. To work around:
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"]
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"]
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.
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 https://github.com/rust-lang/rust/issues/109807