summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-05-10 16:25:16 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-05-11 18:53:37 +0200
commitff0ee3d98551c128f33a289c61ff86ae3baab1da (patch)
tree881d530e689b10c474964702a3f4f9400563cef4 /cmake
parent7f94aa23f59dde48de0e070aea2734939de3e6a1 (diff)
CMake: Handle strip wrapper creation more robustly
Unsetting CMAKE_STRIP and including CMakeFindBinUtils to find it again is not safe, because CMakeFindBinUtils has logic to search for additional tool names depending on the currently processed language. The currently processed language is set in _CMAKE_PROCESSING_LANGUAGE only when CMake is doing it's language introspection via CMakeCXXCompiler.cmake. This resulted in the build system finding a regular host-OS strip, rather than an android specific llvm-strip when doing an Android build, which then silently failed to strip the Android libraries and caused us to ship big binaries. Improve the strip wrapper creation in a few ways: - Save the original strip value on first configuration - Restore it if needed, without using CMakeFindBinUtils - Don't apply the strip wrapper creation logic to Android, we currently don't need it there - Add some informational messages about which CMAKE_STRIP ends up being used even if log-level is not DEBUG - Fix a typo Amends 39f657032b5e65bfcb93472201f6607c0388ba37 Pick-to: 6.2 6.3 Fixes: QTBUG-103356 Task-number: QTBUG-101653 Change-Id: I23d98180446d5bb7628e783668f46e4e546ed700 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtSeparateDebugInfo.cmake32
1 files changed, 21 insertions, 11 deletions
diff --git a/cmake/QtSeparateDebugInfo.cmake b/cmake/QtSeparateDebugInfo.cmake
index e983a3b6c2..61fd29a8f1 100644
--- a/cmake/QtSeparateDebugInfo.cmake
+++ b/cmake/QtSeparateDebugInfo.cmake
@@ -66,7 +66,7 @@ function(qt_internal_try_compile_binary_for_strip binary_out_var)
endfunction()
# When using the MinGW 11.2.0 toolchain, cmake --install --strip as used by
-# qt-cmake-private-intstall.cmake, removes the .gnu_debuglink section in binaries and thus
+# qt-cmake-private-install.cmake, removes the .gnu_debuglink section in binaries and thus
# breaks the separate debug info feature.
#
# Generate a wrapper shell script that passes an option to keep the debug section.
@@ -86,17 +86,27 @@ function(qt_internal_generate_binary_strip_wrapper)
return()
endif()
- # To make reconfiguration more robust when QT_INTERNAL_STRIP_SUPPORTS_KEEP_SECTION is manually
- # removed, make sure to always find the original strip first, by first removing the cached var
- # and then finding the binary again.
- unset(CMAKE_STRIP CACHE)
- include(CMakeFindBinUtils)
+ # Backup the original strip path on very first configuration call.
+ # The value might have been determined by CMake via CMakeDetermineCXXCompiler ->
+ # CMakeFindBinUtils -> find_program(), or it might have been set by a toolchain file.
+ if(NOT QT_INTERNAL_ORIGINAL_CMAKE_STRIP AND CMAKE_STRIP)
+ set(QT_INTERNAL_ORIGINAL_CMAKE_STRIP "${CMAKE_STRIP}" CACHE INTERNAL
+ "Original strip binary")
+ endif()
+
+ message(STATUS "CMAKE_STRIP (original): ${QT_INTERNAL_ORIGINAL_CMAKE_STRIP}")
# Target Linux and MinGW.
if((UNIX OR MINGW)
AND NOT APPLE
+ AND NOT ANDROID
AND CMAKE_STRIP)
+ # To make reconfiguration more robust when QT_INTERNAL_STRIP_SUPPORTS_KEEP_SECTION is
+ # manually removed, make sure to always restore the original strip first, by
+ # re-assigning the original value.
+ set(CMAKE_STRIP "${QT_INTERNAL_ORIGINAL_CMAKE_STRIP}" CACHE STRING "")
+
# Getting path to a binary we can run strip on.
qt_internal_try_compile_binary_for_strip(valid_binary_path)
@@ -127,7 +137,7 @@ function(qt_internal_generate_binary_strip_wrapper)
message(DEBUG
"qt_internal_generate_binary_strip_wrapper:\n"
- "original strip: ${CMAKE_STRIP}\n"
+ "original strip: ${QT_INTERNAL_ORIGINAL_CMAKE_STRIP}\n"
"strip probe output: ${strip_probe_output}\n"
"strip result: ${strip_result_var}\n"
"keep section supported: ${keep_section_supported}\n"
@@ -173,15 +183,15 @@ function(qt_internal_generate_binary_strip_wrapper)
set(wrapper_out "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}${wrapper_extension}")
- set(original_strip "${CMAKE_STRIP}")
+ # Used in the template file.
+ set(original_strip "${QT_INTERNAL_ORIGINAL_CMAKE_STRIP}")
configure_file("${wrapper_in}" "${wrapper_out}" @ONLY)
- # Backup the original strip path for informational purposes.
- set(QT_INTERNAL_ORIGINAL_STRIP "${original_strip}" CACHE INTERNAL "Original strip binary")
-
# Override the strip binary to be used by CMake install target.
set(CMAKE_STRIP "${wrapper_out}" CACHE INTERNAL "Custom Qt strip wrapper")
+
+ message(STATUS "CMAKE_STRIP (used by Qt): ${CMAKE_STRIP}")
endif()
endfunction()