lambci / docker-lambda

Docker images and test runners that replicate the live AWS Lambda environment
MIT License
5.83k stars 431 forks source link

Latest `build` images have inconsistent gcc and g++ versions #182

Closed garyd203 closed 5 years ago

garyd203 commented 5 years ago

Summary We have run into a problem compiling C++ files in the currently version of the lambci/lambda:build-python3.6 docker image. This is caused by an inconsistency in the configured versions of gcc and g++.

There are 2 installed versions of gcc, where both v4.8.5 and v7.2 are installed but v7.2 is used. There is only 1 installed version of g++, which is v4.8.5. This means if you try to compile a C++ file using the gcc command then you get an error along the lines of

gcc: error trying to exec 'cc1plus': execvp: No such file or directory

Reproduce docker run --rm -it lambci/lambda:build-python3.6 pip install marisa-trie

Solution I'm not sure whether we should be using v7.2 or v4.8.5.

As a simple workaround, we are forcing the use of gcc v4.8.5 in our build script via: alternatives --set gcc /usr/bin/gcc48

mhart commented 5 years ago

Oh wow, thanks for the update – gcc and g++ used to be in the development group, which gets installed on the base build system: https://github.com/lambci/docker-lambda/blob/master/base/build/Dockerfile#L18

I'll need to look into what's changed here – probably installing g++ 7.2 is the right answer

mhart commented 5 years ago

Have added gcc72-g++ to the build images – let me know if that fixes the issue!

shlomimatichin commented 5 years ago

my two cents - we installed gcc72-g++ but then it doesn't run on lambda, since some c++ library is missing. we reverted to same fix as above, alternatives --set gcc /usr/bin/gcc48 and update-alternatives --set cpp /usr/bin/cpp48

mhart commented 5 years ago

@shlomimatichin ah, I thought you said in https://github.com/lambci/docker-lambda/issues/183 that it fixed the issue

Can you give some more details as to what the error was? It would be nicer to enable gcc 7.2 if possible just because there's a bunch of software that won't compile on 4.8 anymore

mhart commented 5 years ago

@shlomimatichin I'm just compiling Node.js with g++ 7.2 on docker-lambda right now and it seems to be compiling fine – was it a library specific to your cython extension that might have been the issue?

mhart commented 5 years ago

FWIW, the reproduction from @garyd203 works now:

docker run --rm -it lambci/lambda:build-python3.6 pip install marisa-trie
shlomimatichin commented 5 years ago

fetched the exact error:

Unable to import module 'amenity.insightengine.backend.lambda_insightengine': /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /var/task/amenity/insightengine/runtime/extendeddoc.cpython-36m-x86_64-linux-gnu.so)

i called it in too soon - just as it compiled. once i tried running it on lambda, i think the libstdc++ installed on amazonlinux image used by lambda does not support the ABI generated by new gcc. maybe there are flags to require older ABI?

mhart commented 5 years ago

Ugh. I see. You might be right – that sounds very likely.

Ok, I'll add the alternatives --set calls to the build image too – will update you when they've built

mhart commented 5 years ago

Ok, this should be fixed, for real this time 😸