haskell 运行碰撞解释器时出错

ohtdti5x  于 2022-11-14  发布在  其他
关注(0)|答案(1)|浏览(165)

在M1 mac上运行时,我通过nix-shell安装了stack,该nix-shell定义为:

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

pkgs.mkShell {
  buildInputs = [
    pkgs.stack

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

然后使用stack exec --package clash-ghc -- clashi运行碰撞解释器,生成以下输出:

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

不知道为什么运行上面的命令会产生这些错误。感谢您的帮助!

kg7wmglp

kg7wmglp1#

我丢失了ncurses库的导入,如下面控制台输出的代码片段所述:

hint                     > ld: library not found for -lncurses

因此,我只需将pkgs.ncurses添加到我shell.nix文件中,如下所示:

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

pkgs.mkShell {
  buildInputs = [
    pkgs.stack

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

谢谢@Noughtmare!

相关问题