LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 08-11-2002, 04:03 AM   #1
wrc1944
Member
 
Registered: Aug 2002
Location: Gainesville, Florida
Distribution: Gentoo ~x86 2007.0
Posts: 139

Rep: Reputation: 15
Question Optimizing flags compiling question


Can an expert please tell me precisely where to place my compiling optimization flags. I've tried /etc/profile/, and etc/rpmrc (in Mandrake 8.2, rpmrc is in /usr/lib/rpm/). This works for my .src.rpm compiling, but I can't seem to get the /etc/profile/ optimization flags to work with source files (.tar.gz, extracted).

Do I need to add flags to the ./configure process, or edit them in to the resulting makefile after I do ./configure? Please give me the exact syntax, and where in the makefile I need to place them.

Also, how, and precisely where do I place the CFLAG optimization flags in /etc/profile, which I had understood would then be picked up and placed into every makefile that ./configure produced apparently, the syntax, and/or locations I have been using don't work. This wouldn't be a problem, if I could just place them in the makefile before I run "make install." I need the exact locations to place the opt flags in makefile, and the exact syntax to use- I'm obviously doing something wrong.I'd rather have them in /etc/profile, and work automatically, but I don't mind doing them individually on each compile. I really need some specific examples- I'm new at this and just a general "do this" or "do that" may not help me. I've followed many directions in the articles on this subject, but either they don't work in Mandrake 8.2, or I don't understand them.
Thanks,
wrc1944
 
Old 08-11-2002, 07:37 AM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
/etc/profile is a good place. Remember that not every makefile uses CFLAGS. That's why some programs compile without your optimization flags. In such case, you need to edit Makefiles.
 
Old 08-11-2002, 12:30 PM   #3
wrc1944
Member
 
Registered: Aug 2002
Location: Gainesville, Florida
Distribution: Gentoo ~x86 2007.0
Posts: 139

Original Poster
Rep: Reputation: 15
I need to see an actual example of where to place the opt flags in makefile. I also need somebody to copy their etc/profile file with the working flags, so I can know precisely where to place them. Can somebody who does this please post copies (or send me by email- flacycads@access4less.net) of your etc/profile, etc/rpmrc, and ./bash_profile files if you place the opt flags there, and also an optimized makefile produced by the optimizations. That way, there will be no misunderstanding as to what I need to do. I've been going around in circles all week trying to figure this out. Even though I carefully follow all the advice, nothing seems to work with tar.gz compiles. I can do srpms fine, but obviously I am not doing something correctly with the others.
Thanks again,
wrc1944
 
Old 08-11-2002, 02:51 PM   #4
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
I imagine your problem is that C++ programs use CXXFLAGS rahter than CFLAGS. As for the location you set CFLAGS and CXXFLAGS in your /etc/profile, it doesn't matter. Here's the relevant bit of mine just as an example:

CFLAGS='-march=i686 -mcpu=i686'
CXXFLAGS="$CFLAGS"

These definitions work for me on about 90% of compilations.
 
Old 08-11-2002, 02:53 PM   #5
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
Btw, if you want to use a different selection of flags for a partiular program, you should set them when you type make, like so:

CFLAGS=blahblahblah CXXFLAGS=foofoofoo make
 
Old 08-11-2002, 04:01 PM   #6
wrc1944
Member
 
Registered: Aug 2002
Location: Gainesville, Florida
Distribution: Gentoo ~x86 2007.0
Posts: 139

Original Poster
Rep: Reputation: 15
I need to see someone's actual file, with a few surrounding lines to give it context. As an example, here is mine, placed at the top of /etc/profile. These same flags work perfect every time in the rpmrc file with srpms, but I 've never gotten any combination of flags to work with compiling tar.gz files. This isn't the only style I've tried- I've tried at least 5 versions people have said work. In my case, nothing does. If there is something wrong with this file. please point it out, and give me an example of yours. Not just the correct lines, but a section of the file with the flag lines so I can see the context.
Thanks
wrc1944
---------------------------------------------------------------
# /etc/profile -*- Mode: shell-script -*-
# (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=i686 -O3 -fomit-frame-pointer -pipe -ffast-math -funroll-loops -fforce-mem -fforce-addr -finline-functions
-malign-functions=4 -mpreferred-stack-boundary=2"

CXXFLAGS=$CFAGS

export CXXFLAGS CFLAGS

# Users generally won't see annoyng core files
[ "$UID" = "0" ] && ulimit -S -c 1000000 > /dev/null 2>&1

