What does the -O2 option for gcc do? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












What does the -O2 option for gcc do?



eg. gcc -O2 file1.c -o file1.o







share|improve this question











closed as off-topic by slm♦ Jun 28 at 2:50


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – slm
If this question can be reworded to fit the rules in the help center, please edit the question.












  • There's a detailed page at gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html, or run gcc -c -Q -O2 --help=optimizers
    – Nick ODell
    Jun 28 at 2:18















up vote
-1
down vote

favorite












What does the -O2 option for gcc do?



eg. gcc -O2 file1.c -o file1.o







share|improve this question











closed as off-topic by slm♦ Jun 28 at 2:50


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – slm
If this question can be reworded to fit the rules in the help center, please edit the question.












  • There's a detailed page at gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html, or run gcc -c -Q -O2 --help=optimizers
    – Nick ODell
    Jun 28 at 2:18













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











What does the -O2 option for gcc do?



eg. gcc -O2 file1.c -o file1.o







share|improve this question











What does the -O2 option for gcc do?



eg. gcc -O2 file1.c -o file1.o









share|improve this question










share|improve this question




share|improve this question









asked Jun 28 at 2:12









CJ7

2171513




2171513




closed as off-topic by slm♦ Jun 28 at 2:50


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – slm
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by slm♦ Jun 28 at 2:50


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – slm
If this question can be reworded to fit the rules in the help center, please edit the question.











  • There's a detailed page at gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html, or run gcc -c -Q -O2 --help=optimizers
    – Nick ODell
    Jun 28 at 2:18

















  • There's a detailed page at gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html, or run gcc -c -Q -O2 --help=optimizers
    – Nick ODell
    Jun 28 at 2:18
















There's a detailed page at gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html, or run gcc -c -Q -O2 --help=optimizers
– Nick ODell
Jun 28 at 2:18





There's a detailed page at gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html, or run gcc -c -Q -O2 --help=optimizers
– Nick ODell
Jun 28 at 2:18











1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










The -O options turn on compiler optimization. From man gcc:



 -O2 Optimize even more. GCC performs nearly all supported
optimizations that do not involve a space-speed tradeoff. As
compared to -O, this option increases both compilation time and the
performance of the generated code.


For a list of the specific optimizations, refer to the manual pages.






share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    The -O options turn on compiler optimization. From man gcc:



     -O2 Optimize even more. GCC performs nearly all supported
    optimizations that do not involve a space-speed tradeoff. As
    compared to -O, this option increases both compilation time and the
    performance of the generated code.


    For a list of the specific optimizations, refer to the manual pages.






    share|improve this answer

























      up vote
      0
      down vote



      accepted










      The -O options turn on compiler optimization. From man gcc:



       -O2 Optimize even more. GCC performs nearly all supported
      optimizations that do not involve a space-speed tradeoff. As
      compared to -O, this option increases both compilation time and the
      performance of the generated code.


      For a list of the specific optimizations, refer to the manual pages.






      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        The -O options turn on compiler optimization. From man gcc:



         -O2 Optimize even more. GCC performs nearly all supported
        optimizations that do not involve a space-speed tradeoff. As
        compared to -O, this option increases both compilation time and the
        performance of the generated code.


        For a list of the specific optimizations, refer to the manual pages.






        share|improve this answer













        The -O options turn on compiler optimization. From man gcc:



         -O2 Optimize even more. GCC performs nearly all supported
        optimizations that do not involve a space-speed tradeoff. As
        compared to -O, this option increases both compilation time and the
        performance of the generated code.


        For a list of the specific optimizations, refer to the manual pages.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jun 28 at 2:17









        steeldriver

        30.9k34877




        30.9k34877












            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)