discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file-specific optimization options?


From: Dan Pascu
Subject: Re: file-specific optimization options?
Date: Wed, 7 Nov 2001 02:51:58 +0200 (EET)

On  6 Nov, Nicola Pero wrote:
> 
>> Does anyone know (i) if there is a portable replacement for
>> this pragma, or (ii) if there is support in gnustep-make for
>> file-specific CC options? If not, can anyone suggest a
>> workaround?
> 
> (ii): gnustep-make does not support file-specific CC options ... hmmm ...
> we might add the facility to specify additional compiler flags for a
> specific file ... but it wouldn't fix your problem, because you want to
> *remove* the -O% flags for a single file rather than add it ... unless we
> also add the possibility of specifying a file-specific pattern to
> filter-out from the flags when compiling that specific file ... I can

You don't necessarily have to remove the flags, just modify/append to
them.
Here's a small example of how autoconf/automake does this to allow a
file containing embedded asm code to be compiled without optimizations
and without -fomit-frame-pointer (asm code doesn't compile well with
this flag and any optimization):

-------------------------

LTCOMPILE2=`echo $(LTCOMPILE) | sed -e s/-fomit-frame-pointer//`
COMPILE2=`echo $(COMPILE) | sed -e s/-fomit-frame-pointer//`

# cant compile asm stuff with optimizations
x86_specific.lo: x86_specific.c
        $(LTCOMPILE2) -O0 -c $<

x86_specific.o: x86_specific.c
        $(COMPILE2) -O0 -c $<

--------------------------

if a specific rule is defined for a file, that will be used instead of
the default used for al lthe other files (x86_specific.c in this case).
This means that -fomit-frame-pointer will be stripped out, and all the
other flags will remain, but a -O0 (ie no optimization) flag will be
appended to them. Since the only one that counts is the last one, you
get no optimization (-g -O2 -O0 means only -O0 is effective)


> probably implement all this stuff but I'm not sure how much real use it
> would be and how much would just be confusing and making gnustep-make
> source code more obscure ... if anybody has convincing examples/real life
> cases in which it might be useful to be able to add/remove specific flags
> for a single file, please let me know!  you might convince me to actually
> implement it.

it can be very useful if you ever want to add asm code in your project
for example.

> 
> anyway - as a workable real life solution, you might try to set up a
> subproject containing the only file you want to compile with different
> flags, and set the special flags in that subproject.

-- 
Dan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]