if ! echo ${PATH} |grep -q /usr/X11R6/bin ; then
PATH="$PATH:/usr/X11R6/bin"
fi

if [ "$UID" -ge 500 ] && ! echo ${PATH} |grep -q /usr/games ; then
export PATH=$PATH:/usr/games
fi

umask 022
 
Old 08-12-2002, 07:42 AM   #7
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
This file looks good. The only difference with mine is that I've got it at the end.
If you can see your variable correctly after running
echo $CFLAGS
it's set and should work.
 
Old 08-12-2002, 11:45 AM   #8
wrc1944
Member
 
Registered: Aug 2002
Location: Gainesville, Florida
Distribution: Gentoo ~x86 2007.0
Posts: 139

Original Poster
Rep: Reputation: 15
I put it at the end, and it doesn't work. The only thing that does is the way a person told me on another forum, where I put in the flags like this, after I su and cd to the directory of the extracted tarball.

export CFLAGS=-O3 ......more flags
export CXXFLAGS=-O3 ........more flags
./configure && make && make install

The result is that it does a configure, and the flags show up correctly in the resulting makefile. Then make runs correctly. I haven't gotten through a complete make install yet, but that's due to a missing libperl.a file aborting the make install on ImageMagick-5.4.8. The opt flags are working OK.

Trying to put them in /etc/profile, or /root/bash_profile has not worked. Trying to edit them into the makefile manually does not work either. echo $CFLAGS gives nothing.

I've been searching for a copy of the libperl.a file for three hours, after installing perl and apache(everything in both). No luck. Can someone email me libperl.a? (flacycads@access4less.net)? The output in make install says it should be in user/lib/perl5/5.6.1/i386-linux/CORE, but it's not there.
Thanks,
wrc1944
 
Old 08-12-2002, 06:34 PM   #9
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
The main part of your problem is because your CFLAGS etc are not read from /etc/profile.
Try to put it into your ~/.bash_profile
 
Old 08-13-2002, 03:16 AM   #10
wrc1944
Member
 
Registered: Aug 2002
Location: Gainesville, Florida
Distribution: Gentoo ~x86 2007.0
Posts: 139

Original Poster
Rep: Reputation: 15
I previously tried putting them in ~/.bash_profile, as another person suggested several days ago on another forum. That didn't work either, even as root.

In your post above, you said I should put them in /etc/profile, and now you say the problem is because they aren't read from /etc/profile. This seems contradictory, and the only way this makes sense is that some programs read from /etc/profile, and some don't.Is that correct? Newbies have no way of knowing that. I can say that I've tried countless times with many versions and configurations, as suggested by numerous experts. My conclusions, at least in my case, are:

1. /root/bash_profile doesn't work
2. ~./bash_profile doesn't work
3. /etc/profile doesn't work
4. manually editing flags into a makefile doesn't work
5. putting flags right before ./configure DOES work, only for that specific compile.

Since so many experts are saying 1-4 do work, I'm at a loss as to why in my experience, and after explicitly following all suggestions to the letter, they don't. I must still be doing something wrong, but after 20-30 posts to different forums asking someone to please post their files showing flags in context, nobody has done so. If I could see correct examples of those four relevant files, that would show me what's wrong with what I'm doing, and would have saved days of back and forth postings, and confusion.I really appreciate all the help, but one picture is worth a thousand words.

I guess I can live with doing it manually each time, but I'd really like to figure out why the other methods aren't working for me.
wrc1944
 
Old 08-13-2002, 05:58 AM   #11
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
Individual programs don't read from /etc/profile, the shell does. I can only think that you might be running an shell which doesn't read from /etc/profile. Are you sure you're running bash? To find out, run:

ps ax | grep bash

and see if you get more than one line of output from that command.

I can't really give you an example /etc/profile, because I'm running FreeBSD which uses the c-shell, which uses different configuration files with a different syntax. But I still don't think it's an error in the way you are formatting the file, as long as you get the variable definitions in there somewhere, it should work. Btw, the file you posted had a typo:

CXXFLAGS=$CFAGS

where you had CFAGS instead of CFLAGS

Alex

Last edited by llama_meme; 08-13-2002 at 06:04 AM.
 
Old 08-13-2002, 09:04 AM   #12
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
Quote:
Originally posted by wrc1944

