From 85e14a0d72b3470748e3cbe8871e23a818820ee9 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 23 Feb 2018 14:24:21 +0100 Subject: 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 --- sources/shiboken2/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sources/shiboken2') diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt index 238ee2d34..c5cca506e 100644 --- a/sources/shiboken2/CMakeLists.txt +++ b/sources/shiboken2/CMakeLists.txt @@ -144,6 +144,22 @@ if(CMAKE_HOST_APPLE) endif() endif() +# Build with Address sanitizer enabled if requested. This may break things, so use at your own risk. +if (SANITIZE_ADDRESS AND NOT MSVC) + # Currently this does not check that the clang / gcc version used supports Address sanitizer, + # so once again, use at your own risk. + add_compile_options("-fsanitize=address" "-g" "-fno-omit-frame-pointer") + # We need to add the sanitize address option to all linked executables / shared libraries + # so that proper sanitizer symbols are linked in. + # + # Note that when running tests, you may need to set an additional environment variable + # in set_tests_properties for shiboken2 / pyside tests, or exported in your shell. Address + # sanitizer will tell you what environment variable needs to be exported. For example: + # export DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/ + # ./XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib + set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_STANDARD_LIBRARIES} -fsanitize=address") +endif() + add_subdirectory(ApiExtractor) set(generator_plugin_DIR ${LIB_INSTALL_DIR}/generatorrunner${generator_SUFFIX}) -- cgit v1.2.3 From b57c557c8cd1012851f8a245075591dc33be425b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 1 Mar 2018 11:50:07 +0100 Subject: Implement proper package versioning This change is inspired by / follows PEP 440 for handling version numbers and also takes into account the Qt versioning scheme. PySide2 as package name will stay as-is (not renamed to PySide5). Release versions would have the following pattern: PySide2 5.x.y (e.g. 5.6.3) Package (wheel) name would also contain the bundled Qt version, e.g.: PySide2-5.6.0-5.6.4-cp27-cp27m-macosx_10_7_intel.whl Pre-release versions would look like: PySide2 5.6.0a1, 5.6.0a2, 5.6.0b1, 5.6.0b2, 5.6.0rc1, etc. Development (snapshot) versions would look like: PySide2 5.6.0-dev123456789 (last part is timestamp of build time) All of the examples above comply with the PEP 440 rules. In the example above where the Qt version is specified as part of the wheel package name ("5.6.4"), the Qt version is not part of the package version itself, because it doesn't comply with PEP 440. But it does comply with wheel package names (PEP 427), and by that PEP's definitions, it will be the optional "build tag" part of the file name, which is preceded by the actual package version, and followed by the python version / abi tag. Implementation: This change defines two new python configuration files which will be the authoritative source for the shiboken and PySide2 libraries, as well as the final PySide2 package itself: sources/shiboken/shiboken_version.py sources/pyside2/pyside_version.py The pyside_version.py file will be the source of the final package version. The shiboken and PySide2 version should be modified in sync, when bumping the version of the package before a release. The reason for having both files instead of 1, is to make life easier for developers that might extract only shiboken from the repository. If at some point shiboken and PySide2 CMake projects get merged into one project, the duplicate version files would go away. The version files are parsed by CMake to correctly name the shared libraries (and SO versions), and they are also read by the setup.py script, to generate correct package metadata and a correct package (wheel) name. This change also removes the broken dist targets from PySide2's and shiboken's CMakelists files, which depended on some version suffix which was never set in setup.py. PEP440: https://www.python.org/dev/peps/pep-0440/ PEP427: https://www.python.org/dev/peps/pep-0427/ Change-Id: I3226460b1adf2555c8711fa2ba47c223b957cb44 Reviewed-by: Qt CI Bot Reviewed-by: Friedemann Kleint --- sources/shiboken2/CMakeLists.txt | 44 ++++++++++++++++++++--------------- sources/shiboken2/shiboken_version.py | 10 ++++++++ 2 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 sources/shiboken2/shiboken_version.py (limited to 'sources/shiboken2') diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt index c5cca506e..5735fea18 100644 --- a/sources/shiboken2/CMakeLists.txt +++ b/sources/shiboken2/CMakeLists.txt @@ -11,12 +11,6 @@ find_package(Qt5 REQUIRED COMPONENTS Core Xml XmlPatterns) add_definitions(${Qt5Core_DEFINITIONS}) -set(shiboken_MAJOR_VERSION "2") -set(shiboken_MINOR_VERSION "0") -set(shiboken_MICRO_VERSION "0") -set(shiboken2_VERSION "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}.${shiboken_MICRO_VERSION}") -set(shiboken2_library_so_version "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}") - option(BUILD_TESTS "Build tests." TRUE) option(USE_PYTHON_VERSION "Use specific python version to build shiboken2." "") @@ -28,6 +22,31 @@ else() find_package(PythonLibs 2.6) endif() +set(SHIBOKEN_VERSION_FILE_PATH "${CMAKE_SOURCE_DIR}/shiboken_version.py") +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS + ${SHIBOKEN_VERSION_FILE_PATH} +) +execute_process( + COMMAND ${PYTHON_EXECUTABLE} "${SHIBOKEN_VERSION_FILE_PATH}" + OUTPUT_VARIABLE SHIBOKEN_VERSION_OUTPUT + ERROR_VARIABLE SHIBOKEN_VERSION_OUTPUT_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE) +if (NOT SHIBOKEN_VERSION_OUTPUT) + message(FATAL_ERROR "Could not identify shiboken version. \ + Error: ${SHIBOKEN_VERSION_OUTPUT_ERROR}") +endif() + +list(GET SHIBOKEN_VERSION_OUTPUT 0 shiboken_MAJOR_VERSION) +list(GET SHIBOKEN_VERSION_OUTPUT 1 shiboken_MINOR_VERSION) +list(GET SHIBOKEN_VERSION_OUTPUT 2 shiboken_MICRO_VERSION) +# a - alpha, b - beta, rc - rc +list(GET SHIBOKEN_VERSION_OUTPUT 3 shiboken_PRE_RELEASE_VERSION_TYPE) +# the number of the pre release (alpha1, beta3, rc7, etc.) +list(GET SHIBOKEN_VERSION_OUTPUT 4 shiboken_PRE_RELEASE_VERSION) + +set(shiboken2_VERSION "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}.${shiboken_MICRO_VERSION}") +set(shiboken2_library_so_version "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}") + ## For debugging the PYTHON* variables message("PYTHONLIBS_FOUND: " ${PYTHONLIBS_FOUND}) message("PYTHON_LIBRARIES: " ${PYTHON_LIBRARIES}) @@ -279,16 +298,3 @@ else() endif() add_subdirectory(data) - -# dist target -set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${shiboken2_VERSION}) -add_custom_target(dist - COMMAND mkdir -p "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}" && - git log > "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}/ChangeLog" && - git archive --prefix=${ARCHIVE_NAME}/ HEAD --format=tar --output="${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" && - tar -C "${CMAKE_BINARY_DIR}" --owner=root --group=root -r "${ARCHIVE_NAME}/ChangeLog" -f "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" && - bzip2 -f9 "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" && - echo "Source package created at ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2." - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - - diff --git a/sources/shiboken2/shiboken_version.py b/sources/shiboken2/shiboken_version.py new file mode 100644 index 000000000..b207d6b9c --- /dev/null +++ b/sources/shiboken2/shiboken_version.py @@ -0,0 +1,10 @@ +major_version = "5" +minor_version = "6" +patch_version = "0" +pre_release_version_type = "a" # e.g. "a", "b", "rc". +pre_release_version = "1" # e.g "1", "2", (which means "beta1", "beta2", if type is "b") + +if __name__ == '__main__': + # Used by CMake. + print('{0};{1};{2};{3};{4}'.format(major_version, minor_version, patch_version, + pre_release_version_type, pre_release_version)) -- cgit v1.2.3