default CFLAGS

Morgan Wesström freebsd-questions at pp.dyndns.biz
Sat Jan 24 06:27:07 PST 2009


RW wrote:
> On Sat, 24 Jan 2009 12:51:32 +0000
> Saifi Khan <saifikhan at gmail.com> wrote:
> 
> 
>> on running the command 'make -V CFLAGS', the output is
>>
>> -O2 -fno-strict-aliasing -pipe
>>
>> i haven't setup the CPUTYPE anywhere (not as an env variable nor in
>> /etc/make.conf)
>> So are these default settings for a generc x86 based system ?
> 
> Yes, if you are using i386. 
> 
> Most CPUs have the same default CFLAGS, it's the value of CPUTYPE
> that's passed to the compiler that determines processor optimizations.

If you want to know what gcc processor optimizations will be enabled you
can do this:

Create hello.c:

#include <stdio.h>
main()
{
	printf("hello, world\n");
}

Then compile it with -Q -v in addition to the default CFLAGS:

gcc -O2 -fno-strict-aliasing -pipe -Q -v -o hello hello.c

The section "options enabled" will list them all. I usually only add
"-march=native" to my CFLAGS to enable a few more CPU specific
optimizations.

/Morgan


More information about the freebsd-questions mailing list