-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/lib64/libc.so.6: version `GLIBC_2.18' not found #17
Comments
Oh man, I'm not sure, and I don't have an Ubuntu instance handy. Can you try building this using musl-libc instead of GNU libc? This would entail adding the |
@Dgame I would probably use a docker image to build in local. AWS Lambda uses Amazon Linux 2017.03.1. We are working to add Rust support to SAM build. |
I get the same error when compiling on Arch Linux. And it seems that using amazonlinux doesn't help, building with a docker image yields the same result. Here's a Dockerfile that I used: https://gist.github.com/drogus/e16260baa0210a30922a3808a9eed8ff After building it I just ran the command from the README:
|
That said, building with musl works correctly (on Arch I installed the musl package and added a |
Mh, I was able to cargo build successfully and run the basic example with this Dockerfile: FROM amazonlinux:2017.03.1.20170812
RUN curl https://sh.rustup.rs -sSf | /bin/sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup install stable
RUN yum install -y gcc gcc-c++ make openssl openssl-devel
RUN mkdir /code
WORKDIR /code I will try to replicate with Nightly next, not sure what's causing your issue yet. |
Well, we are already doing that, but there was the slight hope that building it locally would be faster.
I've tried but I get this:
|
I've tried
but then I get those strange OpenSSL errors which I don't get if I drop
Any ideas? |
@Dgame Are you compiling on a Mac or in a container? In a Mac, you get these errors because the version of OpenSSL and source you need are not available or the compiler/linker cannot find them. There's a pretty good explanation on StackOverflow here. I would recommend using a docker container for building with the Dockerfile from my previous answer. |
@Dgame I'm on ARCH so I'm not sure if it helps you in any way, but I had to specify openssl paths and allow cross compilation:
|
On thing I should have added @Dgame, is that if you use the Amazon Linux Docker container to build then you don't have to specify a |
Until some of the command line tools finish, you may want to use the docker and cargo_config from https://github.com/srijs/rust-aws-lambda/tree/master/docker More information on setting up environment here: https://github.com/srijs/rust-aws-lambda/blob/master/docs/getting-started.md#Deploy |
@Dgame you could also try using the C++ runtime. It deals with this issue seamlessly ;) you can build on Ubuntu, ArchLinux, Alpine, etc. |
@marcomagdy No, thanks. ;) I've already written the code in rust. It's just about the build time. With Docker it takes ~15 min, without <4min. |
This is quite painful. I've spent a good few hours trying to get all of the required musl tools and musl Rust target to compile, and now I'm having issues getting openssl-sys to compile on musl. I'd rather not build inside Docker if possible. |
You don't actually have to wait for SAM. If you are a serverless framework user you may want to check out the rust plugin It provides a more seemless build experience as it uses the lambdaci project's "provided" build env ( a faithful replication of the same env you will be deploying into ). If you aren't a SAM user you can also just use the a replicated build env, the lambdaci project provides this for custom runtimes. Here's a published extension of that with the rust toolchain pre-installed https://github.com/softprops/lambda-rust#-usage |
@c-edw SAM build will automatically use docker to build the app. If you'd rather not use docker at all, your alternatives are:
|
From my experience,
The feature will download and compile openssl in your project's |
Using the vendored SSL is the easiest way to build this. I'm working with the SAM CLI folks to have a |
I had all the same issues. I was building on a mac. I went the docker build route after running into OpenSSL linking issues. I had to use the lambci/lambda:build-provided image instead. The image mentioned here resulted in SSL errors when I ran the lambda function in AWS.
Here is my Dockerfile FROM lambci/lambda:build-provided
RUN curl https://sh.rustup.rs -sSf | /bin/sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup install stable
# RUN yum install -y gcc gcc-c++ make openssl openssl-devel
RUN mkdir /code
WORKDIR /code Then I ran
|
Since most of my day-to-day work is on a Mac, I've used Cross (which recently merged support for macOS!) to build the Lambda function. $ cargo install --force --git https://github.com/rust-embedded/cross # this pulls from master, only needed once
$ cross build --release --target x86_64-unknown-linux-musl Note: Cross has a Docker dependency. I've been using Docker Desktop for Mac pretty happily. |
Saved my day! Cross should be mentioned in the README, worked flawlessly. |
Hi everyone, Having the same issue.
|
I think the takeaway of this issue is that this project has to built against musl, as the glibc on the Lambda sandbox is too old for Rust. |
@davidbarsky sorry for my ignorance. What your statement "has to built against musl" means? Can I achieve that by using Ubuntu, Debian or Amazon Linux by installing the special packages? Or/And I need to change some configuration of a system or a project? Thank you. |
@konstantinvlasenko Sorry, that's my bad! Nothing to apologize for: I was curt in my previous message. You'll need to build against the All that being said, I am primarily a macOS user (with the occasional Amazon Linux usage), so I can't really tell you how to install Musl on a Debian-based system. Personally, I build everything via a Docker image. |
(I also apologize if I over-explained anything to you!) |
Works! Works! Works! So in my case after following all the steps from here https://aws.amazon.com/blogs/opensource/rust-runtime-for-aws-lambda/ I was missing this one command in my Ubuntu instance:
|
@davidbarsky I am currently facing this issue. I initially tried building with Is there another way to resolve this? |
@chumaumenze That makes sense. Trying to build crates with C/C++ dependencies isn't trivial. Unfortunately, there isn't anything that you can do at the moment. To properly resolve this issue, the runtime environment needs to be updated to use Amazon Linux 2, which has a significantly more recent glibc. I'm unable to share a date for when that work will be completed, but I'll let you know when that update has launched. |
@softprops , would it be better to replace
with
in the ReadMe (https://github.com/awslabs/aws-lambda-rust-runtime#aws-cli)? I managed to get my Lambda going after targeting |
That doc is still true but when expanded, you've got options. For local builds musl seems reliable with the tradeoff I'm warming up to of making sure your os or the one your building on has all of the musl prerequisites manually installed. This varies by os. This is the approach I'm trying to get sam team to accept aws/aws-lambda-builders#174 (available someday maybe) And one I'm experimenting with in the serverless framework https://github.com/softprops/serverless-rust/blob/master/README.md#-experimental-local-builds (available today) The alternative is to build on a container that matches the lambda runtime. The tradeoff here is that assumes docker. Docker is most likely already present on many dev envs but comes with some limitations of what is preinstalled in that docker image https://github.com/softprops/lambda-rust. (available today) |
I'd actually close this issue and direct folks to I'm looking into building a docker container for rust and lambda that can work well with SAM CLI (and Apple Silicon trying to cross-compile |
Hey, I've added references to provided.al2 in the README now. Closing this issue. |
I'm building the lambda on Ubuntu with the basic example you've provided in the README.
It builds without any errors but if I upload and test it on aws in crashes with:
The log output is:
The text was updated successfully, but these errors were encountered: