Dhall on aws lambda


we want to use dhall (specifically dhall-to-json) on aws lambda. Unfortunately the base linux is Amazon Linux 2 (AL2) and it only supports glibc 2.26. So when we start dhall we get

./dhall: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by ./dhall)
./dhall: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by ./dhall)
./dhall: /lib64/libtinfo.so.6: no version information available (required by ./dhall)

Is there a dhall executable available that works on AL2?
If I plan to compile dhall for AL2, is that something that will probably work or break right away (are there some blockers that come to your mind?)
Any other ideas?

Thanks, best regards Christian

i assume you downloaded dhall from the release page, right?

the reason i ask is because i thought the linux builds of dhall were statically linked (including libc), but i can double-check

Yes, we downloaded the prebuild dhall executables from the releases page.

At the end I recompiled dhall on Amazon Linx 2 (AL2) and that worked fine.

Since it wasn’t that straightforward I leave a description for others who might need/want to do that (AL2 or other Linux flavours). I reordered the various steps so it makes a bit more sense.

So I fired up an EC2 (AL2, t3.large and 30GB volume did the job) and first thing is to install all the dev tools (g++, make, …):

sudo yum groupinstall "Development Tools"

Since dhall needs haskell base <4.16 you will need libtinfo.5

sudo yum  install libtinfo5

And for a reason I forgot you also need ncurses-compat-libs

sudo yum install ncurses-compat-libs

So you should have all the packages.

When installing haskell via ghcup the tool will tell you that you need a bunch of libraries (curl g++ gcc gmp make ncurses realpath xz-utils). the ones you need should all be present by now (realpath and xz-utils are not available for AL2, but you do not need them)

When compiling the sources with g++ you might encounter the problem that some libs cannot be found (e.g. gmp). Reason is that the link libgmp.so is missing but the true file is present (libgmp.so.10.2.0). So just add some links:

sudo ln -s /lib64/libgmp.so.10 /lib64/libgmp.so
sudo ln -s /lib64/libtinfo.so.5 /lib64/libtinfo.so

Remember ld -v libname is your friend in case you need to check for a lib or missing dependency

Now all is set for installing haskell

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

Say Prepend and hit Enter until it starts to install and compile. Then wait and hope all works fine :wink:

When done read the instructions and source the environment (e.g. source /home/ec2-user/.ghcup/env)

ghcup install base version 4.16.x but some dependency of dhall require <4.16. So fire up the config UI:

ghcup tui

Select highest 4.15.x version and activate it. Again download, compile, wait.

At the end you should have two green checkmarks on the left side of the 4.15.x entry.

Now get the dhall code and follow the instructions on the github page. Something like

git clone git@github.com:dhall-lang/dhall-haskell.git
cd dhall-haskell/
git submodule init
git submodule update
cabal new-build dhall

Wait and at the end you find the executables in the reported folders.

Good luck! :slight_smile: