awslabs / aws-c-common

Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.
Apache License 2.0
256 stars 156 forks source link

Consider enabling `-fvisibility=hidden` when building a static library. #1142

Open teo-tsirpanis opened 1 month ago

teo-tsirpanis commented 1 month ago

Describe the feature

When building aws-c-common (and the other AWS C libraries), we pass -fvisibility=hidden, but only when building a shared library (since #516). I am proposing to pass it always.

Use Case

Compiling with -fvisibility=hidden makes sense in static libraries too (see related CMake policy). There has been an issue where the interaction between two Python wheels with their own statically linked copy of the AWS SDK resulted in unexplained failures, because both AWS SDKs exported private symbols, which was fixed by forcing the AWS libraries in one of the wheels to compile with -fvisiblity=hidden.

The AWS SDK is already going to always enable -fvisiblity=hidden and so does s2n for non-testing builds. This issue tracks doing the same for the AWS C libraries.

Proposed Solution

Revert to the behavior before #516, or follow s2n's example and pass -fvisibility=hidden always unless we have enabled testing and are building a shared library.

Other Information

No response

Acknowledgements

jmklix commented 1 month ago

Thanks @teo-tsirpanis for this suggestion. This is something that we would like to do, but I don't have a timeline for when this will get implemented