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

no prebuilt wasm-opt binaries error #913

Closed
JHBonarius opened this issue Sep 7, 2020 · 25 comments · Fixed by #1088
Closed

no prebuilt wasm-opt binaries error #913

JHBonarius opened this issue Sep 7, 2020 · 25 comments · Fixed by #1088
Labels
bug Something isn't working wasm-opt

Comments

@JHBonarius
Copy link

🐛 Bug description

I'm running wasm-pack on a raspberry pie 3b (arm v71). and are trying the game of life tutorial. Build 'fails' with an error. (I say 'fails', as I get something that works after all.)

~/rust/wasm-game-of-life $ wasm-pack build [INFO]: Checking for the Wasm target... [INFO]: Compiling to Wasm... Finished release [optimized] target(s) in 0.50s [INFO]: Installing wasm-bindgen... Error: no prebuilt wasm-opt binaries are available for this platform: Unrecognized target! To disable wasm-opt, add wasm-opt = false to your package metadata in your 'Cargo.toml'.

🤔 Expected Behavior

Looking at wasm-opt.rs, I would have expected the build to successfully complete, giving the message "Skipping wasm-opt because it is not supported on this platform".
It also doesn't seem to look for a local wasm-opt in the path, as described above pub fn find_wasm_opt. I downloaded the wasm-opt source, build it locally and added the bin dir it to the path... source doesn't show any signs of looking at the path...

👟 Steps to reproduce

Get a raspberry pie, install raspbian OS, install git, rust, wasm, etc
git clone https://github.com/rustwasm/wasm_game_of_life.git
cd wasm_game_of_life/
wasm_pack build

🌍 Your environment

Include the relevant details of your environment.
wasm-pack version: 0.9.1
rustc version: 1.46.0

@PiepsC
Copy link

PiepsC commented Sep 9, 2020

I ran into a completely different issue with wasm-opt as well which was solved by downgrading to 0.8.1. I reckon that will not solve anything for you considering the lack of binaries.

Have you tried disabling wasm-opt altogether? To disable wasm-opt, add wasm-opt = false to your package metadata in your Cargo.toml. Obviously doesn't address the issue here, but perhaps it'll at least allow you to continue.

@SebastienGllmt
Copy link

I think this is a duplicate of #886

@JHBonarius
Copy link
Author

I think this is a duplicate of #886

No, because that bug occurs when wasm-opt is actually running. In my case, the wasm-opt binaries are not found at all.

@rambip
Copy link

rambip commented Nov 6, 2020

Same issue here with a raspberry-pi 4

everything compiles well but wasm-opt fails.

@Dygear
Copy link

Dygear commented Dec 17, 2020

Same problem on an ARM Mac.

@darkoverlordofdata
Copy link

Same problem occurs on 12.2-STABLE FreeBSD 12.2-STABLE GENERIC amd64

@mununki
Copy link

mununki commented Jan 31, 2021

exactly the same issue on m1 Mac. Any resolution?

@INCHMAN1900
Copy link

Running into the same problem: everything but wasm-opt works perfectly fine.

find_wasm_opt method only check cache folders(like /Users/user/Library/Caches on MacOS). If there is no .wasm-pack, it try to download from Github.

There are two solutions I think:

  1. disable wasm-opt and manually do the opt
  2. change the wasm_opt_path in wasm-opt.rs file to the executable path on my machine, then build my own wasm-pack

@adamaho
Copy link

adamaho commented Feb 16, 2021

I also can't wasm-pack the hello world application on an M1 MacBook Air. Hopefully a resolution comes soon :)

@INCHMAN1900
Copy link

I also can't wasm-pack the hello world application on an M1 MacBook Air. Hopefully a resolution comes soon :)

try add

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

to your Cargo.toml to disable wasm-opt step.

@JHBonarius
Copy link
Author

I also can't wasm-pack the hello world application on an M1 MacBook Air. Hopefully a resolution comes soon :)

try add

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

to your Cargo.toml to disable wasm-opt step.

That's what the first reply says. But it's not a fix, but a work-around.

@willmcpherson2
Copy link

For M1 users, you can manually run wasm-opt.

Disable automatic wasm-opt in your Cargo.toml:

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

Install standalone wasm-opt binary:

brew install binaryen

Run it on your built wasm file, for example:

wasm-opt -Oz -o out.wasm in.wasm

@titaneric
Copy link

I want to build a wasm in a container without any network access. @willmcpherson2 may be a work-around solution to this (pre-installed it), but hope wasm-pack can find wasm-opt locally without disabling wasm-opt in Cargo.toml.

@INCHMAN1900
Copy link

I want to build a wasm in a container without any network access. @willmcpherson2 may be a work-around solution to this (pre-installed it), but hope wasm-pack can find wasm-opt locally without disabling wasm-opt in Cargo.toml.

change the wasm_opt_path in wasm-opt.rs to the local executable path in your container(so wasm-pack won't need to download it from internet), then build your own wasm-pack.

@nessex
Copy link

nessex commented May 6, 2021

As an alternative to the above, if you would like the wasm-pack command to work normally you can install the wasm-pack from this PR which looks for binaries in your PATH. At least, until such a time as the PR is merged:

# By latest commit at time of this comment
cargo install wasm-pack --git https://github.com/bloveless/wasm-pack --rev fee0938c3417dbcd5d72544a8c1981d761590042

This allows me to just run wasm-pack build --target web without a separate wasm-opt stage.

Note that you'll also need to follow the instructions above to download or build a working wasm-opt binary and put it in your PATH.

@Kade-Powell
Copy link

yep, same issue here.. starting to regret this M1 Mac purchase

@kkharji
Copy link

kkharji commented Jun 29, 2021

As an alternative to the above, if you would like the wasm-pack command to work normally you can install the wasm-pack from this PR which looks for binaries in your PATH. At least, until such a time as the PR is merged:

# By latest commit at time of this comment
cargo install wasm-pack --git https://github.com/bloveless/wasm-pack --rev fee0938c3417dbcd5d72544a8c1981d761590042

This allows me to just run wasm-pack build --target web without a separate wasm-opt stage.

Note that you'll also need to follow the instructions above to download or build a working wasm-opt binary and put it in your PATH.

Which instruction? where can I download and build wasm-opt binary?

M1 mac

Thanks

@mtiller
Copy link

mtiller commented Aug 29, 2021

As far as I can tell, the original repo from @bloveless has been made private (or removed). I presume this is because the changes were merged into the wasm-pack code base. But it doesn't look like the merged version is released yet. So it is, at least as of today, unclear how we are supposed to solver this problem. Yes, I could disable wasm-opt, but I'd prefer to use it since I managed to download it with homebrew. Any suggestions? Anybody know the specific incantation required to install wasm-pack (with merged PR) directly from git? I'm new to cargo, so I'm not quite sure what I should do. Or perhaps the merged version has been released and I'm somehow missing something about how to use it?

Any assistance here is appreciated.

@mtiller
Copy link

mtiller commented Aug 29, 2021

Just a quick follow up. I tried something. I cannot say if it is "correct", but it did seem to work. Although I should make clear that this installs an unreleased version of wasm-pack. Here are the steps I followed to get this working on my M1 Mac:

  1. Install homebrew (most people probably already have this, but just in case).
  2. Run brew install binaryen (as suggested by @willmcpherson2)
  3. Install the unreleased version of wasm-pack using: cargo install wasm-pack --git https://github.com/rustwasm/wasm-pack --rev c9ea9aebbccf5029846a24a6a823b18bb41736c7
  4. Run your build as usual with: wasm-pack build --target web (should run without complaint)

If anybody has any reason to think one of these steps is incorrect, please speak up. I just thought an update was in order since some of the previous instructions seem to be out of date now. Hopefully the next release of wasm-pack will be released soon and people will no longer see this issue (at least on platforms where a binary of wasm-opt is available).

Hope that helps.

@dkozma
Copy link

dkozma commented Nov 16, 2021

Wanted to follow up to @mtiller's instructions with changes I had to make for my M1 Mac running macOS Monterey. After installing homebrew and running brew install binaryen, run the following (Git SHA updated with current HEAD):

export MACOSX_DEPLOYMENT_TARGET=10.7
cargo install wasm-pack --git https://github.com/rustwasm/wasm-pack --rev ae10c23cc14b79ed37a7be222daf5fd851b9cd0d

This sets the deployment target as specified in this issue to resolve the linker issues in Monterey.

@reinmind
Copy link

I think the bug is caused by the binaryen version_90 doesn't have a macos_aarch prebuild release
https://github.com/WebAssembly/binaryen/releases/tag/version_90
I found the predownload link in the file mod.rs

Tool::WasmOpt => {
            Ok(format!(
        "https://github.com/WebAssembly/binaryen/releases/download/{vers}/binaryen-{vers}-{target}.tar.gz",
        vers = "version_90",
        target = target,
            ))
        }

and 'os-configuration' in target.rs

#![allow(missing_docs)]

pub const LINUX: bool = cfg!(target_os = "linux");
pub const MACOS: bool = cfg!(target_os = "macos");
pub const WINDOWS: bool = cfg!(target_os = "windows");

#[allow(non_upper_case_globals)]
pub const x86_64: bool = cfg!(target_arch = "x86_64");
#[allow(non_upper_case_globals)]
pub const x86: bool = cfg!(target_arch = "x86");

It should be solved by a new binaryen osx_aarch64 release

@d3lm
Copy link
Contributor

d3lm commented Dec 3, 2021

I just submitted a PR (#1088) to fix this issue for Apple Sillicon.

@babldev
Copy link

babldev commented Dec 13, 2021

You can test @d3lm's change with:

cargo install wasm-pack --git https://github.com/d3lm/wasm-pack --rev 713868b204f151acd1989c3f29ff9d3bc944c306

It did the trick for me!

@Nasafato Nasafato mentioned this issue Jan 9, 2022
3 tasks
nadimkobeissi added a commit to nymtech/nym that referenced this issue May 5, 2023
wasm-opt has a known issue on Apple Silicon:
rustwasm/wasm-pack#913

The workaround currently seems to be running wasm-opt locally instead of
defining it as part of the Rust package's build pipeline in Cargo.toml.

I hope this is okay!
@prichardsondev
Copy link

Same issue RPI 4 - Bookworm v12 64 Bit

Error: no prebuilt wasm-opt binaries are available for this platform: Unrecognized target!
To disable wasm-opt, add wasm-opt = false to your package metadata in your Cargo.toml.
Caused by: no prebuilt wasm-opt binaries are available for this platform: Unrecognized target!
To disable wasm-opt, add wasm-opt = false to your package metadata in your Cargo.toml.

@WilfredAlmeida
Copy link

Same issue on M3 Mac while running docker compose up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wasm-opt
Projects
None yet
Development

Successfully merging a pull request may close this issue.