Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [qt-build] How to differentiate host and target in source code/qmake?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 3 Posters 2.5k Views
  • 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.
  • myobyteM Offline
    myobyteM Offline
    myobyte
    wrote on last edited by myobyte
    #1

    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.HilkJ 1 Reply Last reply
    0
    • myobyteM Offline
      myobyteM Offline
      myobyte
      wrote on last edited by myobyte
      #7

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

      1 Reply Last reply
      0
      • myobyteM 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.HilkJ Online
        J.HilkJ Online
        J.Hilk
        Moderators
        wrote on last edited by
        #2

        @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


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

        myobyteM 1 Reply Last reply
        0
        • J.HilkJ J.Hilk

          @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")
              ...
          }
          
          myobyteM Offline
          myobyteM Offline
          myobyte
          wrote on last edited by myobyte
          #3

          @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
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            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

            myobyteM 1 Reply Last reply
            0
            • SGaistS SGaist

              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 ?

              myobyteM Offline
              myobyteM Offline
              myobyte
              wrote on last edited by myobyte
              #5

              @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
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                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
                1
                • myobyteM Offline
                  myobyteM Offline
                  myobyte
                  wrote on last edited by myobyte
                  #7

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

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved