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?

[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.6k 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.
  • M Offline
    M Offline
    myobyte
    wrote on 21 Mar 2017, 06:32 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 1 Reply Last reply 21 Mar 2017, 07:16
    0
    • M Offline
      M Offline
      myobyte
      wrote on 22 Mar 2017, 14:46 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
      • M myobyte
        21 Mar 2017, 06:32

        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 Offline
        J Offline
        J.Hilk
        Moderators
        wrote on 21 Mar 2017, 07:16 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.

        M 1 Reply Last reply 21 Mar 2017, 08:13
        0
        • J J.Hilk
          21 Mar 2017, 07:16

          @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")
              ...
          }
          
          M Offline
          M Offline
          myobyte
          wrote on 21 Mar 2017, 08:13 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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 21 Mar 2017, 08:18 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

            M 1 Reply Last reply 21 Mar 2017, 14:35
            0
            • S SGaist
              21 Mar 2017, 08:18

              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 ?

              M Offline
              M Offline
              myobyte
              wrote on 21 Mar 2017, 14:35 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
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 21 Mar 2017, 21:11 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
                • M Offline
                  M Offline
                  myobyte
                  wrote on 22 Mar 2017, 14:46 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

                  4/7

                  21 Mar 2017, 08:18

                  • Login

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