Azure / azure-c-shared-utility

Azure C SDKs common code
Other
111 stars 203 forks source link

azure-c-shared-utility/CMakeFiles/aziotsharedutil.dir/adapters/tlsio_openssl.c fails to build on Alpine #585

Closed abossard closed 2 years ago

abossard commented 2 years ago

Hi

when I build my docker image with some azure sdks in it (for Storage, ServiceBus and KeyVault) it fails to build the azure-c-shared-utility in Alpine linux (works fine on debian.)

Do you know a way I can fix that?

10 214.3 [ 49%] Building C object deps/azure-c-shared-utility/CMakeFiles/aziotsharedutil.dir/adapters/httpapi_compact.c.o

10 214.3 [ 50%] Building C object deps/azure-c-shared-utility/CMakeFiles/aziotsharedutil.dir/src/http_proxy_io.c.o

10 214.3 [ 51%] Building C object deps/azure-c-shared-utility/CMakeFiles/aziotsharedutil.dir/adapters/tlsio_openssl.c.o

10 214.3 /tmp/pip-install-zky71z3s/uamqp_cbc13c2ee0d443a2881e672922be8edf/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/tlsio_openssl.c: In function 'add_certificate_to_store':

10 214.3 /tmp/pip-install-zky71z3s/uamqp_cbc13c2ee0d443a2881e672922be8edf/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/tlsio_openssl.c:961:24: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

10 214.3 961 | bio_method = BIO_s_mem();

10 214.3 | ^

10 214.3 cc1: all warnings being treated as errors

10 214.3 make[2]: *** [deps/azure-c-shared-utility/CMakeFiles/aziotsharedutil.dir/build.make:790: deps/azure-c-shared-utility/CMakeFiles/aziotsharedutil.dir/adapters/tlsio_openssl.c.o] Error 1

10 214.3 make[1]: *** [CMakeFiles/Makefile2:943: deps/azure-c-shared-utility/CMakeFiles/aziotsharedutil.dir/all] Error 2

10 214.3 make: *** [Makefile:146: all] Error 2

10 214.3 Traceback (most recent call last):

10 214.3 File "", line 1, in

10 214.3 File "/tmp/pip-install-zky71z3s/uamqp_cbc13c2ee0d443a2881e672922be8edf/setup.py", line 260, in

