aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-11 11:52:34 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-14 11:49:39 +0100
commit54480637fb019f2a1603e5263b949e3bd918a0c9 (patch)
tree895165692a95cdeca827fb16227ccedf4f6fd225
parenta41e27cf932f736441b0bb7e8fe09a0962446a9f (diff)
Strip libraries in release mode
[ChangeLog][PySide6] Libraries are now stripped. Task-number: PYSIDE-661 Change-Id: I20ea056b8e91cca917017afa62811208c297d51d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
-rw-r--r--build_scripts/main.py9
-rw-r--r--build_scripts/options.py3
-rw-r--r--sources/pyside6/cmake/Macros/PySideModules.cmake1
-rw-r--r--sources/pyside6/libpyside/CMakeLists.txt2
-rw-r--r--sources/pyside6/libpysideqml/CMakeLists.txt2
-rw-r--r--sources/shiboken6/cmake/ShibokenHelpers.cmake11
-rw-r--r--sources/shiboken6/libshiboken/CMakeLists.txt2
-rw-r--r--sources/shiboken6/shibokenmodule/CMakeLists.txt2
8 files changed, 29 insertions, 3 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py
index 2a1f46797..39ee4837e 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -640,9 +640,12 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin):
if numpy and not self.is_cross_compile:
cmake_cmd.append(f"-DNUMPY_INCLUDE_DIR={numpy}")
- if self.build_type.lower() == 'debug' and not self.is_cross_compile:
- cmake_cmd.append(f"-DPYTHON_DEBUG_LIBRARY={self.py_library}")
-
+ if self.build_type.lower() == 'debug':
+ if not self.is_cross_compile:
+ cmake_cmd.append(f"-DPYTHON_DEBUG_LIBRARY={self.py_library}")
+ else:
+ if OPTION['NO_STRIP']:
+ cmake_cmd.append("-DQFP_NO_STRIP=1")
if OPTION["LIMITED_API"] == "yes":
cmake_cmd.append("-DFORCE_LIMITED_API=yes")
elif OPTION["LIMITED_API"] == "no":
diff --git a/build_scripts/options.py b/build_scripts/options.py
index 6ce53b982..76fb5ce9c 100644
--- a/build_scripts/options.py
+++ b/build_scripts/options.py
@@ -208,6 +208,7 @@ class DistUtilsCommandMixin(object):
('debug', None, 'Build with debug information'),
('relwithdebinfo', None, 'Build in release mode with debug information'),
('only-package', None, 'Package only'),
+ ('no-strip', None, 'Do not strip package libraries (release mode)'),
('standalone', None, 'Standalone build'),
('ignore-git', None, 'Do update subrepositories'),
('skip-docs', None, 'Skip documentation build'),
@@ -260,6 +261,7 @@ class DistUtilsCommandMixin(object):
self.avoid_protected_hack = False
self.debug = False
self.relwithdebinfo = False
+ self.no_strip = False
self.only_package = False
self.standalone = False
self.ignore_git = False
@@ -365,6 +367,7 @@ class DistUtilsCommandMixin(object):
OPTION['AVOID_PROTECTED_HACK'] = self.avoid_protected_hack
OPTION['DEBUG'] = self.debug
OPTION['RELWITHDEBINFO'] = self.relwithdebinfo
+ OPTION['NO_STRIP'] = self.no_strip
OPTION['ONLYPACKAGE'] = self.only_package
OPTION['STANDALONE'] = self.standalone
OPTION['IGNOREGIT'] = self.ignore_git
diff --git a/sources/pyside6/cmake/Macros/PySideModules.cmake b/sources/pyside6/cmake/Macros/PySideModules.cmake
index 6ac4da765..c5bee643c 100644
--- a/sources/pyside6/cmake/Macros/PySideModules.cmake
+++ b/sources/pyside6/cmake/Macros/PySideModules.cmake
@@ -200,6 +200,7 @@ macro(create_pyside_module)
endif()
endif()
+ qfp_strip_library("${module_NAME}")
# Add target to generate pyi file, which depends on the module target.
# Don't generate the files when cross-building because the target python can not be executed
diff --git a/sources/pyside6/libpyside/CMakeLists.txt b/sources/pyside6/libpyside/CMakeLists.txt
index 6f804f529..cd39483a3 100644
--- a/sources/pyside6/libpyside/CMakeLists.txt
+++ b/sources/pyside6/libpyside/CMakeLists.txt
@@ -120,6 +120,8 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_TO_ASCII")
+qfp_strip_library("pyside6")
+
# create pkg-config file
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pyside6.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/pyside6${pyside6_SUFFIX}.pc" @ONLY)
diff --git a/sources/pyside6/libpysideqml/CMakeLists.txt b/sources/pyside6/libpysideqml/CMakeLists.txt
index 33bfce1c6..42238c8cb 100644
--- a/sources/pyside6/libpysideqml/CMakeLists.txt
+++ b/sources/pyside6/libpysideqml/CMakeLists.txt
@@ -57,6 +57,8 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_TO_ASCII")
+qfp_strip_library("pyside6qml")
+
# Install-tree / relocatable package config file.
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/PySide6QmlConfig-spec.cmake.in"
diff --git a/sources/shiboken6/cmake/ShibokenHelpers.cmake b/sources/shiboken6/cmake/ShibokenHelpers.cmake
index 6966b716f..567a79c62 100644
--- a/sources/shiboken6/cmake/ShibokenHelpers.cmake
+++ b/sources/shiboken6/cmake/ShibokenHelpers.cmake
@@ -75,6 +75,17 @@ endif()
endmacro()
+function(qfp_strip_library target)
+ # Strip unless macOS (/strip: error: symbols referenced by indirect symbol
+ # table entries that can't be stripped).
+ if (CMAKE_STRIP AND UNIX AND NOT APPLE AND NOT QFP_NO_STRIP
+ AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(post_command COMMAND ${CMAKE_STRIP} $<TARGET_FILE:${target}>)
+ add_custom_command(TARGET ${target} POST_BUILD ${post_command})
+ endif()
+
+endfunction()
+
macro(shiboken_internal_set_python_site_packages)
# When cross-building, we can't run the target python executable to find out the information,
# so we allow an explicit variable assignment or use a default / sensible value.
diff --git a/sources/shiboken6/libshiboken/CMakeLists.txt b/sources/shiboken6/libshiboken/CMakeLists.txt
index f9267b95a..bca0c0902 100644
--- a/sources/shiboken6/libshiboken/CMakeLists.txt
+++ b/sources/shiboken6/libshiboken/CMakeLists.txt
@@ -140,6 +140,8 @@ set_target_properties(libshiboken PROPERTIES OUTPUT_NAME "shiboken6${shiboken6_S
SOVERSION ${libshiboken_SOVERSION}
DEFINE_SYMBOL BUILD_LIBSHIBOKEN)
+qfp_strip_library("libshiboken")
+
install(FILES
autodecref.h
basewrapper.h
diff --git a/sources/shiboken6/shibokenmodule/CMakeLists.txt b/sources/shiboken6/shibokenmodule/CMakeLists.txt
index 11e15075e..da534ba75 100644
--- a/sources/shiboken6/shibokenmodule/CMakeLists.txt
+++ b/sources/shiboken6/shibokenmodule/CMakeLists.txt
@@ -34,6 +34,8 @@ target_link_libraries(shibokenmodule PUBLIC libshiboken)
create_generator_target(shibokenmodule)
+qfp_strip_library("shibokenmodule")
+
install(TARGETS shibokenmodule DESTINATION ${PYTHON_SITE_PACKAGES}/shiboken6)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/_config.py.in"