Bug 12906 - qt PrefixPath is wrong on 2020.05-rc1
Summary: qt PrefixPath is wrong on 2020.05-rc1
Status: RESOLVED FIXED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: Peter Seiderer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-16 10:39 UTC by Joonas Harjumäki
Modified: 2020-05-17 19:27 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joonas Harjumäki 2020-05-16 10:39:13 UTC
The PrefixPath is /. It should be /usr. For example QML modules are under /usr/qml not /qml.

Head of 'qtdiag --no-gl':

Qt 5.14.2 (arm-little_endian-ilp32-eabi-hardfloat shared (dynamic) release build; by GCC 7.5.0) on "eglfs"
OS: Buildroot 2020.05-rc1 [linux version 5.4.3]

Architecture: arm; features:

Environment:

Features: QT_NO_EXCEPTIONS

Library info:
  PrefixPath: /
  DocumentationPath: /doc
  HeadersPath: /include/qt5
  LibrariesPath: /lib
  LibraryExecutablesPath: /libexec
  BinariesPath: /bin
  PluginsPath: /lib/qt/plugins
  ImportsPath: /imports
  Qml2ImportsPath: /qml
  ArchDataPath: /
  DataPath: /
  TranslationsPath: /translations
  ExamplesPath: /lib/qt/examples
  TestsPath: /tests
  SettingsPath: /etc/xdg
Comment 1 Peter Seiderer 2020-05-16 15:50:22 UTC
Tested with the following defconfig (on Raspberry Pi 3 B+):

BR2_arm=y
BR2_cortex_a53=y
BR2_ARM_FPU_NEON_VFPV4=y
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_SYSTEM_DHCP="eth0"
BR2_GENERATE_LOCALE="en_US"
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi3/post-image.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="--add-miniuart-bt-overlay"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,4f2a4cc501c428c940549f39d5562e60404ac4f7)/linux-4f2a4cc501c428c940549f39d5562e60404ac4f7.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b bcm2710-rpi-3-b-plus bcm2710-rpi-cm3"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_STRACE=y
BR2_PACKAGE_DEJAVU=y
BR2_PACKAGE_QT5=y
BR2_PACKAGE_QT5BASE_EXAMPLES=y
BR2_PACKAGE_QT5BASE_OPENGL_LIB=y
BR2_PACKAGE_QT5BASE_EGLFS=y
BR2_PACKAGE_QT5BASE_DEFAULT_QPA="eglfs"
BR2_PACKAGE_QT5BASE_FONTCONFIG=y
BR2_PACKAGE_QT5BASE_GIF=y
BR2_PACKAGE_QT5BASE_JPEG=y
BR2_PACKAGE_QT5BASE_PNG=y
BR2_PACKAGE_QT5QUICKCONTROLS=y
BR2_PACKAGE_QT5QUICKCONTROLS2=y
BR2_PACKAGE_QT5TOOLS=y
BR2_PACKAGE_QT5TOOLS_QTDIAG=y
BR2_PACKAGE_QT5TOOLS_QTPATHS=y
BR2_PACKAGE_QT5TOOLS_QTPLUGININFO=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_USERLAND=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="256M"
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y

$ qtdiag
Unable to query physical screen size, defaulting to 100 dpi.
To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Qt 5.14.2 (arm-little_endian-ilp32-eabi-hardfloat shared (dynamic) release build; by GCC 8.4.0) on "eglfs" 
OS: Buildroot 2020.05-rc1 [linux version 4.19.113-v7]

Architecture: arm; features: Neon

Environment:

Features: QT_NO_EXCEPTIONS QT_NO_OPENSSL

Library info:
  PrefixPath: /usr
  DocumentationPath: /usr/doc
  HeadersPath: /usr/include/qt5
  LibrariesPath: /usr/lib
  LibraryExecutablesPath: /usr/libexec
  BinariesPath: /usr/bin
  PluginsPath: /usr/lib/qt/plugins
  ImportsPath: /usr/imports
  Qml2ImportsPath: /usr/qml
  ArchDataPath: /usr
  DataPath: /usr
  TranslationsPath: /usr/translations
  ExamplesPath: /usr/lib/qt/examples
  TestsPath: /usr/tests
  SettingsPath: /usr/etc/xdg
[...]

Examples e.g. quickcontrols2 gallery runs fine:

$ /usr/lib/qt/examples/quickcontrols2/gallery/gallery

The path problem existed in buildroot in some beforehand/RFC version bumps of qt (5.13.x/5.14.1) but not since the 5.14.2 one was applied, for the beforehand ones I used the following patch/hack:

From 628a79a8f45c7a872f967161a41f599852be4c5e Mon Sep 17 00:00:00 2001
From: Peter Seiderer <ps.report@gmx.net>
Date: Mon, 17 Feb 2020 13:06:29 +0100
Subject: WIP: package/qt5base: add 0005-Hack-to-fix-Qml2Imports-path.patch


diff --git a/package/qt5/qt5base/5.14.1/0005-Hack-to-fix-Qml2Imports-path.patch b/package/qt5/qt5base/5.14.1/0005-Hack-to-fix-Qml2Imports-path.patch
new file mode 100644
index 0000000000..b4f56fa4d1
--- /dev/null
+++ b/package/qt5/qt5base/5.14.1/0005-Hack-to-fix-Qml2Imports-path.patch
@@ -0,0 +1,20 @@
+--- qt5base-5.14.1/configure.pri-orig	2020-02-05 23:00:13.132750848 +0100
++++ qt5base-5.14.1/configure.pri	2020-02-05 23:00:55.893562740 +0100
+@@ -703,7 +703,7 @@
+         $$printInstallPath(Binaries, bindir, bin) \
+         $$printInstallPath(Plugins, plugindir, plugins) \
+         $$printInstallPath(Imports, importdir, imports) \
+-        $$printInstallPath(Qml2Imports, qmldir, qml) \
++        $$printInstallPath(Qml2Imports, qmldir, usr/qml) \
+         $$printInstallPath(ArchData, archdatadir, .) \
+         $$printInstallPath(Data, datadir, .) \
+         $$printInstallPath(Translations, translationdir, translations) \
+@@ -804,7 +804,7 @@
+     processQtPath("", libexecdir, $${archdata_pfx}$$DEFAULT_LIBEXEC)
+     processQtPath("", plugindir, $${archdata_pfx}plugins)
+     processQtPath("", importdir, $${archdata_pfx}imports)
+-    processQtPath("", qmldir, $${archdata_pfx}qml)
++    processQtPath("", qmldir, $${archdata_pfx}usr/qml)
+     processQtPath("", sysconfdir, $$DEFAULT_SYSCONFDIR)
+     $$have_hostprefix {
+         processQtPath(host, hostbindir, bin)

Did you do a complete re-build (make clean && make)? If the problem is
reproducible please provide a config/defconfig file for your configuration...
Comment 2 Joonas Harjumäki 2020-05-16 16:12:53 UTC
Yes, I did complete rebuild. Qt 5.14 introduced relocatable builds (https://www.qt.io/blog/qt-is-relocatable). I was able to restore correct paths by configuring BR2_PACKAGE_QT5BASE_CUSTOM_CONF_OPTS="-no-feature-relocatable".

Head of qt5base-5.14.2/config.summary

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for: devices/linux-buildroot-g++ (arm, CPU features: <none>)
Target compiler: gcc 7.5.0
Configuration: cross_compile compile_examples enable_new_dtags largefile shared shared release c++11 c++14 c++1z concurrent dbus reduce_exports release_tools stl
Build options:
  Mode ................................... release; optimized tools
  Optimize release build for size ........ no
  Building shared libraries .............. yes
  Using C standard ....................... C11
  Using C++ standard ..................... C++17
  Using ccache ........................... no
  Using new DTAGS ........................ yes
  Relocatable ............................ no
  Using precompiled headers .............. no
  Using LTCG ............................. no
  Target compiler supports:
    NEON ................................. no
  Build parts ............................ libs

Peter Seiderer: Did you build relocatable qt?
Comment 3 Peter Seiderer 2020-05-16 16:38:28 UTC
No custom changes (see provided defconfig)...

$ cat build/qt5base-5.14.2/config.summary 
Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for: devices/linux-buildroot-g++ (arm, CPU features: neon crc32)
Target compiler: gcc 8.4.0
Configuration: cross_compile compile_examples enable_new_dtags largefile neon shared shared release c++11 c++14 c++1z concurrent reduce_exports release_tools stl
Build options:
  Mode ................................... release; optimized tools
  Optimize release build for size ........ no
  Building shared libraries .............. yes
  Using C standard ....................... C11
  Using C++ standard ..................... C++17
  Using ccache ........................... no
  Using new DTAGS ........................ yes
  Relocatable ............................ yes
  Using precompiled headers .............. no
[...]
Comment 4 Joonas Harjumäki 2020-05-16 20:41:08 UTC
I don't have any dynamic linker configuration files, eg. /etc/ld.so.conf, /etc/ld.so.cache. In system search path /lib is before /usr/lib. libQt5Core.so is installed in /lib/libQt5Core.so and /usr/lib/libQt5Core.so. Relocatable Qt determines PrefixPath by going up towards root from the directory of the loaded libQt5Core and chooses directory that contains 'lib' as PrefixPath (https://github.com/qt/qtbase/blob/3a6d8df5219653b043bd642668cee193f563ec84/src/corelib/global/qlibraryinfo.cpp#L623). If Qt is non-relocatable, value of -prefix config switch is used as PrefixPath. qtdiag reports correct PrefixPath if it is forced to use /usr/lib/libQt5Core.so. Should buildroot configure qt as non-relocatable?

LD_LIBRARY_PATH=/usr/lib qtdiag --no-gl

Qt 5.14.2 (arm-little_endian-ilp32-eabi-hardfloat shared (dynamic) release build; by GCC 7.5.0) on "eglfs"
OS: Buildroot 2020.02 [linux version 5.4.3]

Architecture: arm; features:

Environment:

Features: QT_NO_EXCEPTIONS

Library info:
  PrefixPath: /usr
  DocumentationPath: /usr/doc
  HeadersPath: /usr/include/qt5
  LibrariesPath: /usr/lib
  LibraryExecutablesPath: /usr/libexec
  BinariesPath: /usr/bin
  PluginsPath: /usr/lib/qt/plugins
  ImportsPath: /usr/imports
  Qml2ImportsPath: /usr/qml
  ArchDataPath: /usr
  DataPath: /usr
  TranslationsPath: /usr/translations
  ExamplesPath: /usr/lib/qt/examples
  TestsPath: /usr/tests
  SettingsPath: /usr/etc/xdg
Comment 5 Peter Seiderer 2020-05-17 07:25:40 UTC
You have BR2_ROOTFS_MERGED_USR enabled in your configurtion?
Comment 6 Joonas Harjumäki 2020-05-17 07:41:54 UTC
Yes
Comment 7 Peter Seiderer 2020-05-17 10:36:52 UTC
Thanks for report and suggested fix! Buildroot suggested patch can be found under [1]...

[1] http://patchwork.ozlabs.org/project/buildroot/patch/20200517102823.15132-1-ps.report@gmx.net
Comment 8 Yann E. MORIN 2020-05-17 19:27:21 UTC
Joonas, All,

Fixed with Peter's commit:
https://git.buildroot.org/buildroot/commit/?id=6491ca40f8374b310a08ceb904e2a274408739af

Thanks for the report.

Regards,
Yann E. MORIN.