10 214.3 setup(

10 214.3 File "/opt/venv/lib/python3.10/site-packages/setuptools/init.py", line 153, in setup

10 214.3 return distutils.core.setup(**attrs)

10 214.3 File "/usr/local/lib/python3.10/distutils/core.py", line 148, in setup

10 214.3 dist.run_commands()

10 214.3 File "/usr/local/lib/python3.10/distutils/dist.py", line 966, in run_commands

10 214.3 self.run_command(cmd)

10 214.3 File "/usr/local/lib/python3.10/distutils/dist.py", line 985, in run_command

10 214.3 cmd_obj.run()

10 214.3 File "/opt/venv/lib/python3.10/site-packages/setuptools/command/install.py", line 61, in run

10 214.3 return orig.install.run(self)

10 214.3 File "/usr/local/lib/python3.10/distutils/command/install.py", line 568, in run

10 214.3 self.run_command('build')

10 214.3 File "/usr/local/lib/python3.10/distutils/cmd.py", line 313, in run_command

10 214.3 self.distribution.run_command(command)

10 214.3 File "/usr/local/lib/python3.10/distutils/dist.py", line 985, in run_command

10 214.3 cmd_obj.run()

10 214.3 File "/usr/local/lib/python3.10/distutils/command/build.py", line 135, in run

10 214.3 self.run_command(cmd_name)

10 214.3 File "/usr/local/lib/python3.10/distutils/cmd.py", line 313, in run_command

10 214.3 self.distribution.run_command(command)

10 214.3 File "/usr/local/lib/python3.10/distutils/dist.py", line 985, in run_command

10 214.3 cmd_obj.run()

10 214.3 File "/tmp/pip-install-zky71z3s/uamqp_cbc13c2ee0d443a2881e672922be8edf/setup.py", line 134, in run

10 214.3 self.build_cmake(ext)

10 214.3 File "/tmp/pip-install-zky71z3s/uamqp_cbc13c2ee0d443a2881e672922be8edf/setup.py", line 188, in build_cmake

10 214.3 subprocess.check_call(joined_cmd, shell=True, universal_newlines=True, env=build_env)

10 214.3 File "/usr/local/lib/python3.10/subprocess.py", line 369, in check_call

10 214.3 raise CalledProcessError(retcode, cmd)

10 214.3 subprocess.CalledProcessError: Command 'cmake --build . --config Release' returned non-zero exit status 2.

10 214.3 ----------------------------------------

10 214.3 ERROR: Command errored out with exit status 1: /opt/venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zky71z3s/uamqp_cbc13c2ee0d443a2881e672922be8edf/setup.py'"'"'; file='"'"'/tmp/pip-install-zky71z3s/uamqp_cbc13c2ee0d443a2881e672922be8edf/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-320_7pft/install-record.txt --single-version-externally-managed --compile --install-headers /opt/venv/include/site/python3.10/uamqp Check the logs for full command output.

10 214.8 WARNING: You are using pip version 21.2.4; however, version 22.0.3 is available.

10 214.8 You should consider upgrading via the '/opt/venv/bin/python3 -m pip install --upgrade pip' command.


error: failed to solve: executor failed running [/bin/sh -c . /opt/venv/bin/activate && pip install -r requirements_freeze.txt]: exit code: 1


- Dockerfile

FROM python:3.10-alpine

WORKDIR /opt/app

RUN apk add --no-cache gcc python3-dev cmake build-base libressl-dev libffi-dev

COPY requirements_freeze.txt .

RUN python3 -m venv /opt/venv RUN . /opt/venv/bin/activate && pip install -r requirements_freeze.txt

COPY entrypoint.sh /opt/app/ COPY src /opt/app ENTRYPOINT [ "/bin/bash", "/opt/app/entrypoint.sh"]


- requirements_freeze.txt

aiohttp==3.8.1 aiosignal==1.2.0 async-timeout==4.0.2 attrs==21.4.0 azure-common==1.1.28 azure-core==1.22.1 azure-core-tracing-opencensus==1.0.0b8 azure-identity==1.7.1 azure-keyvault-secrets==4.3.0 azure-servicebus==7.6.0 azure-storage-blob==12.9.0 azure-storage-queue==12.1.6 cachetools==5.0.0 certifi==2021.10.8 cffi==1.15.0 charset-normalizer==2.0.12 cryptography==36.0.1 frozenlist==1.3.0 google-api-core==2.5.0 google-auth==2.6.0 googleapis-common-protos==1.54.0 idna==3.3 isodate==0.6.1 msal==1.17.0 msal-extensions==0.3.1 msrest==0.6.21 multidict==6.0.2 oauthlib==3.2.0 opencensus==0.8.0 opencensus-context==0.1.2 opencensus-ext-azure==1.1.1 opencensus-ext-httplib==0.7.5 opencensus-ext-logging==0.1.1 opencensus-ext-requests==0.7.6 opencensus-ext-threading==0.1.2 portalocker==2.3.2 protobuf==3.19.4 psutil==5.9.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 pycparser==2.21 PyJWT==2.3.0 pymongo==4.0.1 python-dotenv==0.19.2 requests==2.27.1 requests-oauthlib==1.3.1 rsa==4.8 six==1.16.0 typing_extensions==4.1.1 uamqp==1.5.1 urllib3==1.26.8 wrapt==1.13.3 yarl==1.7.2

danewalton commented 2 years ago

Do you know what version of openssl you are using? The section of code that seems to be failing will use the const up to version 2.0 of openssl.

https://github.com/Azure/azure-c-shared-utility/blob/a0915d48fcd491416ac7e6d89abba4e98cdc2382/adapters/tlsio_openssl.c#L956-L961

abossard commented 2 years ago

ah yes, it's Alpine with libssl1.1

There's no newer version on Alpine Linux https://pkgs.alpinelinux.org/package/edge/main/aarch64/openssl

danewalton commented 2 years ago

Are you able to see if you have OPENSSL_VERSION_NUMBER defined and what that value might be?

abossard commented 2 years ago

I'm not that well-versed in c, but:

#include <stdio.h>
#include <stdlib.h>
#include <openssl/ssl.h> /* core library */

int main(void)
{
  printf("%lx\n", OPENSSL_VERSION_NUMBER);
  return (0);
}

this outputs: 101010cf

Does that help?