Funny things with cflags and world/kernel building

Derek Kuliński takeda at
Sun Sep 7 20:41:05 UTC 2008

Hello Bartosz,

Friday, September 5, 2008, 6:12:12 AM, you wrote:

> My make.conf:
>     CPUTYPE=athlon64
>     MAKEOPTS=-j3

I would recommend to take that -j3 out from make.conf, it might screw
up make install, not to mention many ports might not build with it.

>     # USE CCACHE
>     .if !defined(NOCCACHE)
>     CC=/usr/local/libexec/ccache/world-cc
>     CXX=/usr/local/libexec/ccache/world-c++
>     .endif

AFAIK this is setting for building world, the way you set it up seems
to be using it for everything else (i.e. ports)
I belive this is the recommended way of using it:

.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*)) && !defined(NOCCACHE)

> 1. when I use these flags:

>     CFLAGS=-O2 -fno-strict-aliasing -pipe

> world building finish without problem, but making kernel give an error:

> 2. When I use these flags:

>     CFLAGS=-O2 -fno-strict-aliasing -pipe
>     CXXFLAGS=-O2 -fno-strict-aliasing -pipe
>     COPTFLAGS=-O2 -fno-strict-aliasing -pipe

> kernel build finish without problem, but... building world give an error!:

> 3. What's even more funny? When I use flags:

>     CFLAGS=-O2 -fno-strict-aliasing -pipe
>     COPTFLAGS=-O2 -fno-strict-aliasing -pipe

> I have no errors at all! But shouldn't all those flags be treated by 
> make command exactly the same way??

I think the strange behavior probably is because make.conf is called
each time a make is executed. Building world, kernel etc. Will call
multiple makes inside of another make. I suspect some of the Makefiles
might append additional flags, so the ${CFLAGS} might change its value
in different parts of the compiling, so that's why you might get the
weird errors.
I guess perhaps you could use the last option since it works, or
instead of using = you would use ?=
CFLAGS ?= -O2 -fno-strict-aliasing -pipe

This will assign cflags only if CFLAGS is empty.

Best regards,
 Derek                            mailto:takeda at

-- Be nice to your kids. They'll choose your nursing home.

More information about the freebsd-stable mailing list