LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   gcc compilation optimization (Intel Centrino) (https://www.linuxquestions.org/questions/linux-software-2/gcc-compilation-optimization-intel-centrino-339719/)

IamDaniel 07-03-2005 08:11 PM

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 ?

linux-rulz 07-04-2005 12:28 AM

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.

IamDaniel 07-04-2005 07:52 PM

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?

linux-rulz 07-04-2005 09:46 PM

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.

IamDaniel 07-05-2005 07:18 PM

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?

foo_bar_foo 07-05-2005 11:39 PM

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

linux-rulz 07-06-2005 02:31 AM

Yep, do what foo_bar_foo said :p I was just guessing myself based on what Ubuntu does.

IamDaniel 07-06-2005 07:24 PM

thanks a lot guys...VERY comprehensive posts..


All times are GMT -5. The time now is 05:27 PM.