Funny things with cflags and world/kernel building

Bartosz Stec admin at kkip.pl
Fri Sep 5 13:12:17 UTC 2008


As well as i know variables works this way:

    # set foo=bar
    # set | grep foo
    _       set foo=bar
    foo     bar
    # echo $foo
    bar
    # echo ${foo}
    bar

So maybe someone could explain me why following things happens with 
variables in make.conf?

My make.conf:

    CPUTYPE=athlon64
    MAKEOPTS=-j3

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

    # default build settings for ports collection
    .if ${.CURDIR:M*/ports/*}
    CFLAGS= -O2 -fno-strict-aliasing -pipe -funroll-loops
    -fomit-frame-pointer
    CXXFLAGS= -O2 -fno-strict-aliasing -pipe -funroll-loops
    .endif

    # default build settings for base system
    .if ${.CURDIR:M*/usr/src/*} || ${.CURDIR:M*/usr/obj/*}
    CFLAGS=-O2 -fno-strict-aliasing -pipe
    #CXXFLAGS=-O2 -fno-strict-aliasing -pipe
    COPTFLAGS=-O2 -fno-strict-aliasing -pipe
    CXXFLAGS=${CFLAGS}
    #COPTFLAGS=${CFLAGS}
    .endif
    # added by use.perl 2008-04-14 10:39:38
    PERL_VER=5.8.8
    PERL_VERSION=5.8.8

As you see I use ccache and different flags for world and port building, 
but what's interesting:

1. when I use these flags:

    CFLAGS=-O2 -fno-strict-aliasing -pipe
    CXXFLAGS=${CFLAGS}
    COPTFLAGS=${CFLAGS}

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

    --------------------------------------------------------------
     >>> stage 3.1: making dependencies
    --------------------------------------------------------------
    cd /usr/obj/usr/src/sys/AMD64SMP7; MAKEOBJDIRPREFIX=/usr/obj 
    MACHINE_ARCH=amd64  MACHINE=amd64  CPUTYPE=athlon64 
    GROFF_BIN_PATH=/usr/obj/usr/src/tmp/legacy/usr/bin 
    GROFF_FONT_PATH=/usr/obj/usr/src/tmp/legacy/usr/share/groff_font 
    GROFF_TMAC_PATH=/usr/obj/usr/src/tmp/legacy/usr/share/tmac 
    _SHLIBDIRPREFIX=/usr/obj/usr/src/tmp  VERSION="FreeBSD
    7.1-PRERELEASE amd64 700112"  INSTALL="sh
    /usr/src/tools/install.sh" 
    PATH=/usr/obj/usr/src/tmp/legacy/usr/sbin:/usr/obj/usr/src/tmp/legacy/usr/bin:/usr/obj/usr/src/tmp/legacy/usr/games:/usr/obj/usr/src/tmp/usr/sbin:/usr/obj/usr/src/tmp/usr/bin:/usr/obj/usr/src/tmp/usr/games:/sbin:/bin:/usr/sbin:/usr/bin
    NO_CTF=1 make KERNEL=kernel depend -DNO_MODULES_OBJ
    machine -> /usr/src/sys/amd64/include
    Variable CFLAGS is recursive.
    *** Error code 2

    Stop in /usr/src.
    *** Error code 1

    Stop in /usr/src.

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!:

    ===> gnu/lib/libstdc++ (depend)
    ln -sf
    /usr/src/gnu/lib/libstdc++/../../../contrib/libstdc++/config/cpu/generic/                                                                            
    atomicity_builtins/atomicity.h atomicity.cc
    ln -sf
    /usr/src/gnu/lib/libstdc++/../../../contrib/gcc/unwind-generic.h
    unwind.h
    rm -f .depend
    (...)
    /usr/src/gnu/lib/libstdc++/../../../contrib/libstdc++/libsupc++/unwind-cxx.h:41:                                                                            
    20: error: unwind.h: No such file or directory
    In file included from
    /usr/src/gnu/lib/libstdc++/../../../contrib/libstdc++/libs                                                                            
    upc++/vec.cc:37:
    /usr/src/gnu/lib/libstdc++/../../../contrib/libstdc++/libsupc++/unwind-cxx.h:41:                                                                            
    20: error: unwind.h: No such file or directory
    mkdep: compile failed
    *** Error code 1

    Stop in /usr/src/gnu/lib/libstdc++.
    *** Error code 1

    Stop in /usr/src/gnu/lib.
    *** Error code 1

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

    CFLAGS=-O2 -fno-strict-aliasing -pipe
    COPTFLAGS=-O2 -fno-strict-aliasing -pipe
    CXXFLAGS=${CFLAGS}

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

It isn't new issue - it's couple of months as I face this problem - on 
AMD 64 machine with CPUTYPE=athlon64 and MAKEOPTS=-j3 and olso on i386 
machine with CPUTYPE=pentium2 and MAKEOPTS=-j2.  Other flags are the 
same as in the beginning of this message. Another machine - exactly the 
same flags but CPUTYPE=athlon-tbird and MAKEOPTS=-j2 and no problems 
compiling world and kernel regardless of flags combination.

Could anyone explain to me sthis trange behaviour ?

p.s. Sorry for my poor english ;)

-- 
Bartosz Stec - specjalista ds. IT

AUXILIA Spółka z o.o.




More information about the freebsd-stable mailing list