awslabs / aws-crt-python

Python bindings for the AWS Common Runtime
Apache License 2.0
87 stars 43 forks source link

AWS_CRT_BUILD_FORCE_STATIC_LIBS #596

Open graebm opened 2 weeks ago

graebm commented 2 weeks ago

Issue: https://github.com/awslabs/aws-crt-python/pull/593 introduced env-var, AWS_CRT_BUILD_USE_SYSTEM_LIBS=1, but it didn't work unless those system libs were built statically.

Diagnosis: The reason it didn't work is: there's a hack in setup.py that forces dependencies to be linked statically on Unix variants (excluding macOS). It worked when I tested on macOS because the hack isn't applied there.

The reason for the hack is: in Brazil (internal AWS build system), dependencies are available as both static and dynamic libs. But we prefer to link the static ones so that, if a python application is packaged for AWS lambda, the developer has fewer files they need to chase down and copy into their .zip package.

Description of changes: Don't force static libs to be used unless AWS_CRT_BUILD_FORCE_STATIC_LIBS=1 (new env-var). Otherwise (by default), the linker will use whatever version of the lib is available (if both are available, linkers generally prefer dynamic). This only applies to non-OS dependencies, we won't force libc to be linked statically.

It's unlikely this env-var will be used anywhere except Brazil.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.