3

I am on macos (M1 macbook air)

I installed Haskell toolchain via ghcup and I currently have ghc set to 9.6.1

I ran cabal build for the project but it failed installing one of the dependencies:

Building library for hashable-1.4.2.0..
[1 of 7] Compiling Data.Hashable.Imports ( src/Data/Hashable/Imports.hs, dist/build/Data/Hashable/Imports.o, dist/build/Data/Hashable/Imports.dyn_o )
[2 of 7] Compiling Data.Hashable.LowLevel ( src/Data/Hashable/LowLevel.hs, dist/build/Data/Hashable/LowLevel.o, dist/build/Data/Hashable/LowLevel.dyn_o )

/var/folders/w1/_vgkxyln4c7bk8kr29s1y1k00000gn/T/ghc83995_0/ghc_10.c:4:10: error:
     fatal error: 'ffi.h' file not found
  |
4 | #include <ffi.h>
  |          ^
#include <ffi.h>
         ^~~~~~~
1 error generated.

<no location info>: error:
    `gcc' failed in phase `C Compiler'. (Exit code: 1)
Error: cabal: Failed to build hashable-1.4.2.0 (which is required by
Anentropic
  • 32,188
  • 12
  • 99
  • 147
  • I think you need to install `libffi-dev` on your machine. Maybe https://stackoverflow.com/questions/44706311/how-to-install-libffi-dev-on-mac-os-x will help? – Code-Apprentice Mar 25 '23 at 22:01
  • @Code-Apprentice thanks... I tried `brew install libffi` (along with `export LDFLAGS`, `CPPFLAGS` and `PKG_CONFIG_PATH` ) but it did not fix it – Anentropic Mar 25 '23 at 22:24

1 Answers1

3

Diagnosed and fixed with help from the ghcup devs here:
https://github.com/haskell/ghcup-hs/issues/814

The problem was that I had not re-installed XCode command line tools after a recent macOS or XCode software update.

This was fixed by installing the command line tools:

xcode-select --install

This ensured that the expected symlink was in place at /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

cabal build was then able to succeed

Anentropic
  • 32,188
  • 12
  • 99
  • 147