Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-97728

ld: cannot find atomic when cross-compiling app with qmake

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 6.2.0
    • Fix Version/s: None
    • Component/s: Build tools: qmake
    • Labels:
      None

      Description

      I was cross-compile Qt-6.2.0 and try build qmake-base apps, unfortunately link fail with message ld: cannot find atomic.
      I was inspect gererated Makefile and found strage - LIBS contain atomic

      .........
      LIBS          = $(SUBLIBS) -L/tmp/firmware/staging_sml723x/usr/lib -L../qmap_parser -lqmapparser /tmp/firmware/staging_sml723x/qt6_bmips4380/lib/libQt6Gui.so /tmp/firmware/staging_sml723x/qt6_bmips4380/lib/libQt6Core.so -latomic -lpthread atomic  -Wl,-rpath-link,/tmp/firmware/staging_sml723x/usr/lib
      ............

      After this I was run qmake with debug and I was receive follow output

      ..........
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:20: LD_USES := LIBATOMIC
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:21: entering loop for nu 
      over LIBATOMIC
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:21: loop iteration "LIBAT
      OMIC"
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:21: entering block
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:22: NOT
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:22: evaluating test funct
      ion "defined"
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:22: calling built-in defi
      ned(QMAKE_LIBS_LIBATOMIC, var)
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:22: test function returne
      d true
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:22: AND
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:23: skipped test function
       "error"
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:25: calling built-in $$ev
      al(QMAKE_LIBDIR_LIBATOMIC)
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:25: QMAKE_LIBDIR := /tmp/
      firmware/staging_sml723x/usr/lib
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:27: condition "android" i
      s false
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:27: taking 'else' branch
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:27: entering block
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:31: condition "debug" is 
      false
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:31: taking 'else' branch
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:31: entering block
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:34: calling built-in $$ev
      al(QMAKE_LIBS_LIBATOMIC_RELEASE)
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:34: calling built-in $$ev
      al(QMAKE_LIBS_LIBATOMIC)
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:34: LIBS := /tmp/firmware/staging_sml723x/qt6_bmips4380/lib/libQt6Core.so -lpthread atomic
      DEBUG 1: /tmp/firmware/staging_sml723x/qt6_bmips4380/mkspecs/features/qmake_use.prf:34: leaving block, okey=true
      ............

      I was inspect Qt-generated files and found
      libQt6Core.prl

      QMAKE_PRL_BUILD_DIR = /tmp/firmware/build-sml723x/qtbase-6.2.0/src/corelib
      QMAKE_PRL_TARGET = libQt6Core.so
      QMAKE_PRL_CONFIG = shared
      QMAKE_PRL_VERSION = 6.2.0
      QMAKE_PRL_LIBS = -latomic
      QMAKE_PRL_LIBS_FOR_CMAKE = -latomic

      libQt6Network.prl

      QMAKE_PRL_BUILD_DIR = /tmp/firmware/build-sml723x/qtbase-6.2.0/src/network
      QMAKE_PRL_TARGET = libQt6Network.so
      QMAKE_PRL_CONFIG = shared
      QMAKE_PRL_VERSION = 6.2.0
      QMAKE_PRL_LIBS = $$[QT_INSTALL_LIBS]/libQt6Core.so -latomic
      QMAKE_PRL_LIBS_FOR_CMAKE = $$[QT_INSTALL_LIBS]/libQt6Core.so;-latomic

      qt_lib_core_private.pri

      QT.core_private.VERSION = 6.2.0
      QT.core_private.name = QtCore
      QT.core_private.module =
      QT.core_private.libs = $$QT_MODULE_LIB_BASE
      QT.core_private.includes = $$QT_MODULE_INCLUDE_BASE/QtCore/6.2.0 $$QT_MODULE_INCLUDE_BASE/QtCore/6.2.0/QtCore
      QT.core_private.frameworks = 
      QT.core_private.depends = core
      QT.core_private.uses = 
      QT.core_private.module_config = v2 internal_module
      QT.core_private.enabled_features = clock-gettime doubleconversion futimens glibc inotify linkat mimetype-database system-pcre2 poll_ppoll sha3-fast hijricalendar datetimeparser forkfd_pidfd pcre2 reduce_exports posix_fallocate alloca_h alloca system-zlib gui network printsupport sql testlib widgets xml dlopen relocatable cross_compile force_debug_info largefile enable_new_dtags
      QT.core_private.disabled_features = system-doubleconversion futimes getauxval getentropy glib icu journald system-libb2 poll_pollts poll_poll poll_select qqnx_pps renameat2 slog2 statx syslog backtrace lttng etw android-style-assets gc_binaries use_bfd_linker use_gold_linker use_lld_linker private_tests debug reduce_relocations sse2 sse3 ssse3 sse4_1 sse4_2 avx f16c avx2 avx512f avx512er avx512cd avx512pf avx512dq avx512bw avx512vl avx512ifma avx512vbmi aesni rdrnd rdseed shani mips_dsp mips_dspr2 neon arm_crc32 arm_crypto alloca_malloc_h stack-protector-strong zstd dbus dbus-linked libudev intelcet
      QMAKE_LIBS_LIBATOMIC = atomic
      QMAKE_LIBS_LIBRT = 
      QMAKE_INCDIR_PCRE2 = /tmp/firmware/staging_sml723x/usr/include
      QMAKE_LIBS_PCRE2 = -L"/tmp/firmware/staging_sml723x/usr/lib" -lpcre2-16

      Look like qt_lib_core_private.pri is a source incorrect library name.

      Toolchain include atomic support via external library

      $ find toolchain/mipsel-rtk-linux-uclibc/ -name *atomic.so*
      toolchain/mipsel-rtk-linux-uclibc/mipsel-rtk-linux-uclibc/lib/libatomic.so
      toolchain/mipsel-rtk-linux-uclibc/mipsel-rtk-linux-uclibc/lib/libatomic.so.1.2.0
      toolchain/mipsel-rtk-linux-uclibc/mipsel-rtk-linux-uclibc/lib/libatomic.so.1
      toolchain/mipsel-rtk-linux-uclibc/mipsel-rtk-linux-uclibc/sysroot/lib/libatomic.so
      toolchain/mipsel-rtk-linux-uclibc/mipsel-rtk-linux-uclibc/sysroot/lib/libatomic.so.1.2.0
      toolchain/mipsel-rtk-linux-uclibc/mipsel-rtk-linux-uclibc/sysroot/lib/libatomic.so.1

      My workaround - modify qt_lib_core_private.pri after Qt install

      sed 's/atomic/-latomic/' --in-place=.org $(QT_INSTALL_DIR)/mkspecs/modules/qt_lib_core_private.pri

      This is work, but I think this is can be solved in Qt sources, files cmake/QtGenerateLibHelpers.cmake and cmake/QtGenerateLibPri.cmake.
      Also QMAKE_LIBS_LIBATOMIC look useless in qt_lib_core_private.pri because libQt6Core.prl contain information about libatomic.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qtbuildsystem Qt Build System Team
            Reporter:
            imb Kirill Brilliantov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes