CFLAGS/CXXFLAGS bug with configure

Hi all:

I’ve been tinkering with optimizing zeek for performance, and came across a problem with CFLAGS/CXXFLAGS specified to the configure script. Lets say I want to try the -O3 flag for more aggressive optimization than the default -O2:

$ CFLAGS=’-O3’ CXXFLAGS=’-O3’ ./configure

====================| Bro Build Summary |=====================

CFLAGS: -O3 -Wall -Wno-unused -O2 -g -DNDEBUG

CXXFLAGS: -O3 -Wall -Wno-unused -std=c++11 -O2 -g -DNDEBUG

The couple places where we set CMAKE_C{XX}_FLAGS don't seem to matter:
the flags associated with CMAKE_BUILD_TYPE always come last in the
generated Makefile and I think that's just what CMake does, not
something we can control.

However, you should be able to bypass CMake from inserting build-type
flags entirely if you supply an unknown/bogus build type:

    CFLAGS='-O3' CXXFLAGS='-O3' ./configure --build-type=none

- Jon

Thanks, sounds like a CMake bug, or at least a violation of the Principle of Least Surprise - explicit settings are always expected to override defaults… In any event, in the Zeek context, this thread should suffice to document this (admittedly obscure) issue, and mitigation.