(original) (raw)

On Tue, Jul 21, 2015 at 6:58 PM Justin Bogner <mail@justinbogner.com> wrote:
Paweł Bylica <chfast@gmail.com> writes:
\> On Tue, Jul 21, 2015 at 6:30 PM Justin Bogner <mail@justinbogner.com> wrote:
\>> Paweł Bylica <chfast@gmail.com> writes:
\>>> On Tue, Jul 21, 2015 at 5:55 PM Justin Bogner <mail@justinbogner.com> wrote:
\>>>> FWIW, \`llvm-config --assertion-mode\` will tell you whether or not your
\>>>> LLVM was built with or without NDEBUG.
\>>>
\>>> That's not true in all cases. In case CMAKE\_BUILD\_TYPE=Release,
\>>> LLVM\_ENABLE\_ASSERTIONS=Off and CMAKE\_CXX\_FLAGS\_RELEASE=""
\>>> llvm-config reports asserts as off but NDEBUG flag is not set.
\>>
\>> Um, okay, but why would you set CMAKE\_CXX\_FLAGS\_RELEASE=""? That
\>> doesn't make any sense...
\>
\> I agree, it make no sense. But homebrew actually does that:
\> https://github.com/Homebrew/homebrew/blob/master/Library/Homebrew/formula.rb#L615

That sounds very broken - maybe ask them to fix it?

I've fixed that for the LLVM formula.
https://github.com/Homebrew/homebrew/blob/master/Library/Formula/llvm.rb#L140


In any case, \`llvm-config\` seems to correctly report asserts as ON in
this case, despite the configuration being completely bogus:

In the same time the shared cmake file LLVMConfig.cmake will have LLVM\_ENABLE\_ASSERTIONS set to On.

% cmake -G Ninja ../llvm -DCMAKE\_BUILD\_TYPE=Release -DLLVM\_ENABLE\_ASSERTIONS=Off -DCMAKE\_CXX\_FLAGS\_RELEASE=""
...
% ninja llvm-config
\[94/94\] Linking CXX executable bin/llvm-config
% ./bin/llvm-config --assertion-mode
ON

The code that prints this just checks NDEBUG:

llvm-config.cpp:320:
\> } else if (Arg == "--assertion-mode") {
\> #if defined(NDEBUG)
\> OS << "OFF\\n";
\> #else
\> OS << "ON\\n";
\> #endif