【发布时间】:2016-01-04 23:20:08
【问题描述】:
我正在尝试在 EC2 实例上构建一个静态链接的“hello world”Haskell 程序,以便在 AWS Lambda 上运行它。
我对“简单”stack.yaml 的唯一修改是:
ghc-options:
"*": -static -optc-static -optl-static -optl-pthread
我首先得到以下错误:
[ec2-user@ip-172-31-0-238 lambdatest]$ stack build
lambdatest-0.1.0.0: configure
Configuring lambdatest-0.1.0.0...
lambdatest-0.1.0.0: build
Preprocessing executable 'lambdatest' for lambdatest-0.1.0.0...
Linking .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/lambdatest/lambdatest ...
/usr/bin/ld: cannot find -lgmp
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lrt
/usr/bin/ld: cannot find -ldl
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
我尝试的第一件事是安装 gmp-devel:
[ec2-user@ip-172-31-0-238 lambdatest]$ sudo yum install gmp-devel.x86_64
Loaded plugins: priorities, update-motd, upgrade-helper
Package gmp-devel-6.0.0-11.16.amzn1.x86_64 already installed and latest version
Nothing to do
但看起来这不是问题。
接下来我安装了glibc-static和gmp-static,现在看到的错误是:
[ec2-user@ip-172-31-0-238 lambdatest]$ stack build
lambdatest-0.1.0.0: build
Preprocessing executable 'lambdatest' for lambdatest-0.1.0.0...
Linking .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/lambdatest/lambdatest ...
/home/ec2-user/.stack/programs/x86_64-linux/ghc-7.10.2/lib/ghc-7.10.2/rts/libHSrts.a(Linker.o): In function `internal_dlopen':
Could not resolve file /home/ben/ghc-7.10.2/rts/Linker.c
但是当我第二次运行相同的“堆栈构建”命令时,它会正确完成。
【问题讨论】:
-
也许堆栈有一个详细模式,可以显示它试图运行的命令。查看它传递给 ld 的内容可能有助于您的调试工作。
-
请参阅堆栈存储库上的this issue。这个名叫
ben的家伙即将因成为广泛分布的 GHC 二进制文件的一部分而出名 :)
标签: linux haskell amazon-ec2 haskell-stack