LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-11-2004, 07:23 AM   #1
Ikebo
Member
 
Registered: Jun 2004
Location: Michigan, USA
Distribution: Ubuntu
Posts: 77

Rep: Reputation: 15
gcc multiple optimization levels ?


Does anyone know which optimization level gcc would default to if more than one was specified at the command line?

For example if the Makefile had -O set and your CFLAGS environment variable added -O3 to the end of the command, would gcc optimize at -O or -O3 ?

(edit: spelling errors)

Last edited by Ikebo; 07-11-2004 at 07:25 AM.
 
Old 07-11-2004, 01:13 PM   #2
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
short empirical test:

Code:
13:11 aluser@alf:~/C$ gcc -O -o hello1 hello.c
13:11 aluser@alf:~/C$ gcc -O -O3 -o hello2 hello.c
13:11 aluser@alf:~/C$ gcc -O3 -o hello3 hello.c
13:11 aluser@alf:~/C$ gcc -O3 -O -o hello4 hello.c
13:11 aluser@alf:~/C$ md5sum hello[1234]
9e6032ab46c4f40eabda899cb3e7171e  hello1
77378072c11c38178e985b9f7e63079b  hello2
77378072c11c38178e985b9f7e63079b  hello3
9e6032ab46c4f40eabda899cb3e7171e  hello4
13:12 aluser@alf:~/C$ gcc --version
gcc (GCC) 3.3.4 (Debian 1:3.3.4-2)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
looks like the last option wins.
 
Old 07-12-2004, 12:26 AM   #3
Ikebo
Member
 
Registered: Jun 2004
Location: Michigan, USA
Distribution: Ubuntu
Posts: 77

Original Poster
Rep: Reputation: 15
That is what I was thinking. That's an interesting way to test that. Thanks for the info.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc compilation optimization (Intel Centrino) IamDaniel Linux - Software 7 07-06-2005 08:24 PM
GCC 3.3.3 SMP optimization spaceman27 Linux - General 2 04-14-2005 04:47 AM
GCC 3.4/3.3 Optimization Flags monohouse Linux - Software 0 10-28-2004 11:48 AM
gcc optimization flags: rules of thumb elyk Linux - Software 3 08-05-2004 12:49 AM
GCC Processor Optimization ? Tomasfuego Programming 1 12-20-2003 03:59 PM


All times are GMT -5. The time now is 06:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration