automake
[Top][All Lists]
Advanced

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

Re: How to handle CFLAG ordering


From: Matt Turner
Subject: Re: How to handle CFLAG ordering
Date: Sat, 30 Jun 2012 12:28:49 -0400

On Wed, May 30, 2012 at 3:45 PM, Nick Bowler <address@hidden> wrote:
> On 2012-05-30 13:20 -0400, Matt Turner wrote:
>> I'm maintaining some ARM/iwMMXt-optimized code in pixman,
>> http://cgit.freedesktop.org/pixman/
>>
>> gcc will only emit iwmmxt instructions when -march=iwmmxt{,2} is used,
>> which is stupid. It also has the side-effect of putting gcc into ARMv5
>> mode, even though the CPU I care about is ARMv7. So, we want the rest
>> of the package built with -march=armv7-a.
>>
>> pixman's build system attempts to compile pixman-mmx.c with
>> -march=iwmmxt by building it as a convenience library, but when you
>> build pixman with something like
>>
>> CFLAGS="-O2 -march=armv7-a -pipe" ./configure
>>
>> it winds up putting -O2 -march=armv7-a -pipe *after* -march=iwmmxt,
>> which disables iwmmxt support. There is probably a way to handle this
>> -- I just don't know how.
>
> This is, unfortunately for your case, by design: users are *supposed* to
> be able to override these things by setting CFLAGS.  If there's really
> no way to get GCC to behave the way yo want it to, then there are some
> hacks that come to mind.
>
> Probably the simplest and most reliable approach is to define your own
> make rule to compile the C file.  That way, you can put the compiler
> flags wherever you want.  Unfortunately, you will not get to make use
> of Automake's automake dependency tracking, but this is (hopefully) of
> minor importance since you can usually just list everything explicitly
> as prerequisites.  In your case, I think this should just amount to
> something like this (totally untested):
>
>  crazy.lo: crazy.c other-prerequisites-here
>        $(LTCOMPILE) $(IWMMXT_CFLAGS) -c crazy.c
>
>  mostlyclean-local: clean-crazy-lo
>  clean-crazy-lo:
>        $(LIBTOOL) --mode=clean rm -f crazy.lo
>
> and then just list crazy.lo in _LDADD or _LIBADD variables as
> needed.  You don't need the convenience library anymore, so
> delete the Automake bits related to it.
>
> Hope that helps,
> --
> Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)
>

I wanted to follow up and say that your suggestion worked.

See 
http://cgit.freedesktop.org/pixman/commit/?id=31a6563ec5167d6b15fdb8c158a71ab4f97015ab

I basically copied the generated rules into Makefile.am and modified
the CFLAG ordering. Hacky, but it'll work until gcc is fixed.

Thanks Nick!
Matt



reply via email to

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