[PATCH] cmake: NDEBUG needlessly defined in non-Release builds

Janusz Sobczak janusz.sobczak at mobica.com
Thu Jun 26 02:01:44 PDT 2014


Current situation is very inconsistent and confusing. I hit the issue when I first built a Release version and then switched to Debug in the same build directory. Cmake somehow preserved LLVM_ENABLE_ASSERTIONS=OFF from the Release build, so I ended up with a config, where CMAKE_BUILD_TYPE = DEBUG and LLVM_ENABLE_ASSERTIONS = OFF.

The most confusing bit was that the binaries i.e. llc didn't support '-debug'.
I think it is fair to expect that '-debug' parameter will be supported in DEBUG build, regardless of other options.

The documentation about LLVM_ENABLE_ASSERTIONS says it controls assertions. It doesn't say it controls debugging printfs too.

My understanding of the code in lines 50 - 69 in HandleLLVMOptions.cmake is that LLVM_ENABLE_ASSERTIONS depends on debugging output support, so it is enabled implicitly even in Release build. I'm OK with that because it allows to assert() in optimized code.

The change in lines 71 - 75 in the original file was introduced to fix http://llvm.org/bugs/show_bug.cgi?id=9155. Why is this change specific to MSVC and Xcode? I have no idea. I think this is wrong. It should be done consistently for all IDEs.

http://reviews.llvm.org/D4257






More information about the llvm-commits mailing list