Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOWTO] Make Qt5 build on older systems without SSE2
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
rbergen
n00b
n00b


Joined: 10 Aug 2003
Posts: 51

PostPosted: Mon Nov 25, 2019 1:37 pm    Post subject: [HOWTO] Make Qt5 build on older systems without SSE2 Reply with quote

Make Qt5 build on older systems without SSE2

I recently acquired an old IBM ThinkPad with a Pentium3 CPU, and ran into problems while trying to build Qt5 packages. The problems are caused by the fact that regardless of what is set in CPU_FLAGS_X86, on Gentoo, Qt5 packages are built in such a way that they require SSE2 support. Pentium3 is a pre-SSE2 CPU, which led to illegal instruction (SIGILL) errors while trying to emerge packages depending on Qt5. This issue has been discussed in a previous topic.

The Qt5 build system includes a config option -no-sse2 to explicitly switch off Qt5 dependency on SSE2, but the Qt5 packages provided by Gentoo do not seem to provide any means to set this config option. At some point work-arounds have been included and then reverted by the Qt5 maintainers (as documented in bug 552942, for example), but as things stand there seems to be no supported way to address this. I am confident that the reasons for this are valid from a maintainer's perspective.

Because that did not change my wish to build Qt5 packages on my ThinkPad, I have created a way to do so, using facilities provided by the portage build system.
Concretely, it provides for the -no-sse2 option to be passed to the Qt5 build config when the sse2 CPU flag is not set in CPU_FLAGS_X86. It does this by running a post-sync script that applies a patch to the qt5-build.eclass file provided in the "gentoo" repository. The original version of the patch was attached to bug 648004, this version has been aligned with the current version of qt5-build.eclass. (Credits to Felix Tiede for the original patch, thanks to eccerr0r for bringing the bug back to memory.)

The script:
  • only executes for the gentoo repo;
  • checks for the existence of the patch file before doing anything;
  • first performs a dry run to verify that the patch can be applied successfully. Amongst others, this prevents the patch from being applied multiple times;
  • reports success or failure, when run.

I have created a tarball that can be downloaded here containing the repo post-sync script and the patch file.
After download, the files can be installed by using the following commands:
Code:
$ tar xvf qt5-nosse2-postsync.tar.gz
$ sudo cp -t /etc/portage/repo.postsync.d qt5-nosse2-patch qt5-build-eclass-nosse2.patch

The patch will then be applied after every following execution of emerge --sync.

The patch and script are also available on Github.

I'd like to note that:
  • Future changes to the qt5-build.eclass file as provided by Gentoo may make the patch unusable, although I will try to maintain the patch at least as long as my ThinkPad remains alive;
  • Not all Qt5 packages will build on older systems with the patch applied. QtWebEngine, for instance, will still refuse to build.
  • Script and patch are provided as-is, although I have taken care to try and prevent unintended side effects;
  • If you do run into problems, please reach out and I'll see what I can do to help.


Last edited by rbergen on Sat Aug 15, 2020 9:39 am; edited 4 times in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9832
Location: almost Mile High in the USA

PostPosted: Mon Nov 25, 2019 3:12 pm    Post subject: Reply with quote

I'd say this should be fixed in Gentoo-repository. The revert looks like it was automated because it was causing build problems, and unfortunately if nobody is maintaining this, these things slip through the cracks and the easiest fix is to revert.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
rbergen
n00b
n00b


Joined: 10 Aug 2003
Posts: 51

PostPosted: Mon Nov 25, 2019 3:22 pm    Post subject: Reply with quote

With apologies for my ignorance of due Gentoo process which may make this a stupid question, but is there anything I can or should do in response/relation to this? In a structural sense, I could verify if an alternative solution works or not. However, that is only true until my ThinkPad conks out, and by definition it is only an n=1 verification. I could follow argumentation that the use of pre-SSE2 x86-based CPUs is a scenario that has become too rare to be able to reliably support it from a maintainers perspective.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9832
Location: almost Mile High in the USA

PostPosted: Mon Nov 25, 2019 3:49 pm    Post subject: Reply with quote

You're not the only one with old hardware. I had a more sinister issue with sse2 in media-libs/libaom (I have a P4 without SSE3 but clearly has SSE2, but libaom will not build properly with SSE2. SSE3 is required to build as packaged by libaom.) -- this time the upstream f**ked up and would be harder for Gentoo to maintain a patch.

Worth to file a bug anyway with your patch and reference the revert bug. Perhaps there's already one, is this the same issue? https://bugs.gentoo.org/648004
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
rbergen
n00b
n00b


Joined: 10 Aug 2003
Posts: 51

PostPosted: Mon Nov 25, 2019 5:51 pm    Post subject: Reply with quote

Fair point re the old hardware, even though I didn't quite mean to imply that I am. As a matter of fact, after posting I remembered that due to the nature of the concept, in principle Gentoo is quite suited to squeeze the most out of whatever older machine one has available.

Thank you for the reference to the bug, that is indeed the same issue. I had stumbled upon it earlier, but then lost track of it again. I'll add a comment and my patch to it. The patch that is already attached to it follows CFLAGS, which I don't think is as "Gentoo" as this one. If nothing else, it will give people options.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54596
Location: 56N 3W

PostPosted: Mon Nov 25, 2019 7:57 pm    Post subject: Reply with quote

rbergen,

Does passing
Code:
CFLAGS="${CFLAGS} -fno-sse2" CXXFLAGS="${CXXFLAGS} -fno-lsse2"
on a per package basis fix it or does it get filtered out during the build?
I don't see any CFLAGS or CXXFLAGS filtering in qtcore-5.13.2.ebuild but it could be hidden in an eclass.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
rbergen
n00b
n00b


Joined: 10 Aug 2003
Posts: 51

PostPosted: Mon Nov 25, 2019 8:41 pm    Post subject: Reply with quote

Hi NeddySeagoon, the -fno-sse2 CFLAGS option is filtered out not by by an ebuild or eclass, but by upstream (in Qt5 config, to be precise). Unless -no-sse2 is explicitly passed to Qt5 config, any CFLAGS flag disabling use of SSE2 is overridden by a compiler flag set by Qt5 config that explicitly enables it. That is to say: upstream has decided to use an "SSE2, unless" approach, and since confirmed that this is deliberate due to the old age of pre-SSE2 x86 CPUs. All this means that in the qtcore ebuild, or the qt5-build eclass it derives from, something needs to translate to the -no-sse2 parameter being passed to Qt5 config when use of SSE2 is undesired or actually impossible.

Attached to bug 648004 that eccerr0r kindly pointed out, there are now two patches doing exactly this. One follows CFLAGS, the other CPU_FLAGS_X86. The latter is the one I included in the tarball mentioned in my original post in this topic, and attached to the bug, earlier today.

The bug was reported in February 2018 and is still marked as Unconfirmed. As the nature of the fix (in eclass, not ebuild) means that a per-package patch doesn't work and the problem reappears after every emerge --sync, to the point that I occasionally forget the eclass patch is needed, I've created and shared the above workaround. If and when a fix is indeed provided within the ebuilds/eclasses involved, that would obviously render this workaround obsolete.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9832
Location: almost Mile High in the USA

PostPosted: Mon Nov 25, 2019 10:15 pm    Post subject: Reply with quote

Should also go ahead and re-link in the revert bug 552942, just to let them know they actually pulled out a solution that used to work - not because it wasn't needed but rather because it no longer works with the build and a new one, as proposed, is needed.

Wasn't their fault, but it really is an issue...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
rbergen
n00b
n00b


Joined: 10 Aug 2003
Posts: 51

PostPosted: Mon Nov 25, 2019 10:24 pm    Post subject: Reply with quote

Thank you for the reminder, I had indeed omitted that. Set that straight just now.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum