I'm trying to compile Python 3.6 on Linux statically with OpenSSL.
My build happens in a dockerfile, but essentially does:
$ ./configure --prefix=/task/build --disable-shared LDFLAGS="-static"
$ make altinstall
With an update to Modules/Setup.local
to make it look like:
*static*
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
However, on the configure step, I get the error:
Step 9/14 : RUN ./configure --prefix=/task/build --disable-shared LDFLAGS="-static"
---> Running in cb79ee47052b
checking for git... found
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.6... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/task/cpython':
configure: error: C compiler cannot create executables
See `config.log' for more details
The command '/bin/sh -c ./configure --prefix=/task/build --disable-shared LDFLAGS="-static"' returned a non-zero code: 77
If I change the configure command to:
$ ./configure --prefix=/task/build --disable-shared
I get a compiled binary, but it isn't statically linked to OpenSSL.
What am I doing wrong?
Thanks!
Build dockerfile:
FROM amazonlinux:2017.03.1.20170812
ARG python_version=3.6.8
WORKDIR /task
COPY Modules-Setup.local /task/Modules-Setup.local
# Install requirements
RUN yum install -y \
gcc \
git \
gzip \
openssl-devel \
tar \
zlib \
zlib-devel
# Get openssl and python source
RUN git clone https://github.com/python/cpython.git
WORKDIR /task/cpython
RUN git checkout tags/v${python_version}
# Configure the build
RUN ./configure --prefix=/task/build --disable-shared LDFLAGS="-static"
# Append modules setup with custom values
RUN cat /task/Modules-Setup.local >> /task/cpython/Modules/Setup.local
RUN cat /task/cpython/Modules/Setup.local
# Build
RUN make altinstall
# Zip the results
WORKDIR /task/build
RUN tar --create --gzip --file=/task/python-${python_version}.tar.gz \
lib/ bin/
LDFLAGS="-static" ./configure --prefix=/task/build --disable-shared
. Could you detail what statically linked to OpenSSL means?