streamly icon indicating copy to clipboard operation
streamly copied to clipboard

streamly 0.10.1 does not build on MacOS

Open semanticphilosopher opened this issue 1 year ago • 13 comments
trafficstars

Building from hackage with ghc 9.6.4 results in:

[65 of 72] Compiling Streamly.Internal.FileSystem.Event ( src/Streamly/Internal/FileSystem/Event.hs, dist/build/Streamly/Internal/FileSystem/Event.o, dist/build/Streamly/Internal/FileSystem/Event.dyn_o )

src/Streamly/Internal/FileSystem/Event.hs:54:51: error:
    Module
    ‘Streamly.Internal.FileSystem.Event.Darwin’
    does not export
    ‘Event’
   |
54 | import Streamly.Internal.FileSystem.Event.Darwin (Event)
   |                                                   ^^^^^

semanticphilosopher avatar May 24 '24 12:05 semanticphilosopher

Which version of macOS is it? Are there any other warnings or errors seen before this error? We have CI's on macOS which pass before we release.

harendra-kumar avatar May 24 '24 12:05 harendra-kumar

It is MacOS Sonoma 14.5; Looking back (sorry I should have scrolled back) There was an autoconf failure which as deemed ignorable - namely:

Configuring streamly-0.10.1...
checking for gcc... /nix/store/s7lwib0lr80bqq0k43vd1ihr63yc6yql-clang-wrapper-16.0.6/bin/cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /nix/store/s7lwib0lr80bqq0k43vd1ihr63yc6yql-clang-wrapper-16.0.6/bin/cc accepts -g... yes
checking for /nix/store/s7lwib0lr80bqq0k43vd1ihr63yc6yql-clang-wrapper-16.0.6/bin/cc option to enable C11 features... none needed
checking for /nix/store/s7lwib0lr80bqq0k43vd1ihr63yc6yql-clang-wrapper-16.0.6/bin/cc options needed to detect all undeclared functions... none needed
checking whether IN_MASK_CREATE is declared... no
checking whether IN_EXCL_UNLINK is declared... no
checking whether kFSEventStreamCreateFlagFileEvents is declared... no
checking whether kFSEventStreamCreateFlagFullHistory is declared... no
checking whether kFSEventStreamEventFlagItemCloned is declared... no
checking whether kFSEventStreamEventFlagItemIsHardlink is declared... no
configure: creating ./config.status
config.status: creating src/config.h
Preprocessing library for streamly-0.10.1..
Building library for streamly-0.10.1..

src/Streamly/Internal/FileSystem/Event/Darwin.hs:1079:2: error:
     warning: "Autoconf did not find the definition kFSEventStreamCreateFlagFileEvents in Darwin header files.Do you have Cocoa framework header files installed?Not compiling the Streamly.Internal.FileSystem.Event.Darwin module. Programs depending on this module may not compile. Check if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS is defined in config.h generated from src/config.h.in" [-W#warnings]
     |
1079 | #warning "Autoconf did not find the definition \
     |  ^
#warning "Autoconf did not find the definition \
 ^
1 warning generated.

<no location info>: warning: [GHC-42258] [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - directory-1.3.8.1 (exposed by flag -package-id directory-1.3.8.1)

semanticphilosopher avatar May 24 '24 12:05 semanticphilosopher

Just now, built streamly-0.10.1 successfully on macOS sonoma 14.3.1:

Configuring streamly-0.10.1...
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to enable C11 features... none needed
checking for /usr/bin/gcc options needed to detect all undeclared functions... none needed
checking whether IN_MASK_CREATE is declared... no
checking whether IN_EXCL_UNLINK is declared... no
checking whether kFSEventStreamCreateFlagFileEvents is declared... yes
checking whether kFSEventStreamCreateFlagFullHistory is declared... yes
checking whether kFSEventStreamEventFlagItemCloned is declared... yes
checking whether kFSEventStreamEventFlagItemIsHardlink is declared... yes
configure: creating ./config.status

Maybe some issue with your xcode cli tools or xcode configuration. So it is not able to find the header files.

harendra-kumar avatar May 24 '24 15:05 harendra-kumar

I checked, and force updated, xcode - still the same issue - looking like something related to 14.5

semanticphilosopher avatar May 27 '24 06:05 semanticphilosopher

Completed the build successfully on 14.5. Here are the versions of the relevant tools in my config:

cutlass:~/streamly-0.10.1$ sw_vers -productVersion
14.5
cutlass:~/streamly-0.10.1$ cabal --version
cabal-install version 3.10.3.0
compiled using version 3.10.3.0 of the Cabal library 
cutlass:~/streamly-0.10.1$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.6.5
cutlass:~/streamly-0.10.1$ xcode-select --version
xcode-select version 2408.
cutlass:~/streamly-0.10.1$ xcode-select -p       
/Applications/Xcode.app/Contents/Developer

harendra-kumar avatar May 27 '24 09:05 harendra-kumar

I have tested it on intel silicon. Are you building on apple silicon? Not sure if that makes a difference.

harendra-kumar avatar May 27 '24 11:05 harendra-kumar

Hi, thanks for your focus.

My versions are:

neil@fuji> sw_vers -productVersion ~ 14.5 neil@fuji> cabal --version ~ cabal-install version 3.10.2.1 compiled using version 3.10.1.0 of the Cabal library neil@fuji> ghc --version ~ The Glorious Glasgow Haskell Compilation System, version 9.6.4 neil@fuji> xcode-select --version ~ xcode-select version 2408. neil@fuji> xcode-select -p ~ /Applications/Xcode.app/Contents/Developer

I am on apple silicon

semanticphilosopher avatar May 27 '24 11:05 semanticphilosopher

Built successfully on macOS 14.5 using Apple M1 Pro hardware as well. Are you using nix to build it?

harendra-kumar avatar May 28 '24 04:05 harendra-kumar

The mac has nix on it - but I was using cabal directly. The tools are the ones installed by nix

semanticphilosopher avatar May 28 '24 11:05 semanticphilosopher

Remove nix tools from your PATH environment variable, and try building it with ghcup installed ghc.

harendra-kumar avatar Jun 03 '24 06:06 harendra-kumar

What is the cause of the failure on nix? Also experiencing missing Event symbol.

locallycompact avatar Jun 30 '24 11:06 locallycompact

If you are using some tools/libraries from nix and some from native OS then you may face some unpredictable issues. I suggested to remove nix tools from the PATH above to try and build it using native OS tools only to identify if there is such an issue. Otherwise, we always build using nix and it works fine.

harendra-kumar avatar Jun 30 '24 12:06 harendra-kumar

Oh, no. This is a nix derivation. Generated with cabal2nix and using the latest version of nixpkgs/haskell-updates.

https://gitlab.horizon-haskell.net/package-sets/horizon-platform/-/jobs/1463303

locallycompact avatar Jun 30 '24 12:06 locallycompact

Are you able to build https://hackage.haskell.org/package/hfsevents in the same environment?

harendra-kumar avatar Jul 02 '24 07:07 harendra-kumar

@semanticphilosopher @locallycompact are you missing the Cocoa framework dependency in the nix derivation?

We have a nix derivation section at the end of this guide here https://streamly.composewell.com/streamly-0.10.1/User/HowTo/Compiling.html . I am reproducing it here:

  streamly =
    nixpkgs.haskell.lib.overrideCabal
        (
          super.callHackageDirect
            { pkg = "streamly";
              ver = "0.9.0";
              sha256 = "sha256-eOxVb8qQjZDo1+S7CStqYSExOg2QHWkMY+zlOYqwZak=";
            } {}
        )
        (old:
          { librarySystemDepends =
              if nixpkgs.lib.strings.hasInfix "darwin" builtins.currentSystem
              then [nixpkgs.darwin.apple_sdk.frameworks.Cocoa]
              else [];
          });

harendra-kumar avatar Jul 11 '24 21:07 harendra-kumar