stefan-hoeck / idris2-pack

BSD 3-Clause "New" or "Revised" License
99 stars 26 forks source link

GMP not found on Mac M1 for `pack switch HEAD` #283

Closed joelberkeley closed 4 months ago

joelberkeley commented 6 months ago

I'm trying to upgrade my local pack on mac m1, and it can't find gmp when I pack switch HEAD (I'm currently on nightly-240211)

[ build ] cc -Wall  -fPIC -O2   -c -o buffer.o buffer.c
[ build ] cc -Wall  -fPIC -O2   -c -o casts.o casts.c
In file included from casts.c:1:
In file included from ./casts.h:3:
In file included from ./cBackend.h:8:
./_datatypes.h:3:10: fatal error: 'gmp.h' file not found
#include <gmp.h>
         ^~~~~~~
1 error generated.
make[2]: *** [casts.o] Error 1
make[1]: *** [build-refc] Error 2
make: *** [/Users/joel/.pack/.tmp2/idris2-compiler/support/c/libidris2_support.dylib] Error 2
[ fatal ] Error when executing system command.
          Command: "make" "support" "PREFIX=/Users/joel/.pack/install/c3239cb4c0a6a001a59660111b5e3000db710d2b/idris2" "SCHEME=chez"
          Error code: 2

I have GMP installed already from installing pack the first time

joel@192 ~ % brew install gmp  
Warning: gmp 6.3.0 is already installed and up-to-date.
To reinstall 6.3.0, run:
  brew reinstall gmp

@dunhamsteve says in discord

Quite a while ago, I put this in install.sh, which addresses that issue on M1 mac, but install.sh might not be used for updates. (I have the CPATH in my shell rc files, so I wouldn't notice.):

if [ -d "/opt/homebrew/include" ]; then
   export CPATH="/opt/homebrew/include"
fi

which is this commit fc8766b098e67058f87f057aa4793f39ff2b27bf

stefan-hoeck commented 6 months ago

Could someone please update me on the status of this issue. Is this even something we can handle with pack?

dunhamsteve commented 6 months ago

I've been setting CPATH="/opt/homebrew/include" to help Idris' Makefile find gmp.h installed by homebrew. This is done by the install.sh script in the snippet quoted above.

This could be handled by testing for /opt/homebrew/include and adding either CPATH=/opt/homebrew/include or CPPFLAGS=-I/opt/homebrew/include to the make invocations in pack. (I believe this could be either an environment setting or a command line arg.)

Or we could try changing config.mk in the Idris codebase to do this.

dunhamsteve commented 4 months ago

I believe idris-lang/Idris2#3269 resolves this, can you double check @joelberkeley?

joelberkeley commented 4 months ago

I can't, I no longer have a mac

dunhamsteve commented 4 months ago

Ok, I’ve reproduced this with nightly-240421 and verified that it no longer happens with nightly-240428.

joelberkeley commented 4 months ago

thanks steve, I'll close it then as done. Reopen if there's anything missing