aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-02-23 14:24:21 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-02-23 14:24:44 +0000
commit85e14a0d72b3470748e3cbe8871e23a818820ee9 (patch)
treeb2260ccaeb4a0ecc31a7f86a1eef124a6ed98f02 /setup.py
parent784df63e6be7339df3872a56baf89ca81c7e7199 (diff)
Add rudimentary support for address sanitizer builds
This change adds a new setup.py option called --sanitize-address which will build all executables and shared libraries with address sanitizer enabled. The builds will only succeed on Linux and macOS machines that have new enough gcc / clang versions, so it is a "use at your own risk" build configuration. This change was necessitated by the random crashes that are sometimes observed on the CI machines, and due to valgrind not working properly on new macOS versions, using AddressSanitizer is the next best thing. Note that when running tests with address sanitizer builds, you might need to export a LD_PRELOAD / DYLD_INSERT_LIBRARIES environment variable pointing to the address sanitizer runtime library path, which will be provided by the crashed application. Change-Id: I93014002e5c5e94bcc808ba2fb830d60724cfb69 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 8a8970c6..eb7b1646 100644
--- a/setup.py
+++ b/setup.py
@@ -81,6 +81,7 @@ For development purposes the following options might be of use, when using "setu
--skip-packaging will skip creation of the python package,
--ignore-git will skip the fetching and checkout steps for supermodule and all submodules.
--verbose-build will output the compiler invocation with command line arguments, etc.
+ --sanitize-address will build all targets with address sanitizer enabled.
REQUIREMENTS:
- Python: 2.6, 2.7, 3.3, 3.4, 3.5 and 3.6 are supported
@@ -296,6 +297,7 @@ OPTION_RPATH_VALUES = option_value("rpath")
OPTION_QT_CONF_PREFIX = option_value("qt-conf-prefix")
OPTION_ICULIB = option_value("iculib-url") # Deprecated
OPTION_VERBOSE_BUILD = has_option("verbose-build")
+OPTION_SANITIZE_ADDRESS = has_option("sanitize-address")
# This is used automatically by distutils.command.install object, to specify final installation
# location.
@@ -1033,6 +1035,13 @@ class pyside_build(_build):
if OPTION_VERBOSE_BUILD:
cmake_cmd.append("-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON")
+ if OPTION_SANITIZE_ADDRESS:
+ # Some simple sanity checking. Only use at your own risk.
+ if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
+ cmake_cmd.append("-DSANITIZE_ADDRESS=ON")
+ else:
+ raise DistutilsSetupError("Address sanitizer can only be used on Linux and macOS.")
+
if extension.lower() == "pyside2":
pyside_qt_conf_prefix = ''
if OPTION_QT_CONF_PREFIX: