尝试在Nixos上使用堆栈编译静态可执行文件时出现链接器错误

时间:2019-02-24 12:10:30

标签: haskell stack nix nixos

似乎我可能需要向nix依赖项添加一些“程序包”,尽管我不确定如何确定哪些程序包(除了对每个lmlrt进行繁琐的网络搜索之外)。 ..)?

stack install     
Building all executables for `sodiumSierraStrawberry' once. After a successful build of all of them, only specified executables will be rebuilt.
sodiumSierraStrawberry-0.1.0.0: configure (exe)
Configuring sodiumSierraStrawberry-0.1.0.0...
sodiumSierraStrawberry-0.1.0.0: build (exe)
Preprocessing executable 'sodiumSierraStrawberry' for sodiumSierraStrawberry-0.1.0.0..
Building executable 'sodiumSierraStrawberry' for sodiumSierraStrawberry-0.1.0.0..
[1 of 2] Compiling Paths_sodiumSierraStrawberry ( .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/autogen/Paths_sodiumSierraStrawberry.hs, .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/sodiumSierraStrawberry-tmp/Paths_sodiumSierraStrawberry.o )
[2 of 2] Compiling Prompt           ( src/Prompt.hs, .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/sodiumSierraStrawberry-tmp/Prompt.o )
Linking .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/sodiumSierraStrawberry ...
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lm
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lrt
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lutil
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -ldl
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lgmp
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lm
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lrt
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -ldl
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lpthread
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)

--  While building package sodiumSierraStrawberry-0.1.0.0 using:
      /home/chris/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.3 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1 build exe:sodiumSierraStrawberry --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

cabal文件:

-- This file has been generated from package.static.yaml by hpack version 0.28.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: dc5d80120403b39adcd93487e3eb7b084fcc8abb48bc9c23eaaa9dbc7c48cb06

cabal-version:  >= 1.10
name:           sodiumSierraStrawberry
version:        0.1.0.0
author:         Chris Stryczynski
maintainer:     Chris Stryczynski
license:        BSD3
license-file:   LICENSE
build-type:     Simple
extra-source-files:
    ChangeLog.md

executable sodiumSierraStrawberry
  main-is: Prompt.hs
  other-modules:
      Paths_sodiumSierraStrawberry
  hs-source-dirs:
      src
  default-extensions: LambdaCase
  ghc-options: -Wall -O2 -static -threaded -main-is Prompt
  cc-options: -static
  ld-options: -static -pthread
  build-depends:
      MissingH
    , aeson
    , base
    , bytestring
    , directory
    , filepath
    , optparse-applicative
    , pretty-simple
    , safe
    , split
    , stm
    , string-conversions
    , text
    , thyme
    , time
  default-language: Haskell2010

1 个答案:

答案 0 :(得分:2)

在这种情况下,我可以通过添加以下内容来解决它:

nix:
  packages:
      - glibc.static
      - gmp5.static

但是,我仍然不确定如何确定这些flags(lm,lrt等)与实际包装之间的关系。