How do I specify i686 arch/cpu when compiling?
I see all the packages with "i686" in their names, and whenever I create one it always has "i386" instead (on a P4). How do I compile with i686 optimized code? I have done many searched on LQ and Google, but none of it (so far) has actually showed me how (instead just said it can be done).
|
You've to specify that in the ./configure step (or directly in the gcc if you're building your own program or don't use a configure script).
Take a look here for flags: http://linuxreviews.org/howtos/compiling/ And quoting a configure script: " Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. " Hope this helps. |
With some software, better is to unset CFLAGS and CXXFLAGS before configure and compile as
it set the optimization level for you and some other optimizing options, I used to export my CFLAGS as this : -O2 -march=athlon-xp -pipe -fomit-frame-pointer but I saw a warning at configure time that advised me to not use custom CFLAGS, so I unset them (export CFLAGS= ) and at compile time I realized that mplayer uses -O4 as optimisation level ! (and it uses -pipe end -fomit-frame-pointer) |
Something like this
CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer" |
Okay... so would I be correct in assuming "./configure march=i686" is what I'm looking for in this case? According to that howto, mcpu (or mtune) will just default to whatever march is. Thanks again,
|
No, something like ./configure CFLAGS="-march=i686" but be carefull becaue this will override program default flags...
Another way could be to edit the Makefile generated by configure adding the flag. |
That makes a lot of sense now. Is there a way to automatically set my system to compile with i686 every time? Or will the make file of each package always override that?
|
Yea, adding CFLAGS to ./configure will override which is bad for whatever your building. Setting it as global is what you want. Then it will just add your Cflags onto whatever the program wants to use. I use a ~/.bashrc and /etc/bashrc to define CFLAGS and any aliases that I want. That way, they are exported as soon as you open your terminal.
Code:
# Begin /etc/bashrc Code:
# Begin ~/.bashrc |
jong357:
I have done exactly what your example shows (create /etc/bashrc and ~/.bashrc), but when I start a new session as my user, and "echo $CFLAGS", it outputs nothing. I thought maybe I had to make /etc/bashrc executable (even though none of the other rc files are +x in /etc), but that didn't help. Any idea what I'm not doing right? Btw, if I login as my user and then "export CFLAGS="whatever" from the command line, and then echo $CFLAGS, it works. so I'm guessing my ~/.bashrc file isn't executing? (or is it even supposed to execute) |
Create a ~/.bash_profile with this content :
Code:
if [ -f ~/.bashrc ]; then jong357> if you compile mplayer with your flags, it will be less optimized as it uses default optimization level -O4 if $CFLAGS is not set |
that works, thanks :)
ps: why in jong356's /etc/bashrc does he export CXXFLAGS="${CFLAGS}" when export CXXFLAGS=$CFLAGS does the same thing? do the quotes and curly brackets do something special? thanks. |
In bash ${} is used for parameter expansion, more infos at :
http://itb.biologie.hu-berlin.de/~be...ware/bash.html but in this case "${CFLAGS}" is the same thing as $CFLAGS because there is no need to protect the variable name, I mean ${} is needed for example: Code:
s=1 |
ah, ok.
one more question (sorry if you're getting tired of this thread). checkinstall is still naming the tgz packages with "i386" in them. should I take this to mean it is still only using i386, or is it just because I'm not changing the "architecture" field of the description before checkinstall finishes (ie: it IS compiled with i686, just not named that way) |
It's just that you're not changing the field. You can either change it each time, or edit checkinstall and change the default architecture (for example, I have it set to i486).
|
Quote:
I find that strange that bash wasn't reading ~/.bashrc... Altho, now that I look, I have a long forgotten .bash_profile that does the same thing... I was under the impression that I only needed a .bash_profile if I wanted to stay in init3 and still have my /etc/bashrc sourced... That was the conclusion I came to long ago anyway. Maybe I'm wrong... ;) |
All times are GMT -5. The time now is 03:16 PM. |