Uploaded image for project: 'Qbs ("Cubes")'
  1. Qbs ("Cubes")
  2. QBS-241

Add support for more optimization flags in GCC module

    XMLWordPrintable

Details

    Description

      Lets go to share/qbs/modules/cpp/gcc.js and look at the line #47. Currently, it looks as follows:

       
      var opt = ModUtils.moduleProperty(config, "optimization")
      if (opt === 'fast')
          args.push('-O2');
      if (opt === 'small')
          args.push('-Os');
      
      

      However, I'd love to rather see something like this:

       
      var opt = ModUtils.moduleProperty(config, "optimization")
      if (opt === 'aggressive')
          args.push('-O3');
          args.push('-fomit-frame-pointer');
          args.push('-funroll-loops');
          args.push('-flto');
      if (opt === 'fastest')
          args.push('-O3');
      if (opt === 'fast')
          args.push('-O2');
      if (opt === 'balanced')
          args.push('-O1');
      if (opt === 'small')
          args.push('-Os');
      if (opt === 'debug')
          args.push('-Og');
      

      I understand that there are no equivalents to some of these flags in other compilers, and therefore you might think that this somehow breaks the cross-compiler interface. However, you could simply map the same flags from Microsoft VC++, for example, to multiple values above. For instance:

       
      var opt = ModUtils.moduleProperty(config, "optimization")
      if (opt === 'aggressive')
          args.push('/O2');
          // I can't remember exactly now,
          // but probably something could be added here too...
      if (opt === 'fastest')
          args.push('/O2');
      if (opt === 'fast')
          args.push('/O2');
      if (opt === 'balanced')
          args.push('/Od');
      if (opt === 'small')
          args.push('/O1');
      if (opt === 'debug')
          args.push('/Od');
      

      You could also add more properties concerning optimization, for example something like this:

      var opt = ModUtils.moduleProperty(config, "platformSpecificOptimization")
      if (opt === 'native')
          args.push('-march=native');
      

      Looking forward to your feedback.

      Best regards.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            haroogan hwgexohr
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes