Build "Release" with cmake produces a debug build?

I have been trying to build a release version of clang-tidy with a local patch from the 15.0.5 tag. I ran a configure step with

cmake -G “Ninja” -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=“clang;clang-tools-extra;” -DCMAKE_INSTALL_PREFIX=“$install_path” -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ …/llvm

and then built ninja -j 12 install-clang-tidy. Everything built as expected, however:

clang-tidy --version
LLVM (http://llvm.org/):
LLVM version 15.0.5
DEBUG build with assertions.
Default target: x86_64-unknown-linux-gnu
Host CPU: skylake

Note the “DEBUG build with assertions.”

My previous build was from the 14.0.0 tag (same config, I just rebuilt it), which reports:
clang-tidy --version
LLVM (http://llvm.org/):
LLVM version 14.0.0git
Optimized build.
Default target: x86_64-unknown-linux-gnu
Host CPU: znver1

Has something changed that hasn’t made it to the building with cmake documentation?

Thanks,
Ian.

I think there could be a bug in whatever part of the build system adds the “DEBUG build with assertions” text to the binary. You should confirm that it is actually a debug build by using a tool like readelf to inspect the binary for debuginfo.

The code that prints that message is here llvm-project/CommandLine.cpp at 63d65d3764ea2fc27e0e1a6054ec42cff6d84158 · llvm/llvm-project · GitHub if you want to see what the logic is.

Thanks for the feedback.

I see LLVM_IS_DEBUG_BUILD is defined based on OPTIMIZE which clang does set.

Looking at the two builds with ‘readelf --debug-dump=info’, no debug symbols are found. However, both are unstripped and the original is 77MB while the latest is 222M with objdump --syms showing 85419 and 595823 symbols respectively.

Assertions are enabled (I hit one!) and yes, NDEBUG is defined on the compile command line.

I think it is being built with no optimisation options which would explain the lack of debug symbols and OPTIMIZE not being defined.

I have tried to reproduce this in a fresh docker container and I have been unable to do so.

It looks like a build environment issue.