LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-03-2005, 08:11 PM   #1
IamDaniel
Member
 
Registered: Mar 2003
Location: Sungai Petani
Distribution: Slackware
Posts: 143

Rep: Reputation: 15
gcc compilation optimization (Intel Centrino)


Most often whenever we compile some packages, from the INSTALL or README file, we read the 3 simple line:

Quote:
./configure
make
make install
but somehow, possibly more advanced options available for us to tweak...

the question is how to optimize the compilation for certain architecture ?

for example, Intel Pentium Centrino ?
 
Old 07-04-2005, 12:28 AM   #2
linux-rulz
Member
 
Registered: Dec 2004
Distribution: Windows XP Home, Ubuntu Hoary
Posts: 584

Rep: Reputation: 30
Generally, when you first install your distro, it tells gcc to optimize stuff for your architecure.

For instance, on my Ubuntu, gcc automatically optimizes stuff for k7 (Athlon XP) instead of just 686 or 386.

When you type make for installing something, watch the output and it should say something along the lines of

--march=pentium4

Or something like that.
 
Old 07-04-2005, 07:52 PM   #3
IamDaniel
Member
 
Registered: Mar 2003
Location: Sungai Petani
Distribution: Slackware
Posts: 143

Original Poster
Rep: Reputation: 15
hmm....for example,

Code:
#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi
PKG=$TMP/package-sudo

VERSION=1.6.8p6
ARCH=${ARCH:-i486}
BUILD=${BUILD:-1}

if [ ! -d $TMP ]; then
  mkdir -p $TMP # location to build the source
fi
rm -rf $PKG
mkdir -p $PKG

if [ "$ARCH" = "i386" ]; then
  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2"
fi
.....
reference from sudo.SlackBuild

The line, ARCH=${ARCH:-i486}
what was that means? Sorry, I'm not a scripting guru..But I guess it's a subshell and defined as new variable for inside this script (correct me if I was wrong).

Then followed by the,
if...fi block
Does modern computers should compile with i686 for both -march=i686 and -mcpu=i686 ?

Also, how to categorize the Intel Centrino type (possible closed to Mobile)? i686 or mobile or any `cpu-type' name?
 
Old 07-04-2005, 09:46 PM   #4
linux-rulz
Member
 
Registered: Dec 2004
Distribution: Windows XP Home, Ubuntu Hoary
Posts: 584

Rep: Reputation: 30
Well, it will most likely compile against the 686 architecure. I'm not quite sure how to make it compile against P4, or if that will work on a Centrino.
 
Old 07-05-2005, 07:18 PM   #5
IamDaniel
Member
 
Registered: Mar 2003
Location: Sungai Petani
Distribution: Slackware
Posts: 143

Original Poster
Rep: Reputation: 15
Does 686 arch' covered all the recent Intel class precessors? with exceptional 64 bit cpu?

which means, Intel Mobile + Intel Mobile Centrino (Dothan) + Intel Mobile (Banias) + Intel Pentium 4 HT + possibly others also categorize in this category?
 
Old 07-05-2005, 11:39 PM   #6
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
hi,
go yo the manual for your version of gcc
gcc-v
here
http://gcc.gnu.org/onlinedocs/
look under
Hardware Models and Configurations -> Intel 386 and AMD x86-64 Options
there you will find the proper setting
for the modern compilers the proper setting for centrino is
-march=pentium-m
or
-mtune=pentium-m
all the older settings from pentium3 down to i386 will run on the centrino
centrino is a small pentium3 so code compiled for pentium4 and above wont work

you don't need -mcpu is old and does nothing now

so hack that script and put
SLKCFLAGS="-O2 -march=pentium-m"
or if you want to be brave
SLKCFLAGS="-O3 -march=pentium-m"
and forget about it using those arch readings from the kernel

for packages that don't use SLKFLAGS put this in your ~/.bashrc
export CFLAGS='-O2 -march=pentium-m'
export CXXFLAGS=$CFLAGS

first time before you log in with the new file you can read it in with
source ~/.bashrc
it will get read automatically later and most packages will pick up the values
if something doesn't work bacause of the optimizations
unset CFLAGS
unset CXXFLAGS
and then do the configure again and you will get default optimizations
 
Old 07-06-2005, 02:31 AM   #7
linux-rulz
Member
 
Registered: Dec 2004
Distribution: Windows XP Home, Ubuntu Hoary
Posts: 584

Rep: Reputation: 30
Yep, do what foo_bar_foo said I was just guessing myself based on what Ubuntu does.
 
Old 07-06-2005, 07:24 PM   #8
IamDaniel
Member
 
Registered: Mar 2003
Location: Sungai Petani
Distribution: Slackware
Posts: 143

Original Poster
Rep: Reputation: 15
thanks a lot guys...VERY comprehensive posts..
 
  


Reply



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 3.3.3 SMP optimization spaceman27 Linux - General 2 04-14-2005 03:47 AM
GCC 3.4/3.3 Optimization Flags monohouse Linux - Software 0 10-28-2004 10:48 AM
gcc optimization flags: rules of thumb elyk Linux - Software 3 08-04-2004 11:49 PM
gcc multiple optimization levels ? Ikebo Programming 2 07-11-2004 11:26 PM
GCC Processor Optimization ? Tomasfuego Programming 1 12-20-2003 02:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:56 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
Open Source Consulting | Domain Registration