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

fix: build on Apple M1 chip #434

Closed
wants to merge 1 commit into from

Conversation

plitzenberger
Copy link

@plitzenberger plitzenberger commented Oct 23, 2021

Description

when running II_ENV=development dfx deploy --no-wallet --argument '(null)' on apple M1 chip the build fails with:

Check #381

error: failed to add native library /var/folders/z8/06mhg00s4lzd_dzykt3q0s6m0000gn/T/cargo-installNkJZeH/release/build/wabt-sys-0c5d3f90b9057634/out/build/libwabt.a: file too small to be an archive

error: aborting due to previous error

error: could not compile wabt-sys

Motivation and Context

This PR is primarily intended as an opening to discussions on how to fix the above build issue in general. By applying this change, the build script installs ic-cdk-optimizer to your home dir ~/.cargo/bin/ic-cdk-optimizer instead of the local target folder. For whatever reason this works. I'm not a rust expert.

How Has This Been Tested?

It works on my machine :)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@nmattia
Copy link
Collaborator

nmattia commented Oct 25, 2021

Hi, thanks for the PR! I'll try to get my hands on an M1 and will try to figure out why it doesn't work out of the box (I've also caught up on #381). Do you reckon this actually solves the issue, or does it simply hide the error message?

@plitzenberger
Copy link
Author

@nmattia yes, it solves the issue. I've looked into the result of "$II_DIR"/../../target/. And this is actually just target in the root directory. So I came to the conclusion that the path construction is just useless.

What I cannot tell is why the ic-cdk-optimizer is installed within the internet-identity/target folder and if this breaks something when installed to your ~/.cargo/ dir.

@nmattia
Copy link
Collaborator

nmattia commented Nov 8, 2021

@dsarlis it looks like you set up ic-cdk-optimizer in a74ad75. Can you shed some light here?

@bitdivine
Copy link
Member

bitdivine commented Nov 10, 2021

The II_DIR refers to src/internet_identity, so in theory the path construction could make sense, however on line 6 of build.sh we have npm run build which assumes that the script is being run from the root of the git dir.

Options:

  • If we want to make the script strongly location independent we can start the script with cd "$(dirname "$(realpath "$0")")/../.." but note that the original realpath spec was broken, so most Linux distributions dropped it and used readlink -f ... instead. Recent Ubuntu has a semi-sane realpath installed by default (>20.04 if I recall correctly), but earlier versions of Ubuntu and many other distros will reject the code at this point. - RECOMMEND REJECT
  • We can assume that there are no soft links in place and do cd "$(dirname "$0")/../..". We don't have soft links so this should work out of the box for everyone who doesn't customize their setup. - RECOMMEND OK
  • Use git: cd "$(git rev-parse --show-toplevel)" - RECOMMEND REJECT - ADDS DEPENDENCY ON GIT SETUP
  • Or we can just assume that we are running from the git root.

Update: I was wrong, I think the code in theory makes sense, however I am still in favour of simply putting a cd to the git root at the top of the script and eliminating II_DIR from the rest of the code.

@Mert75
Copy link

Mert75 commented Nov 19, 2021

I'm also on the M1 chip and ran into the same problem.

Running cargo install ic-cdk-optimizer --version 0.3.1 followed by the solution in the PR solved it for me 👍

@krpeacock
Copy link
Contributor

@nmattia @bitdivine bumping this

@nmattia
Copy link
Collaborator

nmattia commented Jan 11, 2022

@krpeacock unfortunately @bitdivine and I are very snowed under at the moment; hopefully in two or three weeks we'll have a few spare cycles. In the meantime feel free to have a look! This is definitely on our radar.

@wewei
Copy link

wewei commented Feb 3, 2022

Hi, any updates on this one?
The forum link is https://forum.dfinity.org/t/setup-internet-identity-locally-failed-macbook-m1/7684

@letmejustputthishere
Copy link
Member

letmejustputthishere commented Feb 5, 2022

I can confirm this solves the problem on a M1, thanks @plitzenberger

you really have to run cargo install ic-cdk-optimizer --version 0.3.1 manually first though.

@nmattia
Copy link
Collaborator

nmattia commented Feb 7, 2022

Ok, so I've removed the cargo install bit entirely here: #531

As far as I understand this should fix the issue, right? Anybody needing to build the code will just need to run cargo install ic-cdk-optimizer once!

@nmattia
Copy link
Collaborator

nmattia commented Feb 14, 2022

Haven't heard anyone complain so I'll go ahead and close this, feel free to re-open though!

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 this pull request may close these issues.

None yet

7 participants