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

M1 Mac build issue - could not compile wabt-sys #237

Closed
krpeacock opened this issue Apr 25, 2022 · 13 comments · Fixed by #419
Closed

M1 Mac build issue - could not compile wabt-sys #237

krpeacock opened this issue Apr 25, 2022 · 13 comments · Fixed by #419
Assignees
Milestone

Comments

@krpeacock
Copy link

Issue can be observed in any example project, or even a blank ts entrypoint. Spec is
OS: Monterey 12.3.1
Processor: M1 Pro
Node: 16.14.0
Rust: 1.60.0

Full output is:

   Compiling wabt v0.10.0
error: failed to add native library /var/folders/xt/9tbb8ws541979mzdx2n9ms2r0000gn/T/cargo-installtXfSMj/release/build/wabt-sys-e78371680e273395/out/build/libwabt.a: file too small to be an archive

error: could not compile `wabt-sys` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `ic-cdk-optimizer v0.3.4`, intermediate artifacts can be found at `/var/folders/xt/9tbb8ws541979mzdx2n9ms2r0000gn/T/cargo-installtXfSMj`
Caused by:
  build failed
Error: Command failed: cd target/azle && cargo install ic-cdk-optimizer --root ..
    at checkExecSyncError (node:child_process:828:11)
    at execSync (node:child_process:902:15)
    at installRustDependencies (/Users/kyle/code/azle-rss/backend/node_modules/azle/src/azle.ts:60:13)
    at azle (/Users/kyle/code/azle-rss/backend/node_modules/azle/src/azle.ts:26:5)
    at Object.<anonymous> (/Users/kyle/code/azle-rss/backend/node_modules/azle/src/azle.ts:15:1)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Module.m._compile (/Users/kyle/code/azle-rss/backend/node_modules/ts-node/src/index.ts:1365:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/kyle/code/azle-rss/backend/node_modules/ts-node/src/index.ts:1368:12)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  status: 101,
  signal: null,
  output: [ null, null, null ],
  pid: 97782,
  stdout: null,
  stderr: null
}
Error: The build step failed for canister 'rrkah-fqaaa-aaaaa-aaaaq-cai' with an embedded error: The custom tool failed.
@lastmjs
Copy link
Member

lastmjs commented Apr 25, 2022

@lastmjs
Copy link
Member

lastmjs commented Apr 25, 2022

Related: dfinity/internet-identity#434

@lastmjs
Copy link
Member

lastmjs commented Apr 25, 2022

Are you able to compile and run ic-cdk-optimizer outside of Azle?

@lastmjs
Copy link
Member

lastmjs commented Apr 25, 2022

As a quick local fix you might try commenting this out: https://github.com/demergent-labs/azle/blob/main/src/azle.ts#L104 in node_modules/azle/src/azle.ts

@lastmjs
Copy link
Member

lastmjs commented Apr 25, 2022

Related: pepyakin/wabt-rs#78

@lastmjs
Copy link
Member

lastmjs commented Apr 28, 2022

Someone else ran into an issue on an M1 with swc, adding this for future reference. FYI I don't have easy access to an M1 nor do any members of my team, so I'm not sure what I can do but try to help someone with an M1 figure this out. I might have a friend who can help in the future but no guarantees.

@krpeacock
Copy link
Author

I'm sure there's some single command that magically fixes it somewhere. I'm not blocked because I have other machines though

@cryptoisgood
Copy link

@krpeacock I wrapped dfx and the azle dependencies in a docker container. It's not really ready to be used but it be cool if you tried it to see if it gets you past this issue.

https://www.npmjs.com/package/wdfx

@infu
Copy link

infu commented May 13, 2022

2min fix for M1

  1. Install ic-cdk-optimizer standalone.
 cargo install ic-cdk-optimizer
  1. Remove dependency install from
    execSync(
    // execSync(
    //     `cd target/azle && cargo install ic-cdk-optimizer --root ..`,
    //     { stdio: 'inherit' }
    // );
  1. Change path to ic-cdk-optimiser
    `./target/bin/ic-cdk-optimizer ./target/wasm32-unknown-unknown/release/${canisterName}.wasm -o ./target/wasm32-unknown-unknown/release/${canisterName}.wasm`,
execSync(
        `~/.cargo/bin/ic-cdk-optimizer ./target/wasm32-unknown-unknown/release/${canisterName}.wasm -o ./target/wasm32-unknown-unknown/release/${canisterName}.wasm`,
        { stdio: 'inherit' }
    );

@lastmjs
Copy link
Member

lastmjs commented May 13, 2022

Thanks for this, we can probably get this fix into Azle soon. @krpeacock I would love to know if this works for you if you ever get a chance.

@lastmjs
Copy link
Member

lastmjs commented Jun 17, 2022

Could someone with an M1 could test building and deploying with npm install [email protected]? If that works then the issue should be resolved and we can get this into a major release.

@lastmjs
Copy link
Member

lastmjs commented Jun 18, 2022

I've had one person successfully use Azle on an M1 with this fix, so I'm considering it fixed for now

@lastmjs
Copy link
Member

lastmjs commented Oct 11, 2022

I'm hoping this will for sure be resolved once we switch Azle to ic-wasm, like we are planning to do in Kybra: demergent-labs/kybra#42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants