Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 927691 - dev-qt/qtcore:5, dev-qt/qtbase:6: break by merge-usr on musl
Summary: dev-qt/qtcore:5, dev-qt/qtbase:6: break by merge-usr on musl
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Qt Bug Alias
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: usrmerge, usrmerge-fixes
  Show dependency tree
 
Reported: 2024-03-24 10:48 UTC by 12101111
Modified: 2024-04-03 12:48 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 12101111 2024-03-24 10:48:37 UTC
Qt has a feature called relocatable build which is enabled by default: https://www.qt.io/blog/qt-is-relocatable

On musl system with merged-usr, qt will use '/' as install prefix, instead of '/usr', and break some programs.

> falkon
Fatal: The following paths were searched for Qt WebEngine resources:
  /share/qt6/resources
  /share/qt6
  /usr/bin
  /home/<$USER>/.falkon
but could not find any.
You may override the default search paths by using QTWEBENGINE_RESOURCES_PATH environment variable.
zsh: abort (core dumped)  falkon




Reproducible: Always

Steps to Reproduce:
Test code1: (test.cpp)
```
#include <QLibraryInfo>
#include <iostream>

int main() {
#if QT_VERSION >= 0x060000
  auto data_path = QLibraryInfo::path(QLibraryInfo::DataPath).toStdString();
#else
  auto data_path = QLibraryInfo::location(QLibraryInfo::DataPath).toStdString();
#endif
  std::cout << data_path << std::endl;
}
```

Build against qt6: `c++ -isystem /usr/include/qt6 -isystem /usr/include/qt6/QtCore -lQt6Core test.cpp -o test`
Build against qt5: `c++ -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -lQt5Core test.cpp -o test`

Output on glibc system with merged-usr: `/usr/share/qt6` and `/usr/share/qt5`
Output on musl system with merged-usr: `/share/qt6` and `/share/qt5`

On musl system with merged-usr:
> ldd test | grep Qt6
	libQt6Core.so.6 => /lib/libQt6Core.so.6 (0x7ff9ce238000)
> ldd test | grep Qt5
	libQt5Core.so.5 => /lib/libQt5Core.so.5 (0x7f7e8bcb8000)

On glibc system with merged-usr:
> ldd test | grep Qt
	libQt6Core.so.6 => /usr/lib64/libQt6Core.so.6 (0x00007f71d8aaa000)
> ldd test | grep Qt
	libQt5Core.so.5 => /usr/lib64/libQt5Core.so.5 (0x00007f21894e3000)

Qt use following code to detect runtime prefix:

Test Code2: (path.cpp)
```
#include <QLibraryInfo>
#include <dlfcn.h>
#include <iostream>

int main() {
  Dl_info info;
  int result =
      dladdr(reinterpret_cast<void *>(&QLibraryInfo::isDebugBuild), &info);
  if (result > 0 && info.dli_fname) {
    std::cout << info.dli_fname << std::endl;
  }
}
```

Build against qt6: `c++ -isystem /usr/include/qt6 -isystem /usr/include/qt6/QtCore -lQt6Core path.cpp -o path`
Build against qt5: `c++ -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -lQt5Core path.cpp -o path`

Output on glibc system with merged-usr: `/usr/lib64/libQt6Core.so.6` `/usr/lib64/libQt5Core.so.5`
Output on musl system with merged-usr: `/lib/libQt6Core.so.6` and `/lib/libQt5Core.so.5`

Possible solution
1. Disable relocatable feature of qt
2. Remove `/lib` in /etc/ld-musl-x86_64.path on system with merged-usr. This file is generated by ldconfig from musl ebuild
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-24 10:50:35 UTC
Thank you for the analysis.
Comment 2 Ionen Wolkens gentoo-dev 2024-03-24 11:20:05 UTC
(In reply to 12101111 from comment #0)
> Possible solution
> 1. Disable relocatable feature of qt
> 2. Remove `/lib` in /etc/ld-musl-x86_64.path on system with merged-usr. This
> file is generated by ldconfig from musl ebuild
I see little reason not to do both.

Relocatable feature seems pointless for our use case, and don't see why not disable it for everyone, and then unnecessary duplication with the /lib symlink should be avoided too.

Just to be sure, did you actually try to turn it off to see if *did* help? Aka, I assume this does it on dev-qt/qtbase:

    MYCMAKEARGS="-DQT_FEATURE_relocatable=OFF"

Should show:
    relocatable ............................ no

(unsure if I'll bother experimenting with this myself w/ musl beside just turning it off)

Also don't know if other dev-qt/* need to be rebuilt as well, not that it matters that much given I could do this change only in Qt6.6.3 anyway and save people from revbumps (currently due to release tomorrow, and won't wait all that long to stabilize it given 6.7.0 will take over in ~testing).
Comment 3 Ionen Wolkens gentoo-dev 2024-03-24 11:25:01 UTC
(In reply to Ionen Wolkens from comment #2)
> (unsure if I'll bother experimenting with this myself w/ musl beside just
> turning it off)
On that note, I hope it won't affect finding resources during tests which uses Qt from a temporary location and lot of these tests tend to expect Qt to be already installed on top.
Comment 4 12101111 2024-03-24 11:39:51 UTC
It seems rebuild dev-qt/* is not needed.
Just disable relocatable in dev-qt/qtcore:5 and dev-qt/qtbase:6 then rebuild them.
Comment 5 Ionen Wolkens gentoo-dev 2024-03-24 11:46:07 UTC
(In reply to 12101111 from comment #4)
> It seems rebuild dev-qt/* is not needed.
> Just disable relocatable in dev-qt/qtcore:5 and dev-qt/qtbase:6 then rebuild
> them.
Oh 5 is affected too? Never really looked at Qt5 at all, so I typically don't touch it myself.
Comment 6 Ionen Wolkens gentoo-dev 2024-03-24 12:00:53 UTC
(In reply to Ionen Wolkens from comment #5)
> (In reply to 12101111 from comment #4)
> > It seems rebuild dev-qt/* is not needed.
> > Just disable relocatable in dev-qt/qtcore:5 and dev-qt/qtbase:6 then rebuild
> > them.
> Oh 5 is affected too? Never really looked at Qt5 at all, so I typically
> don't touch it myself.
And right, you gave examples for that too. Kind of forgot while writing a reply though :)

I'll handle it for qtbase with 6.6.3, and may revbump 6.6.2 at same time as the bump for stable users given likely more users doing migration with 23.0 now.

I'll leave qtcore to asturm or whomever else want to look at that though.
Comment 7 Ionen Wolkens gentoo-dev 2024-03-24 12:59:46 UTC
(In reply to Ionen Wolkens from comment #3)
> (In reply to Ionen Wolkens from comment #2)
> > (unsure if I'll bother experimenting with this myself w/ musl beside just
> > turning it off)
> On that note, I hope it won't affect finding resources during tests which
> uses Qt from a temporary location and lot of these tests tend to expect Qt
> to be already installed on top.
Well, seems already getting some failing tests due to relocatable=OFF (or at least when qtbase is not already installed) -- albeit barely tried and unsure for scope given low on resources to run Qt builds atm.

May skip if it's just a few, otherwise unsure yet.
Comment 8 Ionen Wolkens gentoo-dev 2024-03-24 15:54:57 UTC
(In reply to Ionen Wolkens from comment #7)
> (In reply to Ionen Wolkens from comment #3)
> > (In reply to Ionen Wolkens from comment #2)
> > > (unsure if I'll bother experimenting with this myself w/ musl beside just
> > > turning it off)
> > On that note, I hope it won't affect finding resources during tests which
> > uses Qt from a temporary location and lot of these tests tend to expect Qt
> > to be already installed on top.
> Well, seems already getting some failing tests due to relocatable=OFF (or at
> least when qtbase is not already installed) -- albeit barely tried and
> unsure for scope given low on resources to run Qt builds atm.
> 
> May skip if it's just a few, otherwise unsure yet.
Well, after a full run of dev-qt/* tests, turns out it didn't affect anything but 3 tests on qtbase and other tests are still able to find everything fine, so will just skip these.

Keeping this locally until tomorrow to do together with the 6.6.3 bump still tho.
Comment 9 Larry the Git Cow gentoo-dev 2024-03-25 22:10:26 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4d83f8f0859e6060cb191e2b7b66259937369f20

commit 4d83f8f0859e6060cb191e2b7b66259937369f20
Author:     Ionen Wolkens <ionen@gentoo.org>
AuthorDate: 2024-03-24 11:37:58 +0000
Commit:     Ionen Wolkens <ionen@gentoo.org>
CommitDate: 2024-03-25 22:08:06 +0000

    dev-qt/qtbase: disable relocatable builds
    
    And skip 3 tests that newly fail to find some resources (or at least,
    if qtbase is not already installed). Not worth keeping enabled over
    these.
    
    Meant to wait for 6.6.3 to merge this to lessen rebuilds, but looks
    like it may(?) be delayed again.
    
    Bug: https://bugs.gentoo.org/927691
    Signed-off-by: Ionen Wolkens <ionen@gentoo.org>

 dev-qt/qtbase/{qtbase-6.6.2.ebuild => qtbase-6.6.2-r1.ebuild}        | 5 +++++
 dev-qt/qtbase/qtbase-6.6.9999.ebuild                                 | 5 +++++
 .../qtbase/{qtbase-6.7.0_rc2.ebuild => qtbase-6.7.0_rc2-r1.ebuild}   | 5 +++++
 dev-qt/qtbase/qtbase-6.7.9999.ebuild                                 | 5 +++++
 dev-qt/qtbase/qtbase-6.9999.ebuild                                   | 5 +++++
 5 files changed, 25 insertions(+)