Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Changing compiler flags for a single unit

Changing compiler flags for a single unit

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 183 Views 4 Watching
  • 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote last edited by
    #1

    Using qmake files and building with GCC 13.3.0 + Qt 6.5 or later and std:c++17, how can I change the optimization flags in a release build for a single .cpp file in my project from -O2 to -O3?

    Is there a "Qt way", or do i have to manually edit the makefile before building?

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote last edited by
      #2

      I think you will get better input if you explain your reasoning as to why you want that.
      Also, if the cpp file in question is not Q_OBJECT/MOC dependent then you could compile it separately (thru build or manually) and just add it as a link time object. There are project file vars for adding external stuff at linktime.

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      R 1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        I think you will get better input if you explain your reasoning as to why you want that.
        Also, if the cpp file in question is not Q_OBJECT/MOC dependent then you could compile it separately (thru build or manually) and just add it as a link time object. There are project file vars for adding external stuff at linktime.

        R Offline
        R Offline
        Robert Hairgrove
        wrote last edited by Robert Hairgrove
        #3

        @Kent-Dorfman said in Changing compiler flags for a single unit:

        I think you will get better input if you explain your reasoning as to why you want that.

        Actually, in the meantime I am leaning towards just compiling everything with -O3 as it is much simpler to set up.

        Also, if the cpp file in question is not Q_OBJECT/MOC dependent then you could compile it separately (thru build or manually) and just add it as a link time object. There are project file vars for adding external stuff at linktime.

        Unfortunately, it does inherit from QObject -- this runs in a background thread, does a lot of heavy lifting (which is why it needs to be as fast as possible) but it does need to communicate with its controller which runds in the main thread.

        If we assume that I know what I am doing, how could it be done? It's actually fairly common in the real world to mix compilation units having different optimization settings. I just don't know how to do this with qmake.

        (EDIT: Most of the caveats involve floating-point calculations, especially when it involves compiling with -Ofast on GCC -- that's not an issue here).

        SGaistS 1 Reply Last reply
        0
        • R Robert Hairgrove

          @Kent-Dorfman said in Changing compiler flags for a single unit:

          I think you will get better input if you explain your reasoning as to why you want that.

          Actually, in the meantime I am leaning towards just compiling everything with -O3 as it is much simpler to set up.

          Also, if the cpp file in question is not Q_OBJECT/MOC dependent then you could compile it separately (thru build or manually) and just add it as a link time object. There are project file vars for adding external stuff at linktime.

          Unfortunately, it does inherit from QObject -- this runs in a background thread, does a lot of heavy lifting (which is why it needs to be as fast as possible) but it does need to communicate with its controller which runds in the main thread.

          If we assume that I know what I am doing, how could it be done? It's actually fairly common in the real world to mix compilation units having different optimization settings. I just don't know how to do this with qmake.

          (EDIT: Most of the caveats involve floating-point calculations, especially when it involves compiling with -Ofast on GCC -- that's not an issue here).

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by
          #4

          @Robert-Hairgrove Hi,

          I think you should be able to do what you want using a "custom compiler".

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

          R 1 Reply Last reply
          2
          • SGaistS SGaist

            @Robert-Hairgrove Hi,

            I think you should be able to do what you want using a "custom compiler".

            R Offline
            R Offline
            Robert Hairgrove
            wrote last edited by
            #5

            @SGaist Thank you ... this is exactly what I was looking for!

            1 Reply Last reply
            0
            • R Robert Hairgrove has marked this topic as solved

            • Login

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