IntersectMBO / plutus-apps

The Plutus application platform
Apache License 2.0
305 stars 213 forks source link

Nix does not build on Apple Silicon #632

Closed erichulburd closed 1 year ago

erichulburd commented 2 years ago

Summary

After finishing the Plutus Pioneer Program using a Google Cloud compute instance, I was holding off on Plutus development and waiting for my new MBP M1 to come, so I could make use of the VSCode Haskell plugin. The day finally arrived and I was super stoked to get Plutus up and running. Unfortunately, Nix failed to build.

Steps to reproduce the behavior

  1. Setup IOHK caches:
% cat /etc/nix/nix.conf      
substituters        = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
  1. Install Nix
% sh <(curl -L https://nixos.org/nix/install) --daemon
  1. Clone this repo and nix-build
% git clone https://github.com/input-output-hk/plutus-apps
% cd plutus-apps
plutus-apps % nix-build -A plutus-playground.server

Actual Result

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
`cc' failed in phase `C Compiler'. (Exit code: 1)
error: builder for '/nix/store/3w27fs094aacf570g1jx2q0fgawkn5bz-scrypt-lib-scrypt-0.5.0.drv' failed with exit code 1;
       last 10 log lines:
       > /nix/store/qc4fzcja2bs760vsqcsc6v28imjwy0wi-clang-wrapper-11.1.0/resource-root/include/mmintrin.h:525:12: error:
       >      error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
       >         return (__m64)__builtin_ia32_psubw((__v4hi)__m1, (__v4hi)__m2);
       >                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       >     |
       > 525 |     return (__m64)__builtin_ia32_psubw((__v4hi)__m1, (__v4hi)__m2);
       >     |            ^
       > fatal error: too many errors emitted, stopping now [-ferror-limit=]
       > 20 errors generated.
       > `cc' failed in phase `C Compiler'. (Exit code: 1)
       For full logs, run 'nix log /nix/store/3w27fs094aacf570g1jx2q0fgawkn5bz-scrypt-lib-scrypt-0.5.0.drv'.
error: 1 dependencies of derivation '/nix/store/phv89ijk0lindnpjvh10bn5hv3inw8lq-cardano-wallet-core-lib-cardano-wallet-core-2022.1.18-config.drv' failed to build
error: 1 dependencies of derivation '/nix/store/c2wbx39k5804ifjg3sdjnfjf7q9ky0v2-cardano-wallet-core-lib-cardano-wallet-core-2022.1.18.drv' failed to build
building '/nix/store/s7790i5399d0knlsinpb1r9jcl55kyvj-attoparsec-lib-attoparsec-0.13.2.5-config.drv'...
error: 1 dependencies of derivation '/nix/store/in76rncrqv7z1ah82w60sy0gg8861m29-plutus-contract-lib-plutus-contract-0.1.0.0-config.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f5g6ngllgspr7hxvjns0py3q6vn8xdkz-plutus-contract-lib-plutus-contract-0.1.0.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/af1531h59nhk24p83p00qww7jajayw4f-plutus-playground-server-exe-plutus-playground-server-0.1.0.0.drv' failed to build

Expected Result

No error observed and nix is able to build.

Describe the approach you would take to fix this

I am not familiar enough with this repository or Nix to give an idea, but I would ask the following questions:

  1. Is it possible to test this in CI/CD at all?
  2. Is there a stable commit to reference in the README to suggest to users to build from?

System info

MacOS 12.3, 16 inch 2021 Apple M1 Max Memory 32 GB

% clang --version
Apple clang version 13.0.0 (clang-1300.0.27.3)
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Also, FYI, I do have ghcup globally installed as well outside of Nix:

% curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
# ...
% ghcup --version
The GHCup Haskell installer, version v0.1.17.8
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7
erichulburd commented 2 years ago

I did not see this: . I will revert Nix and re-attempt using those instructions. If that works, I'll add a link to the readme: https://github.com/renzwo/cardano-plutus-apps-install-m1/blob/main/README.md

ghost commented 1 year ago

I think the current https://github.com/input-output-hk/plutus-apps/blob/main/CONTRIBUTING.adoc#installing-and-setting-up-nix covers this.