From a88f7b21c61e4aa9efcfb81d7939e44b06df3a0d Mon Sep 17 00:00:00 2001 From: Shyamnath Premnadh Date: Wed, 23 Mar 2022 09:33:22 +0100 Subject: PySide6: Optimize for Size build: use the following flag with setup.py to turn off size optimization --no-size-optimization Added the following compiler optimization flags and their corresponding flags on other platforms GCC - -ffunction-sections -fdata-section which segretates data and function section and linker flag --gc-section which removes unused code. - -fno-exceptions to disable exception handling - -Os - Optimize for size. Basically same as -O2 but removes some flags that cause increase in size. (Ran a couple of example and did not see difference in execution time) MSVC - /Gy /Gw /OPT:REF - same as -ffunction-sections, -fdata-section, -Wl, --gc-section - /EHsc same as -fno-exceptions - /O1 instead of /Os because for MSVC /O1 gave the best results. Clang - Same as GCC except for using -Oz instead of -Os. Experiments: Built a wheel with QtCore and noticed a 300kb reduction in size on both Windows and Linux. Built a complete wheel(except QTest) and it gives me a 4 mb size reduction with unaffected performance. Task-number: PYSIDE-1860 Change-Id: Ia5dfa2c4bfde92994c939b5fac0d0831fa3a73ab Reviewed-by: Friedemann Kleint Reviewed-by: Christian Tismer --- build_scripts/main.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'build_scripts/main.py') diff --git a/build_scripts/main.py b/build_scripts/main.py index d44fa2f76..3f8ebd4d7 100644 --- a/build_scripts/main.py +++ b/build_scripts/main.py @@ -667,6 +667,9 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): else: if OPTION['NO_STRIP']: cmake_cmd.append("-DQFP_NO_STRIP=1") + if OPTION['NO_OVERRIDE_OPTIMIZATION_FLAGS']: + cmake_cmd.append("-DQFP_NO_OVERRIDE_OPTIMIZATION_FLAGS=1") + if OPTION["LIMITED_API"] == "yes": cmake_cmd.append("-DFORCE_LIMITED_API=yes") elif OPTION["LIMITED_API"] == "no": -- cgit v1.2.3