SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
"
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)
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
# System wide aliases and functions.
alias ls='ls -A --color=always'
alias bt5='bittorrent --max_upload_rate 5'
alias bt10='bittorrent --max_upload_rate 10'
alias bt15='bittorrent --max_upload_rate 15'
alias shutdown='shutdown -h now'
alias start='/etc/rc.d/rc.pcmcia start'
alias stop='/etc/rc.d/rc.pcmcia stop'
alias restart='/etc/rc.d/rc.pcmcia restart'
# Lets set some good Slackware environment variables:
export CFLAGS="-march=i486 -mtune=i686 -pipe -O2"
export CXXFLAGS="${CFLAGS}"
export MAKEOPTS="-j3"
# If we are using XTERM, tell it to keep walking
# We'll get it there eventually
if [ "$TERM" = "xterm" ]; then
source /etc/profile
fi
# End /etc/bashrc
And for your home folder
Code:
# Begin ~/.bashrc
#
# Personal aliases and functions.
if [ -f "/etc/bashrc" ] ; then
source /etc/bashrc
fi
# End ~/.bashrc
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)
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.
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).
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
I know... I just compiled mplayer and it's optional 20 deps last month.. I think -O4 is too agressive. I purposefully compile EVERYTHING with -02.. Mplayer runs fast and clean with those opts....
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.