Package: qmake6
Version: 6.4.2+dfsg-21
Followup-For: Bug #1060267
X-Debbugs-Cc: maar...@railconnected.eu

Dear Maintainer,

Cross building with qmake6 fails due to QT_HOST_LIBEXECS having a wrong
value. For completeness: QT_HOST_LIBEXECS refers to the config file
variable HostLibraryExecutables, and is internally referred to as
QMakeLibraryInfo::HostLibraryExecutablesPath and
QMakeLibraryInfo::LibraryPathQMakeExtras::HostLibraryExecutablesPath in
the qmake source code.

The issue is that HostLibraryExecutables defaults to the *default* value
of LibraryExecutables. LibraryExecutables is set to the right value (a
concatenation of Prefix + LibraryExecutables with the value
"/usr/lib/qt6/libexec"), but its default value is Prefix + "libexec".

As the cross build config /usr/lib/<multiarch>/qt6/qt6.conf specifies
Prefix as "/usr", the default of LibraryExecutables, and hence the
default of HostLibraryExecutables, is now "/usr/libexec", which is the
wrong value.

The simple fix is to supply the value of HostLibraryExecutables in
/usr/lib/<multiarch>/qt6/qt6.conf explicitly:

...
HostLibraryExecutables=lib/qt6/libexec
...

The better fix would possibly be, upstream, to take the *actual* value
of LibraryExecutables as the default value for HostLibraryExecutables,
and not the default value.

This bug was observed on bookworm, trixie and sid, when cross building
on x86-64 for armel, and on each of these releases it was fixed by
adding the proposed line to qt6.conf. A diff to the source package:

*** qt6-base-6.4.2+dfsg/debian/qt.conf.in.orig    2024-02-13 03:28:31.532410597 
+0100
--- qt6-base-6.4.2+dfsg/debian/qt.conf.in    2024-02-13 03:28:38.716318378 +0100
***************
*** 10,15 ****
--- 10,16 ----
  HostLibraries=lib/@DEB_HOST_MULTIARCH@
  Libraries=lib/@DEB_HOST_MULTIARCH@
  LibraryExecutables=lib/qt6/libexec
+ HostLibraryExecutables=lib/qt6/libexec
  Plugins=lib/@DEB_HOST_MULTIARCH@/qt6/plugins
  Qml2Imports=lib/@DEB_HOST_MULTIARCH@/qt6/qml
  Settings=/etc/xdg

For completeness I include a script below to demonstrate the problem and
the fix in a self-contained manner; save as gen-mre.sh and run: <<EOF

#!/bin/bash

# This script provides a minimum reproducible example of an issue plus
# fix in the qmake package. It creates an schroot environment and shows
# the failing command, and demonstrates the fix. It can be used to
# quickly test various Debian releases.
# It can be run multiple times without problems.
# Be warned that the resulting schroot environment is easily 2+ Gb in size.

# refuse to be sourced
return 0 2>/dev/null

if [ $# -lt 1 ]
then
    echo "Usage: $0 [bookwork|testing|sid|...]"
    exit
fi

if ! which debootstrap > /dev/null
then
    echo "Cannot find debootstrap; check \$PATH."
    echo "Refusing to run sbuild-createchroot."
    exit
fi

BASEDIST=$1

MAX_LINE_LEN=$(stty size |awk '{print ($2>80)?$2:80}')
echo "Truncating lines to $MAX_LINE_LEN"

{ # All output is fed through sed to indent subprocess output; lines starting
  # with @@ are not indented.

CHROOT_BASENAME=qt6-mre-$BASEDIST
echo "@@Looking for schroots named source.*$CHROOT_BASENAME..."
CHROOT=$(schroot -l |egrep "source.*$CHROOT_BASENAME")
if [ "$CHROOT" == "" ]
then
    echo "Not found. Creating schroot..."
    sbuild-createchroot --merged-usr --chroot-prefix=$CHROOT_BASENAME \
        $BASEDIST $CHROOT_BASENAME
    CHROOT=$(schroot -l |egrep "source.*$CHROOT_BASENAME")
    if [ "$CHROOT" == "" ]
    then
        echo "Failed to create chroot, bailing out"
        exit
    fi
    echo "schroot created with name $CHROOT"
else
    echo "Found $CHROOT"
fi

run() {
    echo "\$ $@"
    schroot --chroot $CHROOT --directory /tmp -- "$@"
}

echo "@@Testing schroot..."
run cat /etc/debian_chroot

echo "@@Adding architecture armel..."
run sh -c "dpkg --add-architecture armel && apt-get -q update"

echo "@@Installing base utils..."
run apt-get -q -y install qt6-base-dev qmake6 libqt6core6 libqt6network6
run apt-get -q -y install qt6-base-dev:armel qmake6:armel libqt6core6:armel \
                          libqt6network6:armel
run apt-get -q -y install g++-arm-linux-gnueabi file wget

echo "@@Fetching demo application..."
for fn in http.pro authenticationdialog.ui httpwindow.cpp httpwindow.h main.cpp
do
    
URL=https://raw.githubusercontent.com/qt/qtbase/dev/examples/network/http/$fn
    run wget -nc --no-verbose $URL
done

echo "@@Performing a simple build on the demo project..."
run sh -c "ls -al && qmake6 && make -j"
echo "@@Resulting binary:"
run ls -alh http
run file http
echo "@@The above is expected to show a valid native binary"

QT6CONF=/usr/lib/arm-linux-gnueabi/qt6/qt6.conf
LINE=HostLibraryExecutables=lib/qt6/libexec
echo "@@Removing proposed patch (will give an error on first run, no worries)"
run cp -v $QT6CONF.orig $QT6CONF
echo "@@Backing up unpatched $QT6CONF..."
run cp -v $QT6CONF $QT6CONF.orig

echo "@@Cross compiling for armel, without patch..."
run sh -c "arm-linux-gnueabi-qmake6 && make"
echo "@@The above is expected to give an error '/usr/libexec/uic: not found'"

echo "This is fixed by adding the following line to $QT6CONF"
echo "   $LINE"
run sh -c "echo \"$LINE\" >> $QT6CONF"

echo "@@Cross compiling for armel, with patch..."
run sh -c "make clean && arm-linux-gnueabi-qmake6 && make -j"
echo "@@Resulting binary:"
run ls -alh http
run file http
echo "@@The above is expected to show a valid ARM binary of ~79K"

} 2>&1 | sed -e "s/^/   /;s/^   @@//;s/^\(.\{$MAX_LINE_LEN\}\).*/\1/"

EOF

The script shows various results (failing/succeeding builds) and
indicates what is expected.

Kind regards, Maarten

-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: armel

Kernel: Linux 4.19.0-10-amd64 (SMP w/8 CPU threads)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to 
C.UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages qmake6 depends on:
ii  perl        5.38.2-3
ii  qmake6-bin  6.4.2+dfsg-21

qmake6 recommends no packages.

qmake6 suggests no packages.

-- no debconf information

Reply via email to