Bug 224971 - devel/qt5-qmake: fails to build when CXX contains absolute path
Summary: devel/qt5-qmake: fails to build when CXX contains absolute path
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: kde
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2018-01-07 13:11 UTC by mikael.urankar
Modified: 2018-01-07 15:09 UTC (History)
2 users (show)

See Also:
rakuco: maintainer-feedback+


Attachments
Revert unintended change (511 bytes, patch)
2018-01-07 14:22 UTC, Jan Beich
rakuco: maintainer-approval-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mikael.urankar 2018-01-07 13:11:15 UTC
Hi,
I can't build qt5-qmake 5.9.3, the build error is as follow:

===>  Configuring for qt5-qmake-5.9.3
/bin/mkdir -p /wrkdirs/usr/ports/devel/qt5-qmake/work/qtbase-opensource-src-5.9.3
echo 'CMAKE_MODULE_TESTS = -' > /wrkdirs/usr/ports/devel/qt5-qmake/work/qtbase-opensource-src-5.9.3/.qmake.cache
echo 'QMAKE_LIBDIR_FLAGS = -L/wrkdirs/usr/ports/devel/qt5-qmake/work/qtbase-opensource-src-5.9.3/lib' >> /wrkdirs/usr/ports/devel/qt5-qmake/work/qtbase-opensource-src-5.9.3/.qmake.cache
/bin/sh: Syntax error: ")" unexpected (expecting "then")
*** Error code 2

it only happens when CXX is an absolute path:
make CXX=/usr/bin/c++ : doesn't build
make CXX=c++ : builds fine

I'm crossbuilding for armv7 where CXX is /nxb-bin/usr/bin/c++
poudriere jails -l
12armv7  12.0-CURRENT 1200054 r327541 arm.armv7

It's also reported on the forum:
https://forums.freebsd.org/threads/64025/#post-371716
Comment 1 mikael.urankar 2018-01-07 13:34:05 UTC
I see the following diff in the configure phase:
-platform freebsd-$(ccver="$(c++ --version)" (with make CXX=c++)
-platform c++ --version)" (with make CXX=/usr/bin/c++)
Comment 2 mikael.urankar 2018-01-07 13:49:42 UTC
The following patch fixes the problem for me but I don't know why the T modifier was added:
Index: bsd.qt.mk
===================================================================
--- bsd.qt.mk   (revision 458335)
+++ bsd.qt.mk   (working copy)
@@ -135,7 +135,7 @@
                                -demosdir ${PREFIX}/${QT_EXAMPLEDIR_REL}/demos
 . else
 CONFIGURE_ARGS+=-nomake examples -nomake tests \
-                               -platform ${QMAKESPEC:T} \
+                               -platform ${QMAKESPEC} \
                                -archdatadir ${PREFIX}/${QT_ARCHDIR_REL} \
                                -libexecdir ${PREFIX}/${QT_LIBEXECDIR_REL} \
                                -qmldir ${PREFIX}/${QT_QMLDIR_REL} \
Comment 3 Jan Beich freebsd_committer 2018-01-07 14:22:00 UTC
Created attachment 189491 [details]
Revert unintended change

/nxb-bin/usr/bin/c++ is a cross compiler created by a poudriere jail -x. On https://pkg-status.freebsd.org/ that'd be builders for mips, mips64, armv6, armv7. To reproduce on amd64 host the following would be enough:

  # -x (native-xtools) before FreeBSD 12.0 requires /usr/src to match jail
  $ svn checkout https://svn.freebsd.org/base/releng/11.1 /usr/src
  $ poudriere jail -cxj 111aarch64 -a arm64.aarch64 -v 11.1-RELEASE
  $ poudriere bulk -Ctj 111aarch64 devel/qt5-qmake

or

  $ poudriere jail -cxj head-aarch64 -a arm64.aarch64 -v head -m svn+https
  $ poudriere bulk -Ctj head-aarch64 devel/qt5-qmake

The build broke because CONFIGURE_ARGS now tries to chop directory off QMAKESPEC , something completely unnecessary given the expression never evaluates to any other string than "clang" or "g++".  However, qt5-qmake doesn't really respect CXX and calls clang++ instead which ends up being emulated via qemu-user-static rather than use cross-compiler.
Comment 4 Jan Beich freebsd_committer 2018-01-07 14:22:33 UTC
Oops, forgot to refresh the page in browser. ;)
Comment 5 commit-hook freebsd_committer 2018-01-07 15:03:53 UTC
A commit references this bug:

Author: rakuco
Date: Sun Jan  7 15:03:08 UTC 2018
New revision: 458339
URL: https://svnweb.freebsd.org/changeset/ports/458339

Log:
  Correctly pass -platform to qtbase's configure script when CXX is an absolute path.

  With the update to Qt 5.9.3, the configure script and qmake expect an mkspec
  name, not an absolute path, which is why r458293 switched to using
  ${QMAKESPEC:T}.

  However, the :T modifier breaks things when CXX is set to an absolute path
  instead of just "c++", QMAKE_COMPILER is a shell string that will be evaluated
  only after make invokes `configure' with CONFIGURE_ARGS. In other words, we end
  up turning something like

      $$(ccver="$$(/usr/bin/c++ --version)"; case "$$ccver" in *clang*) echo clang ;; *) echo g++ ;; esac)

  into

      /c++ --version)"; case "$$ccver" in *clang*) echo clang ;; *) echo g++ ;; esac)

  which is obviously invalid.

  We now just avoid being too smart and set a separate variable called
  QMAKESPECNAME, which contains only the mkspec name and that we use both when
  setting CONFIGURE_ARGS as well as to create QMAKESPEC.

  PR:		224971

Changes:
  head/Mk/bsd.qt.mk
Comment 6 Raphael Kubo da Costa freebsd_committer 2018-01-07 15:05:20 UTC
Comment on attachment 189491 [details]
Revert unintended change

The change was actually intended, it's just the implementation that was buggy. r458339 contains a better explanation for why this is needed.
Comment 7 Raphael Kubo da Costa freebsd_committer 2018-01-07 15:05:45 UTC
Thanks for the report, everything should be working fine now.