If I could see correct examples of those four relevant files, that would show me what's wrong with what I'm doing, and would have saved days of back and forth postings, and confusion.I really appreciate all the help, but one picture is worth a thousand words.
Seeing a file won't help much, but if you really wish it (not full, the last part):
Code:
# Mandrake-Security : if you remove this comment, remove the next line too.
SECURE_LEVEL=3
# Mandrake-Security : if you remove this comment, remove the next line too.
umask 022
# Mandrake-Security : if you remove this comment, remove the next line too.
PATH=$PATH:/usr/X11R6/bin:/usr/games:/usr/local/bin:/usr/local/sbin:/usr/local/kde/bin:/repository/kde/qt/bin:/usr/TeX/bin/i386-linux
QTDIR=/repository/kde/qt
KDEDIR=/usr/local/kde
# Mandrake-Security : if you remove this comment, remove the next line too.
export PATH SECURE_LEVEL QTDIR KDEDIR

CFLAGS="-O9 -march=athlon"
export CFLAGS
Also check if you don't have a spelling mistake as
llama_meme suggested. It's not a reason not having CFLAGS, it can only affect CXXFLAGS, but check it.
 
Old 08-13-2002, 09:28 AM   #13
wrc1944
Member
 
Registered: Aug 2002
Location: Gainesville, Florida
Distribution: Gentoo ~x86 2007.0
Posts: 139

Original Poster
Rep: Reputation: 15
Alex,
Here's my output, in user, and root:

[wrc1944@localhost wrc1944]$ ps ax|grep bash
2357 pts/0 S 0:00 /bin/bash
2385 pts/0 R 0:00 grep bash

[root@localhost wrc1944]# ps ax|grep bash
2357 pts/0 S 0:00 /bin/bash
2392 pts/0 S 0:00 bash
2422 pts/0 S 0:00 grep bash

I had thought the default shell in Mandrake was bash, so I guess this output confirms that.
I had noticed that typo- it wasn't in the actual files, just in the post to the forum.

Mara,
I assume this is your /etc/profile file. I see you have the flags at the absolute end. In mine, I didn't want to put flags after "done" and unset i, as that didn't seem sensible. After umask 022, I see you only have path lines, but in mine I have a bunch of other stuff (see below) Could this make a difference?
---------------------------------------------------------------------------------------
umask 022

USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HISTCONTROL=ignoredups
HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi

# some old programs still use it (eg: "man"), and it is also
# required for level1 compliance for LI18NUX2000
NLSPATH=/usr/share/locale/%l/%N

export PATH PS1 USER LOGNAME MAIL HOSTNAME INPUTRC NLSPATH
export HISTCONTROL HISTSIZE


for i in /etc/profile.d/*.sh ; do
if [ -x $i ]; then
. $i
fi

#CFLAGS="-march=i686 -O3 -fomit-frame-pointer -pipe -ffast-math -funroll-loops
-fforce-mem -fforce-addr -finline-functions
-malign-functions=4 -mpreferred-stack-boundary=2 -mcpu=i686"

#CXXFLAGS=$CFLAGS

#export_ETC_PROFILE PATH USER HOST HOSTNAME LOGNAME CXXFLAGS CFLAGS


done

unset i
----------------------------------------------------------------------------------
Thanks,wrc1944
 
Old 08-13-2002, 09:45 AM   #14
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
Hmm, '#' means a comment? Is it what you want?
You also have your pathes set inside 'for' loop. I'd move it somewhere else. The absolute end would be good.
 
Old 08-13-2002, 10:55 AM   #15
wrc1944
Member
 
Registered: Aug 2002
Location: Gainesville, Florida
Distribution: Gentoo ~x86 2007.0
Posts: 139

Original Poster
Rep: Reputation: 15
Sorry- I copied the file after I had commented it out when I was installing some i586 packages- thus the #. I always uncommented it whenever I was trying to compile with i686 flags. OK- so I've set the flags inside something I shouldn't have. Maybe that is my problem.
Many thanks.
 
  


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
flags for compiling Xlib.h in gcc Maidros Programming 2 06-15-2005 06:00 AM
optimizing slack (compiling packages from the source ISO disk) saurabhp_75 Slackware - Installation 1 02-28-2005 06:19 AM
optimization flags and kernel compiling kpachopoulos Linux - Newbie 2 08-26-2004 08:29 AM
Snort flags SYN Question gfyspf Linux - Security 1 12-10-2003 11:12 AM
Compiling KDE 3.0 w/ multiple architecture flags (quick and easy question)? MatMan5959 Linux - Software 4 05-31-2002 02:57 PM


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

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