From dd4bc2087964ba1f19c219563f925a4283643bff Mon Sep 17 00:00:00 2001 From: Fatih Uzunoglu <fuzun54@outlook.com> Date: Tue, 4 Mar 2025 21:33:41 +0200 Subject: [PATCH] qt: pass debug mode (if enabled) to qmake The behavior may be different when qmake generates the build files depending on the build mode. For example, with MinGW-w64 `-Wl,-s` (which stands for stripping symbol information) is added to the linker flags if build mode is (directed or assumed to be) release. If debug mode is not enabled, the default behavior is retained, which appears to be release. I specifically did not request release mode when debug is false, because debug being false does not necessarily mean release. --- configure.ac | 31 +++++++++++++++++++-------- modules/gui/qt/meson.build | 6 ++++++ modules/gui/qt/scripts/static_dirs.py | 9 ++++++-- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index a94bab310576..0a90da203464 100644 --- a/configure.ac +++ b/configure.ac @@ -4083,12 +4083,17 @@ AS_IF([test "${enable_qt}" != "no"], [ ],[ AC_MSG_CHECKING([for Qt libraries]) + qmake_additional_params="" + AS_IF([test "${enable_debug}" != "no"], [ + qmake_additional_params="$qmake_additional_params --debug" + ]) srcdir_abs=`(cd ${srcdir} && pwd -P)` QT_PKG_ERRORS=$(${PYTHON3} ${srcdir}/modules/gui/qt/scripts/static_dirs.py \ --qmake "${QMAKE6}" --qtconf "${with_qtconf}" \ --pro ${srcdir_abs}/modules/gui/qt/qt6.pro \ --builddir ${ac_pwd}/modules/gui/qt \ - --libs) + --libs \ + ${qmake_additional_params}) ac_status=$? AS_IF([test $ac_status = 0],[ @@ -4098,12 +4103,14 @@ AS_IF([test "${enable_qt}" != "no"], [ --qmake "${QMAKE6}" --qtconf "${with_qtconf}" \ --pro ${srcdir_abs}/modules/gui/qt/qt6.pro \ --builddir ${ac_pwd}/modules/gui/qt \ - --cflags) + --cflags \ + ${qmake_additional_params}) QT_LDFLAGS=$(${PYTHON3} ${srcdir}/modules/gui/qt/scripts/static_dirs.py \ --qmake "${QMAKE6}" --qtconf "${with_qtconf}" \ --pro ${srcdir_abs}/modules/gui/qt/qt6.pro \ --builddir ${ac_pwd}/modules/gui/qt \ - --ldflags) + --ldflags \ + ${qmake_additional_params}) AC_SUBST([QT_LIBS]) AC_SUBST([QT_CFLAGS]) AC_SUBST([QT_LDFLAGS]) @@ -4168,7 +4175,8 @@ AS_IF([test "${enable_qt}" != "no"], [ --qmake "${QMAKE6}" --qtconf "${with_qtconf}" \ --pro ${srcdir_abs}/modules/gui/qt/qtest.pro \ --builddir ${ac_pwd}/modules/gui/qt \ - --libs) 2>/dev/null + --libs \ + ${qmake_additional_params}) 2>/dev/null ac_status=$? AS_IF([test $ac_status = 0],[ AC_MSG_RESULT([yes]) @@ -4177,12 +4185,14 @@ AS_IF([test "${enable_qt}" != "no"], [ --qmake "${QMAKE6}" --qtconf "${with_qtconf}" \ --pro ${srcdir_abs}/modules/gui/qt/qtest.pro \ --builddir ${ac_pwd}/modules/gui/qt \ - --cflags) + --cflags \ + ${qmake_additional_params}) QT_QTEST_LDFLAGS=$(${PYTHON3} ${srcdir}/modules/gui/qt/scripts/static_dirs.py \ --qmake "${QMAKE6}" --qtconf "${with_qtconf}" \ --pro ${srcdir_abs}/modules/gui/qt/qtest.pro \ --builddir ${ac_pwd}/modules/gui/qt \ - --ldflags) + --ldflags \ + ${qmake_additional_params}) AC_SUBST([QT_QTEST_LIBS]) AC_SUBST([QT_QTEST_CFLAGS]) AC_SUBST([QT_QTEST_LDFLAGS]) @@ -4196,7 +4206,8 @@ AS_IF([test "${enable_qt}" != "no"], [ --qmake "${QMAKE6}" --qtconf "${with_qtconf}" \ --pro ${srcdir_abs}/modules/gui/qt/quicktest.pro \ --builddir ${ac_pwd}/modules/gui/qt \ - --libs) 2>/dev/null + --libs \ + ${qmake_additional_params}) 2>/dev/null ac_status=$? AS_IF([test $ac_status = 0],[ AS_IF([${PYTHON3} ${srcdir}/buildsystem/check_qml_module.py \ @@ -4210,12 +4221,14 @@ AS_IF([test "${enable_qt}" != "no"], [ --qmake "${QMAKE6}" --qtconf "${with_qtconf}" \ --pro ${srcdir_abs}/modules/gui/qt/quicktest.pro \ --builddir ${ac_pwd}/modules/gui/qt \ - --cflags) + --cflags \ + ${qmake_additional_params}) QT_QUICK_TEST_LDFLAGS=$(${PYTHON3} ${srcdir}/modules/gui/qt/scripts/static_dirs.py \ --qmake "${QMAKE6}" --qtconf "${with_qtconf}" \ --pro ${srcdir_abs}/modules/gui/qt/quicktest.pro \ --builddir ${ac_pwd}/modules/gui/qt \ - --ldflags) + --ldflags \ + ${qmake_additional_params}) AC_SUBST([QT_QUICK_TEST_LIBS]) AC_SUBST([QT_QUICK_TEST_CFLAGS]) AC_SUBST([QT_QUICK_TEST_LDFLAGS]) diff --git a/modules/gui/qt/meson.build b/modules/gui/qt/meson.build index 1b8ea6ad1749..a65618f2121c 100644 --- a/modules/gui/qt/meson.build +++ b/modules/gui/qt/meson.build @@ -989,6 +989,10 @@ if qt6_dep.found() qt_install_bin_directory = qt6_dep.get_variable(pkgconfig: 'bindir', configtool: '-query QT_INSTALL_BINS') qmake6 = find_program(qt_install_bin_directory + '/qmake6', required: true) if qmake6.found() + qmake_additional_params = [] + if get_option('buildtype') == 'debug' + qmake_additional_params += '--debug' + endif qtcflags = run_command( prog_python, meson.current_source_dir() / 'scripts/static_dirs.py', @@ -996,6 +1000,7 @@ if qt6_dep.found() '--pro', meson.current_source_dir() / 'qt6.pro', '--builddir', meson.current_build_dir(), '--cflags', + qmake_additional_params, check: false, ) if qtcflags.returncode() == 0 @@ -1010,6 +1015,7 @@ if qt6_dep.found() '--pro', meson.current_source_dir() / 'qt6.pro', '--builddir', meson.current_build_dir(), '--libs', '--ldflags', + qmake_additional_params, check: false, ) if qtlflags.returncode() == 0 diff --git a/modules/gui/qt/scripts/static_dirs.py b/modules/gui/qt/scripts/static_dirs.py index 0db02af05eba..054c2d67e373 100644 --- a/modules/gui/qt/scripts/static_dirs.py +++ b/modules/gui/qt/scripts/static_dirs.py @@ -12,10 +12,12 @@ import re import subprocess import sys -def call_qmake(qmake:str, qtconf, builddir, pro) -> str: +def call_qmake(qmake:str, qtconf, builddir, pro, debug:bool) -> str: if builddir and builddir != '' and not os.path.exists(builddir): os.makedirs(builddir) qmake_cmd = [ qmake ] + if debug: + qmake_cmd += ['CONFIG+=debug'] if qtconf and qtconf != '': qmake_cmd += [ '-qtconf', qtconf ] qmake_cmd += [pro, '-o', '-' ] @@ -55,12 +57,15 @@ if __name__ == "__main__": parser.add_argument("--ldflags", required=False, action='store_true', help="get the list of linker flags") + parser.add_argument("--debug", + required=False, action='store_true', + help="debug mode") args = parser.parse_args() result = '' sources = [ os.path.join(args.builddir, '.qmake.stash') ] in_sources = False - makefile = call_qmake(args.qmake, args.qtconf, args.builddir, args.pro) + makefile = call_qmake(args.qmake, args.qtconf, args.builddir, args.pro, args.debug) for line in makefile.splitlines(): if in_sources: l = line.strip() -- GitLab