conan-center-index
conan-center-index copied to clipboard
zeromq: Add options to enable sanitizers
Summary
Changes to recipe: zeromq/4.3.5
Motivation
This PR adds CMake options to enable AddressSanitizer (ASAN), ThreadSanitizer (TSAN), UndefinedBehaviorSanitizer (UBSAN), and atomic intrinsics support. These options help developers catch memory errors, data races, and undefined behavior during development and testing, improving code safety and reliability.
Details
TSAN may report many false positives in libzmq because thread synchronization is often managed by design assumptions rather than explicit enforcement. The configuration below allows building libzmq with basic TSAN support, mainly for compatibility when linking with other TSAN-instrumented code e.g. applications using ZeroMQ and tested under various sanitizers.
- Added ENABLE_ASAN, ENABLE_TSAN, and ENABLE_UBSAN options to allow building with sanitizers for better bug detection.
- Added ENABLE_INTRINSICS option to use compiler intrinsics for atomic operations, improving performance and correctness.
More information can be found here https://github.com/zeromq/libzmq/issues/3919
- [x] Read the contributing guidelines
- [x] Checked that this PR is not a duplicate: list of PRs by recipe
- [x] Tested locally with at least one configuration using a recent version of Conan
Hi, just checking in to see if there’s anything I can do to move this forward. Happy to make changes if needed.
Hi @pblxptr - thanks for your PR.
Adding specific options for sanitizers is not something that we typically handle at the recipe level, because it can be done outside of the recipes altogether, in your profile.
For example, for asan
os=Linux
compiler=gcc
...
[conf]
tools.build:cflags=["-fsanitize=address","-fsanitize-address-use-after-scope","-fno-omit-frame-pointer"]
tools.build:cxxflags=["-fsanitize=address","-fsanitize-address-use-after-scope","-fno-omit-frame-pointer"]
tools.build:exelinkflags=["-fsanitize=address","-fsanitize-address-use-after-scope"]
tools.build:sharedlinkflags=["-fsanitize=address","-fsanitize-address-use-after-scope"]
These are generally preferred, since using sanitizers typically means all dependencies need to be built with sanitizers (otherwise there may be false positives or false negatives).
If you wish to enforce this for zeromq only, this can also be injected via the profile or command line without the recipe having to be modified:
[conf]
zeromq/*:tools.cmake.cmaketoolchain:extra_variables={'ENABLE_ASAN': 'ON'}
Let us know if you have questions about how to inject these.
Happy to consider ENABLE_INTRINSICS as an option for the recipe, as that one seems to be specific to zmq.