seek-oss / serverless-haskell

Deploying Haskell applications to AWS Lambda with Serverless
MIT License
215 stars 22 forks source link

LTS 14: GLIBC_2.27 not found #114

Closed Jimbo4350 closed 4 years ago

Jimbo4350 commented 4 years ago

Following from: #113 I have written a simple servant server and converted it into a lambda function that queries a ~MySQL~ postgres db in amazon RDS. I can get it to work locally with serverless offline start.

However when I deploy it (serverless deploy) I get the following error in my logs when trying to access my simple test endpoint: ./apigw: /lib64/libm.so.6: version GLIBC_2.27 not found (required by ./apigw)

koterpillar commented 4 years ago

Did you build your Lambda with Docker (default) or without?

Jimbo4350 commented 4 years ago

@koterpillar Running sls deploy --verbose gives the following:

Pulling image from registry: 'fpco/stack-build:lts-14.12'
lts-14.12: Pulling from fpco/stack-build
Digest: sha256:e6be3229b47b790ba2a8dd3f8d36e879705e0df18082f6afe0f36979987194a6
Status: Image is up to date for fpco/stack-build:lts-14.12
docker.io/fpco/stack-build:lts-14.12
Serverless: Building handler apigw with Stack...
koterpillar commented 4 years ago

The binary built with the Stack Docker image is supposed to depend on the low enough GLIBC version for the AWS Lambda to have it. Can you please do the following:

sls package
unzip -l .serverless/*.zip
unzip .serverless/*.zip apigw
unzip .serverless/*.zip '*.so.*'
for binary in apigw *.so.*; do echo $binary; objdump -T $binary | grep -o -E 'GLIBC_[0-9.]+' | sort -u; done

Then we'll be able to see where the newer version is coming from.

Jimbo4350 commented 4 years ago

Here is the output:

for binary in apigw *.so.*; do echo $binary; objdump -T $binary | grep -o -E 'GLIBC_[0-9.]+' | sort -u; done    

apigw
GLIBC_2.10
GLIBC_2.12
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.27
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.4
GLIBC_2.7
GLIBC_2.8
libatomic.so.1
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3.4
GLIBC_2.4
libmysqlclient.so.20
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3.4
GLIBC_2.4
koterpillar commented 4 years ago

OK, I see now, the issue is that lts-14 images have the newer glibc than Lambda:

$ docker run --rm -it fpco/stack-build:lts-14.12 ldd --version
ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

As a workaround, use LTS 13, which uses an older glibc.

koterpillar commented 4 years ago

This is now fixed in 0.9.2 (now building), you can use LTS 14 again.