Home > Net >  errors in running the clash interpreter
errors in running the clash interpreter

Time:10-26

Running on an M1 mac, I installed stack via a nix-shell defined with:

{ pkgs ? import <nixpkgs> { system = "x86_64-darwin"; } }:

pkgs.mkShell {
  buildInputs = [
    pkgs.stack

    # required for clashi
    pkgs.libiconv
    pkgs.libffi
  ];
}

I then run the clash interpreter with stack exec --package clash-ghc -- clashi, which yields the output:

ghc-tcplugins-extra      > configure
ghc-tcplugins-extra      > Configuring ghc-tcplugins-extra-0.4.3...
ghc-tcplugins-extra      > build
hint                     > configure
ghc-tcplugins-extra      > Preprocessing library for ghc-tcplugins-extra-0.4.3..
ghc-tcplugins-extra      > Building library for ghc-tcplugins-extra-0.4.3..
ghc-tcplugins-extra      > [1 of 8] Compiling GhcApi.Constraint
ghc-tcplugins-extra      > [2 of 8] Compiling GhcApi.GhcPlugins
hint                     > Configuring hint-0.9.0.6...
ghc-tcplugins-extra      > [3 of 8] Compiling GhcApi.Predicate
ghc-tcplugins-extra      > [4 of 8] Compiling Internal.Constraint
hint                     > build
hint                     > Preprocessing library for hint-0.9.0.6..
hint                     > Building library for hint-0.9.0.6..
ghc-tcplugins-extra      > [5 of 8] Compiling Internal.Evidence
ghc-tcplugins-extra      > [6 of 8] Compiling Internal.Type
ghc-tcplugins-extra      > [7 of 8] Compiling Internal
hint                     > [ 1 of 19] Compiling Control.Monad.Ghc
hint                     >
hint                     > /private/tmp/stack-190bd81cb4ea998b/hint-0.9.0.6/src/Control/Monad/Ghc.hs:22:1: warning: [-Wunused-imports]
hint                     >     The qualified import of ‘GHC.Utils.Exception’ is redundant
hint                     >       except perhaps to import instances from ‘GHC.Utils.Exception’
hint                     >     To import instances alone, use: import GHC.Utils.Exception()
hint                     >    |
hint                     > 22 | import qualified GHC.Utils.Exception as GHC
hint                     >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hint                     > [ 2 of 19] Compiling Hint.CompatPlatform
ghc-tcplugins-extra      > [8 of 8] Compiling GHC.TcPluginM.Extra
hint                     > [ 3 of 19] Compiling Hint.GHC
ghc-tcplugins-extra      > ld: library not found for -lncurses
ghc-tcplugins-extra      > clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
ghc-tcplugins-extra      > `clang' failed in phase `Linker'. (Exit code: 1)
hint                     > [ 4 of 19] Compiling Hint.Extension
hint                     > [ 5 of 19] Compiling Hint.Base
hint                     > [ 6 of 19] Compiling Hint.Conversions
hint                     > [ 7 of 19] Compiling Hint.Annotations
hint                     > [ 8 of 19] Compiling Hint.Parsers
hint                     > [ 9 of 19] Compiling Hint.Reflection
hint                     > [10 of 19] Compiling Hint.Typecheck
hint                     > [11 of 19] Compiling Hint.Internal
hint                     > [12 of 19] Compiling Hint.Util
hint                     > [13 of 19] Compiling Hint.Configuration
hint                     >
hint                     > /private/tmp/stack-190bd81cb4ea998b/hint-0.9.0.6/src/Hint/Configuration.hs:20:1: warning: [-Wunused-imports]
hint                     >     The import of ‘Data.Maybe’ is redundant
hint                     >       except perhaps to import instances from ‘Data.Maybe’
hint                     >     To import instances alone, use: import Data.Maybe()
hint                     >    |
hint                     > 20 | import Data.Maybe (maybe)
hint                     >    | ^^^^^^^^^^^^^^^^^^^^^^^^^
hint                     > [14 of 19] Compiling Hint.Context
hint                     >
hint                     > /private/tmp/stack-190bd81cb4ea998b/hint-0.9.0.6/src/Hint/Context.hs:35:1: warning: [-Wunused-imports]
hint                     >     The import of ‘Data.Maybe’ is redundant
hint                     >       except perhaps to import instances from ‘Data.Maybe’
hint                     >     To import instances alone, use: import Data.Maybe()
hint                     >    |
hint                     > 35 | import Data.Maybe (maybe)
hint                     >    | ^^^^^^^^^^^^^^^^^^^^^^^^^
hint                     > [15 of 19] Compiling Hint.InterpreterT
hint                     >
hint                     > /private/tmp/stack-190bd81cb4ea998b/hint-0.9.0.6/src/Hint/InterpreterT.hs:22:1: warning: [-Wunused-imports]
hint                     >     The import of ‘Control.Concurrent.MVar’ is redundant
hint                     >       except perhaps to import instances from ‘Control.Concurrent.MVar’
hint                     >     To import instances alone, use: import Control.Concurrent.MVar()
hint                     >    |
hint                     > 22 | import Control.Concurrent.MVar
hint                     >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hint                     >
hint                     > /private/tmp/stack-190bd81cb4ea998b/hint-0.9.0.6/src/Hint/InterpreterT.hs:23:1: warning: [-Wunused-imports]
hint                     >     The import of ‘System.IO.Unsafe’ is redundant
hint                     >       except perhaps to import instances from ‘System.IO.Unsafe’
hint                     >     To import instances alone, use: import System.IO.Unsafe()
hint                     >    |
hint                     > 23 | import System.IO.Unsafe (unsafePerformIO)
hint                     >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hint                     > [16 of 19] Compiling Hint.Eval
hint                     > [17 of 19] Compiling Language.Haskell.Interpreter
hint                     > [18 of 19] Compiling Language.Haskell.Interpreter.Extension
hint                     > [19 of 19] Compiling Language.Haskell.Interpreter.Unsafe
hint                     > ld: library not found for -lncurses
hint                     > clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
hint                     > `clang' failed in phase `Linker'. (Exit code: 1)
Progress 2/8

--  While building package hint-0.9.0.6 (scroll up to its section to see the error) using:
      /Users/beckerawqatty/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-3.4.1.0 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1


--  While building package ghc-tcplugins-extra-0.4.3 (scroll up to its section to see the error) using:
      /Users/beckerawqatty/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-3.4.1.0 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

Not sure why running the above command generates these errors. Any help appreciated, thanks!

CodePudding user response:

I was missing an import for the ncurses library, as described from the below snippet from my console output:

hint                     > ld: library not found for -lncurses

so I just had to add pkgs.ncurses to my shell.nix file, like so:

{ pkgs ? import <nixpkgs> { system = "x86_64-darwin"; } }:

pkgs.mkShell {
  buildInputs = [
    pkgs.stack

    # required for clashi
    pkgs.libiconv
    pkgs.libffi
    pkgs.ncurses  ##### <- add import here! #####
  ];
}

thanks @Noughtmare!

  • Related