aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-07-17 16:50:36 +0200
committerShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-07-26 15:38:14 +0200
commit26a006cc76fbc65cae1b688da6f9bf5aa2456867 (patch)
tree87ff321917b850ccd64b913b76e1a5123a77d1da
parentdde6245d58f6af76ec49bb9b509a103374ac4c36 (diff)
Android Deployment: Rpath changes through linker flags
- Using patchelf to modify the binaries for rpath changes corrupts the binary. This leads to binaries not being able to be loaded at startup by the Android runtime which is required for establishing callbacks from C++ back to Python. - Using linker flags -Wl,-rpath='$ORIGIN' -Wl,-rpath='$ORIGIN/Qt/lib' and disabling patchelf for Android cross compilation solves the issue Task-number: PYSIDE-1612 Change-Id: I70e74d3ca2b0bc65e2565268c36038eeb7c47ddd Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--build_scripts/platforms/linux.py12
-rw-r--r--build_scripts/platforms/unix.py2
-rw-r--r--tools/cross_compile_android/templates/toolchain_default.tmpl.cmake12
3 files changed, 18 insertions, 8 deletions
diff --git a/build_scripts/platforms/linux.py b/build_scripts/platforms/linux.py
index 7bb3bdeb9..835cc4dd0 100644
--- a/build_scripts/platforms/linux.py
+++ b/build_scripts/platforms/linux.py
@@ -72,7 +72,8 @@ def prepare_standalone_package_linux(pyside_build, _vars, cross_build=False, is_
copy_icu_libs(pyside_build._patchelf_path, destination_qt_lib_dir)
# Set RPATH for Qt libs.
- pyside_build.update_rpath_for_linux_qt_libraries(destination_qt_lib_dir)
+ if not is_android:
+ pyside_build.update_rpath_for_linux_qt_libraries(destination_qt_lib_dir)
# Patching designer to use the Qt libraries provided in the wheel
if config.is_internal_pyside_build() and not OPTION['NO_QT_TOOLS']:
@@ -120,10 +121,11 @@ def prepare_standalone_package_linux(pyside_build, _vars, cross_build=False, is_
_vars=_vars)
copied_plugins = pyside_build.get_shared_libraries_in_path_recursively(
qml_plugins_target)
- pyside_build.update_rpath_for_linux_plugins(
- copied_plugins,
- qt_lib_dir=destination_qt_lib_dir,
- is_qml_plugin=True)
+ if not is_android:
+ pyside_build.update_rpath_for_linux_plugins(
+ copied_plugins,
+ qt_lib_dir=destination_qt_lib_dir,
+ is_qml_plugin=True)
if copy_translations:
# <qt>/translations/* ->
diff --git a/build_scripts/platforms/unix.py b/build_scripts/platforms/unix.py
index 8665fb2dc..570c4d570 100644
--- a/build_scripts/platforms/unix.py
+++ b/build_scripts/platforms/unix.py
@@ -238,7 +238,7 @@ def prepare_packages_posix(pyside_build, _vars, cross_build=False):
pyside_build.prepare_standalone_clang(is_win=False)
# Update rpath to $ORIGIN
- if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
+ if (sys.platform.startswith('linux') or sys.platform.startswith('darwin')) and not is_android:
rpath_path = destination_dir
pyside_build.update_rpath(executables)
pyside_build.update_rpath(pyside_build.package_libraries(rpath_path))
diff --git a/tools/cross_compile_android/templates/toolchain_default.tmpl.cmake b/tools/cross_compile_android/templates/toolchain_default.tmpl.cmake
index 47040dac2..343389998 100644
--- a/tools/cross_compile_android/templates/toolchain_default.tmpl.cmake
+++ b/tools/cross_compile_android/templates/toolchain_default.tmpl.cmake
@@ -26,8 +26,16 @@ set(QT_COMPILER_FLAGS "--target={{ plat_name }}-linux-android{{ api_level }} \
-I{{ target_python_path }}/include/python{{ python_version }} \
-Wno-unused-command-line-argument")
set(QT_COMPILER_FLAGS_RELEASE "-O2 -pipe")
-set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed \
- -L{{ qt_install_path }}/android_{{ qt_plat_name }}/lib \
+
+# FIXME
+# https://gitlab.kitware.com/cmake/cmake/-/issues/23670
+# The CMake Android toolchain does not allow RPATHS. Hence CMAKE_INSTALL_RPATH does not work.
+# Currently the linker flags are set directly as -Wl,-rpath='$ORIGIN' -Wl,-rpath='$ORIGIN/Qt/lib'
+# set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+# set(CMAKE_INSTALL_RPATH "$ORIGIN")
+
+set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,-rpath='$ORIGIN' -Wl,-rpath='$ORIGIN/Qt/lib' \
+ -Wl,--as-needed -L{{ qt_install_path }}/android_{{ qt_plat_name }}/lib \
-L{{ qt_install_path }}/android_{{ qt_plat_name }}/plugins/platforms \
-L{{ target_python_path }}/lib \
-lpython{{ python_version }}")