Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved [qt-build] How to differentiate host and target in source code/qmake?

    Mobile and Embedded
    3
    7
    2087
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • myobyte
      myobyte last edited by myobyte

      How to differentiate host and target in source code/qmake?

      Both my host and target is linux-gcc, but with different versions.

      I would like to add some compiler/linker flags for target.
      For example, in order to use santizer, I have to add cc flags, and linker flags [to a proper place].

      However host toolchain version is different, which means that if I casually do something like this:
      https://codereview.qt-project.org/#change,43420
      Host tools build fails with unknown options.

      There are several problems here:

      1. I couldn't find a way to add target-only stuffs to qmake.
      2. I couldn't find a way to add linker flags to the designated place. (which is critical)
        qmake bootstrap process is tricky and surprising, and linker flags are ordered as a side effect of this process.

      In case of a native build, these problems is relatively easy to workaround.
      However for a cross build, these problems become nasty.

      J.Hilk 1 Reply Last reply Reply Quote 0
      • myobyte
        myobyte last edited by myobyte

        host_build {
        }
        Can be used, and is available quite early. (maybe around spec_pre.prf)

        1 Reply Last reply Reply Quote 0
        • J.Hilk
          J.Hilk Moderators @myobyte last edited by

          @myobyte
          hi,

          take a look at the qmake variables especially the subsection QMAKE_HOST it will allow you to specify the host:

          .arch	Host architecture
          .os	Host OS
          .cpu_count	Number of available cpus
          .name	Host computer name
          .version	Host OS version number
          .version_string	Host OS version string
          

          example from the docu:

          win32-g++:contains(QMAKE_HOST.arch, x86_64):{
              message("Host is 64bit")
              ...
          }
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

          Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          myobyte 1 Reply Last reply Reply Quote 0
          • myobyte
            myobyte @J.Hilk last edited by myobyte

            @J.Hilk said in [qt-build] How to differentiate host and target in source code/qmake?:

            @myobyte
            hi,

            take a look at the qmake variables especially the subsection QMAKE_HOST it will allow you to specify the host:

            I can't see how QMAKE_HOST can be used to add target-only flags in qmake.

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              Hi,

              Something's not clear here, do you mean that your are "cross-compiling" for the same architecture but with a different version of the compiler ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              myobyte 1 Reply Last reply Reply Quote 0
              • myobyte
                myobyte @SGaist last edited by myobyte

                @SGaist said in [qt-build] How to differentiate host and target in source code/qmake?:

                Hi,

                Something's not clear here, do you mean that your are "cross-compiling" for the same architecture but with a different version of the compiler ?

                I use both native build and cross build.
                The cross-compiling build is target=arm/arm64, while host=x86_x64.
                The native build is x86_64.

                Besides, the cc/ld options is not something that could be put into platform conf and forget.
                As far as I can recall, platform conf is loaded very early, and cc/ld options will appear at the begin of the gcc cmdline -- the wrong place that build will fail.

                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  Then you should use a scope matching your target. e.g. linux-beagleboard-g++ if you are using the BBB mkspec

                  linux-beagleboard-g++ {
                  message("BBB specifics")
                  }
                  

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply Reply Quote 1
                  • myobyte
                    myobyte last edited by myobyte

                    host_build {
                    }
                    Can be used, and is available quite early. (maybe around spec_pre.prf)

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post