Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#35982 closed defect (wontfix)

qt4-mac & Qt4 portgroup: clang spec for qmake

Reported by: mojca (Mojca Miklavec) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: michaelld (Michael Dickens), ryandesign (Ryan Carsten Schmidt), bgschaid@…, cooljeanius (Eric Gallager)
Port: qt4-mac

Description

This issue came up during inclusion of Goldendict port which currently uses:

configure.cmd       ${qt_qmake_cmd}
configure.pre_args
configure.universal_args-delete --disable-dependency-tracking

variant universal {}

build.args          CC="${configure.cc} [get_canonical_archflags cc]" \
                    CXX="${configure.cxx} [get_canonical_archflags cxx]" \
                    LINK="${configure.cxx} [get_canonical_archflags cxx]" \
                    XXXOBJC="${configure.cc} [get_canonical_archflags cc]"

The problem is that ${qt_qmake_cmd} from Qt4 portgroup doesn't take sufficient care of choosing the desired compiler. qmake can take a spec file as an argument (something like qmake -spec macx-llvm) and the spec file takes care of setting the compiler and its flags.

This is the list of currently installed spec files:

/opt/local/share/qt4/mkspecs/macx-g++/qmake.conf
/opt/local/share/qt4/mkspecs/macx-g++40/qmake.conf
/opt/local/share/qt4/mkspecs/macx-g++42/qmake.conf
/opt/local/share/qt4/mkspecs/macx-icc/qmake.conf
/opt/local/share/qt4/mkspecs/macx-llvm/qmake.conf
/opt/local/share/qt4/mkspecs/macx-pbuilder/qmake.conf
/opt/local/share/qt4/mkspecs/macx-xcode/qmake.conf
/opt/local/share/qt4/mkspecs/macx-xlc/qmake.conf

I actually miss macx-clang spec being present upstream, but even then I'm not absolutely sure if this would cover all the cases. Most probably there is some further tweaking needed to convince qmake to work as desired (choose the right compiler and flags, possibly handling universal builds as well).

Change History (6)

comment:1 Changed 12 years ago by bgschaid@…

Cc: bgschaid@… added

Cc Me!

comment:2 Changed 12 years ago by michaelld (Michael Dickens)

I just came across this ticket, and I'm wondering what exactly it is you want to get done? Add macx-clang to the mkspecs? qt4-mac sort of uses macx-g++ for both Apple's GCC and Clang, and it seems to work OK. Qt5 provides full separated support for Clang, from what I've seen, though I haven't gotten further than that in building Qt5. I have no great interest in back-porting macx-clang form Qt5 to Qt4, since it works OK as is -- it could probably be better, but then QMake allows the user to specify pretty much anything needed if/as desired/needed. Hence, if Goldendict need to specify a -spec file, that can be programmed in. If you want to use special Clang features, that can also be programmed in. I'm just not clear what the goal is for this ticket.

comment:3 Changed 12 years ago by mojca (Mojca Miklavec)

The main "problem" is that programs using qmake don't respect MacPorts' compiler settings. There is no special need to actually provide the spec file, but I thought that this would be the easiest solution. The file /opt/local/share/qt4/mkspecs/macx-llvm/qmake.conf is very short and simple (ok, I don't understand what all those compiler flags mean). It includes a couple of other conf files (like common/llvm.conf), but all of them are relatively straightforward.

I just checked the sources though (see r97316). It seems that Ryan added reinplace on the generated Makefile to fix the choice of the compiler:

post-configure {
    # For some reason the Makefile qmake generates hardcodes the compiler
    # that qt4-mac was made with as the one used to build lionsupport.o.
    # Replace it with $(CC) which we set up for the correct compiler and
    # -arch flags with the build.args below.
    reinplace -E "/-o build\\/lionsupport.o/s/^(\[\[:space:\]\]+)\[^\[:space:\]\]+/\\1\\$\\(CC\\)/" ${worksrcpath}/Makefile
}

(To explain the For some reason: qmake always hardcodes the compiler. Compiler can be switched by using a different spec file, but there might be other options I'm not aware of.)

Given that a workaround has been found, that version 5 with a fix is out and if no other ports have a problem with this, maybe you could close the ticket as "won't fix".

comment:4 Changed 12 years ago by michaelld (Michael Dickens)

Resolution: wontfix
Status: newclosed

I believe you can add to the QMake command "QMAKE_CC=\${CC}" (and, so forth for CXX, OBJC, OBJCXX as needed) to override what QMake provides by default. Or, as you say, one can choose a different spec file if it exists though the results may be odd since Qt4 doesn't really use alternative specs beyond g++-macx; it's a "catch all".

comment:5 Changed 12 years ago by mojca (Mojca Miklavec)

Thank you. I have tried it now. Exporting an environmental variable doesn't have any influence, but something like

qmake QMAKE_CC=/opt/local/bin/clang-mp-3.2

seems to work. The architecture flags are yet another topic.

comment:6 Changed 12 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

Note: See TracTickets for help on using tickets.