theam / aws-lambda-haskell-runtime

⚡Haskell runtime for AWS Lambda
https://theam.github.io/aws-lambda-haskell-runtime/
Other
270 stars 48 forks source link

Question about external libraries, e.g libpq.so.5 #39

Closed oddvars closed 5 years ago

oddvars commented 5 years ago

I hit a snag with external libraries, much like the ones mentioned here.

I got round them, at least initially, with doing a ldd bootstrap in the ./build folder, and then copying the ones I needed into ./lib, and then adding this to the Makefile.

rsync -rl ./lib/ ./build/lib/ cd build && zip -r quotation-lambda.zip bootstrap lib && cd ..

$LAMBDA_TASK_ROOT/lib seemed to already be in the LD_LIBRARY_PATH, so I just went for that.

This got a bit tedious, and I've found a way of copying everything into the ./lib folder using ldd + sed, but I also tried to add this in my package.yaml, and that seemed to do the job with less ceremony:

ghc-options: -threaded -rtsopts -O2 -static -with-rtsopts=-N cc-options: -static ld-options: -static -pthread

Are there reasons for not statically linking the executable when building with stack?

NickSeagull commented 5 years ago

Hey! Thanks for pointing this out!

To be honest, we didn't think about that 😅 Would you be up to contribute a PR that adds these flags to the stack-template.hs file?

Another possibility would be to add it to the Common Errors doc page you pointed out.

Thanks again! 🙏

oddvars commented 5 years ago

Sure, no problem :smile: