Bug 231542 - devel/qt5-qmake: fix build with gcc-based architectures
Summary: devel/qt5-qmake: fix build with gcc-based architectures
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: kde
URL:
Keywords:
Depends on:
Blocks: 231584 231963
  Show dependency treegraph
 
Reported: 2018-09-21 12:57 UTC by Piotr Kubaj
Modified: 2018-10-14 08:04 UTC (History)
5 users (show)

See Also:
tcberner: maintainer-feedback+


Attachments
patch (3.19 KB, patch)
2018-09-21 12:57 UTC, Piotr Kubaj
no flags Details | Diff
v2 (3.63 KB, patch)
2018-09-22 17:49 UTC, Piotr Kubaj
no flags Details | Diff
v3 (3.98 KB, patch)
2018-09-25 17:34 UTC, Piotr Kubaj
no flags Details | Diff
v4 (4.22 KB, patch)
2018-09-26 13:06 UTC, Piotr Kubaj
no flags Details | Diff
v5 (4.17 KB, patch)
2018-09-26 13:18 UTC, Piotr Kubaj
pkubaj: maintainer-approval? (kde)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Kubaj freebsd_committer 2018-09-21 12:57:58 UTC
Created attachment 197300 [details]
patch

Qt5 forcibly sets gcc and g++ as CC and CXX if they exist, which breaks compilation on architectures that don't use LLVM. This patch fixes this issue.

Tested on amd64 with clang and on powerpc64.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2018-09-21 13:01:20 UTC
I'll test this soon.

Probably I'll make the following change:

.if ${ARCH:Mmips*} || ${ARCH:Mpowerpc*} || ${ARCH} == sparc64

to keep the sorting correct.
Comment 2 Adriaan de Groot freebsd_committer 2018-09-21 13:46:27 UTC
Are you saying that there is no gcc and g++ available in base? Or that qmake picks gcc and g++, which are way too old in base and it should be using (ports?) gcc7 instead?

This still leaves open the various issues around Qt not respecting CC / CXX .. but that's a far, far more invasive patch (because Qt totally isn't set up for that). 

So if Mark says "this works", it's got my blessing, though.
Comment 3 Piotr Kubaj freebsd_committer 2018-09-21 13:51:49 UTC
(In reply to Adriaan de Groot from comment #2)
There are gcc and g++ in base, but it's only version 4.2.1. Qt5 needs C++11-compatible compiler.
Comment 4 Piotr Kubaj freebsd_committer 2018-09-22 17:49:42 UTC
Created attachment 197358 [details]
v2

While making patches for next Qt5 ports, I noticed the same patches are necessary for each port.

Fix it better by patching Mk/Uses/qt-dist.mk.

Individual patches will still be needed for each port's Makefile (only USES will be modified).
Comment 5 Tobias C. Berner freebsd_committer 2018-09-25 04:44:53 UTC
Moin moin

In extra-patch-mkspecs_common_gcc-base.conf you should probably substitute in the value of $LOCALBASE and not assume it's /usr/local


mfg Tobias
Comment 6 Piotr Kubaj freebsd_committer 2018-09-25 17:34:58 UTC
Created attachment 197494 [details]
v3

The $PREFIX issue is fixed in this patch.
Comment 7 Tobias C. Berner freebsd_committer 2018-09-25 18:03:07 UTC
Is the build time dependency on lang/gcc providing gcc7 implicit by the USES=compiler ? 

I.e. shouldn't gcc7/g++7 be subbed via "gcc%%GCC_DEFAULT%%" and  "g++%%GCC_DEFAULT%%" or something? [same for the 7 in the linker path]
Comment 8 Piotr Kubaj freebsd_committer 2018-09-26 13:06:51 UTC
Created attachment 197513 [details]
v4

GCC_DEFAULT is now used instead of hard-coding 7.

Test compilation of qt5-qmake works.
Comment 9 Piotr Kubaj freebsd_committer 2018-09-26 13:18:43 UTC
Created attachment 197515 [details]
v5

Small fixes.
Comment 10 Mark Linimon freebsd_committer freebsd_triage 2018-09-27 11:17:33 UTC
(In reply to Piotr Kubaj from comment #9)

This still isn't general enough.  What if someone wants to test building with (for example) gcc9?

I'm working on an improved patch.

Also, now that it affects something in Mk/, it's most likely going to need an exp-run.
Comment 11 Piotr Kubaj freebsd_committer 2018-09-27 12:10:43 UTC
(In reply to Mark Linimon from comment #10)
I did a quick test.

/etc/make.conf:
DEFAULT_VERSIONS=       gcc=8

$ make -V GCC_DEFAULT
8

I tried to build it, it uses GCC 8.
===>  Applying FreeBSD patches for qt5-qmake-5.11.1
/usr/bin/sed -i "" 's|%%LOCALBASE%%|/usr/local|' /tmp/usr/local/poudriere/ports/default/devel/qt5-qmake/work/qtbase-everywhere-src-5.11.1/mkspecs/common/gcc-base.conf
/usr/bin/sed -i "" 's|%%GCC_DEFAULT%%|8|' /tmp/usr/local/poudriere/ports/default/devel/qt5-qmake/work/qtbase-everywhere-src-5.11.1/mkspecs/common/gcc-base.conf  /tmp/usr/local/poudriere/ports/default/devel/qt5-qmake/work/qtbase-everywhere-src-5.11.1/mkspecs/common/g++-base.conf
/usr/bin/sed -i "" -e "/DEFAULT_LIBDIRS=/ s,\\\\\"\\\\n,\\\\n/usr/local/lib&,"  /tmp/usr/local/poudriere/ports/default/devel/qt5-qmake/work/qtbase-everywhere-src-5.11.1/configure
===>   qt5-qmake-5.11.1 depends on executable: gmake - found
===>   qt5-qmake-5.11.1 depends on package: pkgconf>=1.3.0_1 - found
===>   qt5-qmake-5.11.1 depends on file: /usr/local/bin/python2.7 - found
===>   qt5-qmake-5.11.1 depends on executable: gcc8 - not found
Comment 12 Tobias C. Berner freebsd_committer 2018-09-28 05:02:34 UTC
(In reply to Mark Linimon from comment #10)
Technically you can only have one gcc set to build Qt. The one used in devel/qt5-qmake and written there in the qmake.conf used, which we have two of: freebsd-clang and freebsd-gcc. 

So if you want it general you need to expose a new configuration variable
QT_GCC_VERSION
which defaults to GCC_DEFAULT or can be overridden via make.conf (and will take affect in qt5-qmake as the other will use qmake to get the compiler).

Then also add explicit build & run depends on lang/gcc${QT_GCC_VERSION}


But... That also needs to work well with compiler.mk and not on clang architectures (as I fear many fancy errors).


Mfg Tobias
Comment 13 Mark Linimon freebsd_committer freebsd_triage 2018-10-06 23:35:57 UTC
(In reply to Tobias C. Berner from comment #12)

There is already a way to add the depends.

What about adding, right after

  +.if ${ARCH:Mmips*} || ${ARCH:Mpowerpc*} || ${ARCH} == sparc64

USE_GCC= yes

?

Mk/bsd.gcc.mk is processed after all of USES_*.

As for the "work well on compiler.mk", the extra patches are already dependent on that ARCH conditional; and the patchfiles are only for gcc-related files.

I'll test a build with this in a bit.
Comment 14 commit-hook freebsd_committer 2018-10-14 08:02:46 UTC
A commit references this bug:

Author: tcberner
Date: Sun Oct 14 08:01:25 UTC 2018
New revision: 482034
URL: https://svnweb.freebsd.org/changeset/ports/482034

Log:
  qt5: Fix build on GCC based architectures.

  PR:		231584
  PR:		231677
  PR:		231685
  PR:		231830
  PR:		231955
  PR:		231905
  PR:		231892
  PR:		231684
  PR:		231958
  PR:		231960
  PR:		231818
  PR:		231542
  PR:		231860
  PR:		231681
  PR:		231963
  PR:		231891
  PR:		231966
  PR:		231904
  PR:		231676
  PR:		231819
  PR:		231956
  PR:		231680
  PR:		231957
  PR:		231903
  PR:		231901
  PR:		231667
  PR:		231861
  Submitted by:	 Piotr Kubaj <pkubaj@anongoth.pl>

Changes:
  head/Mk/Uses/qt-dist.mk
  head/accessibility/qt5-speech/Makefile
  head/comms/qt5-sensors/Makefile
  head/comms/qt5-serialport/Makefile
  head/databases/qt5-sql/Makefile
  head/devel/qt5/Makefile.sqldrivers
  head/devel/qt5/files/extra-patch-mkspecs_common_g++-base.conf
  head/devel/qt5/files/extra-patch-mkspecs_common_gcc-base.conf
  head/devel/qt5-assistant/Makefile
  head/devel/qt5-buildtools/Makefile
  head/devel/qt5-concurrent/Makefile
  head/devel/qt5-core/Makefile
  head/devel/qt5-dbus/Makefile
  head/devel/qt5-designer/Makefile
  head/devel/qt5-help/Makefile
  head/devel/qt5-linguisttools/Makefile
  head/devel/qt5-location/Makefile
  head/devel/qt5-qdbus/Makefile
  head/devel/qt5-qmake/Makefile
  head/devel/qt5-script/Makefile
  head/devel/qt5-scripttools/Makefile
  head/devel/qt5-testlib/Makefile
  head/devel/qt5-uitools/Makefile
  head/graphics/qt5-imageformats/Makefile
  head/graphics/qt5-opengl/Makefile
  head/graphics/qt5-svg/Makefile
  head/lang/qt5-qml/Makefile
  head/multimedia/qt5-multimedia/Makefile
  head/net/qt5-network/Makefile
  head/print/qt5-printsupport/Makefile
  head/sysutils/qt5-qtpaths/Makefile
  head/textproc/qt5-xml/Makefile
  head/textproc/qt5-xmlpatterns/Makefile
  head/www/qt5-webchannel/Makefile
  head/x11/qt5-x11extras/Makefile
  head/x11-toolkits/qt5-gui/Makefile
  head/x11-toolkits/qt5-quick/Makefile
  head/x11-toolkits/qt5-quickcontrols/Makefile
  head/x11-toolkits/qt5-quickcontrols2/Makefile
  head/x11-toolkits/qt5-virtualkeyboard/Makefile
  head/x11-toolkits/qt5-widgets/Makefile
Comment 15 Tobias C. Berner freebsd_committer 2018-10-14 08:04:08 UTC
Committed. Thanks