[LLVMdev] Building llvm and clang with mixed assertion modes

Óscar Fuentes ofv at wanadoo.es
Mon Nov 26 17:24:14 PST 2012


"David Peixotto" <dpeixott at codeaurora.org> writes:

> I'd like to build llvm with assertions enabled, but build clang with
> assertions disabled. In other words, I'd like lvm in Release+Asserts mode,
> but clang in Release mode.
>
> Is it possible to do this with one top level configure/make command? If not,
> any idea how much work would it be to add this feature to llvm? I'm not very
> familiar with llvm's build system.

Dunno about the configure&make build, but with the cmake build you can
do that by building clang standalone (build and install LLVM without
clang, then build clang using LLVM as an external library,
enabling/disabling assertions as you like).

You can also modify clang/CMakeLists.txt by changing

add_definitions( -D_GNU_SOURCE )

to

add_definitions( -D_GNU_SOURCE -U_DEBUG -DNDEBUG )

which disables assertions for clang. Then build LLVM+Clang using the
option for enabling assertions:

mkdir mybuilddir && cd mybuilddir
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON path/to/llvm/src

(In the cmake build, assertions are disabled by default in Release mode)




More information about the llvm-dev mailing list