# CFLAGS/CXXFLAGS bug with configure

**URL:** <https://community.zeek.org/t/cflags-cxxflags-bug-with-configure/5713>\
**Category:** Development\
**Tags:** development\
**Created:** [May 29, 2019, 5:23pm UTC](https://community.zeek.org/t/cflags-cxxflags-bug-with-configure/5713 "2019-05-29T17:23:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jim\_Mellander](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@Jim\_Mellander](https://community.zeek.org/u/Jim_Mellander)\
**Post date:** [May 29, 2019, 5:23pm UTC](https://community.zeek.org/t/cflags-cxxflags-bug-with-configure/5713/1 "2019-05-29T17:23:32Z")

</div>

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  
…

---

<div class="post-metadata">

**Author:** ![Jon\_Siwek](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Jon\_Siwek](https://community.zeek.org/u/Jon_Siwek)\
**Post date:** [May 29, 2019, 9:21pm UTC](https://community.zeek.org/t/cflags-cxxflags-bug-with-configure/5713/2 "2019-05-29T21:21:22Z")

</div>

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:

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

- Jon

---

<div class="post-metadata">

**Author:** ![Jim\_Mellander](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@Jim\_Mellander](https://community.zeek.org/u/Jim_Mellander)\
**Post date:** [May 30, 2019, 5:04pm UTC](https://community.zeek.org/t/cflags-cxxflags-bug-with-configure/5713/3 "2019-05-30T17:04:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/zeek/original/1X/f09d732bc2cc7c7cc7e35db67cf4e1d5233ce7a7.png) [@system](https://community.zeek.org/u/system)\
**Post date:** [May 6, 2022, 3:46pm UTC](https://community.zeek.org/t/cflags-cxxflags-bug-with-configure/5713/4 "2022-05-06T15:46:32Z")

</div>


