On Wednesday, 7 January 2015 09:25:25 CEST, Pali Rohár wrote:
Problem is that -Wall (or -W) is not standard option. Other systems (like Windows) are traditionally using slash instead dash when parsing options. Could be there some problem?

In theory, yes. In practice, even MSVC apparently recognized -Wall and turned the warnings on. Because cmake doesn't have a portable switch "please turn the warnings on", -Wall is the best thing we have right now.

-O2 can drop local variables from debug symbols

Yes, that's an unfortunate side effect, but in my opinion it's far outweighed by the speed benefits. I use that on a daily basis.

If you say that optimization should be enabled by default, does it mean -O2 is explicitly added to CXXFLAGS? Or by default is set CMAKE_BUILD_TYPE to RelWithDebInfo and optimization flags (depending on target compiler) are added to CXXFLAGS by cmake?

"That's an implementation detail."

Let's first decide on what sorts of audience we cater for and what "build profiles" we can expect, and then let's talk about how to get there.

a) Trojita developers. For me, this means Q_ASSERTs that remain active, optimized build, and debug symbols. Warnings must be on, and I'll go on and say that they should be fatal (similar to the current -DDEV_FATAL_WARNINGS=ON).

b) General users who couldn't care less about us, but run the git version for some reason. Optimizations are given. The industry appears to skip asserts which I can follow, even though I'm not thrilled by this. Do we want debug symbols? I'm inclined to say "yes".

c) Special circumstances where a single developer is debugging a hard-to-understand error. I agree that disabling optimizations might help in some cases. Debug symbols are a must, asserts should remain active, too. IMHO this is special enough that simply re-running cmake with custom CXXFLAGS is OK.

d) Distributions and other builds of releases (i.e. anything that corresponds to a signed git tag right now). Optimizations are present, asserts can be probably skipped. Dunno about debug symbols. In particular, do we want to distinguish this from b) above?

Maybe we can unify b) and d) -- about the only reason for distinguishing between them was that maybe those users who already bother with git could at least send us an occasional bugreport. Probably both b) and d) can be accommodated by CMAKE_BUILD_TYPE=RelWithDebInfo, or maybe just Release if we want to follow the rest of the crowd. Looking at the options which cmake sets for us, I think that they are acceptable optimization-wise, NDEBUG-wise and debug-symbols-wise. I would still add -Wall in there, though.

We can also probably unify a) and c). In that case, CMAKE_BUILD_TYPE=Debug is IMHO the most obvious choice, *but* we absolutely have to activate optimizations. I've wasted too much of my time already on unoptimized builds, and the difference is very real. So this means that we must at least check for clang or GCC in this build mode, and inject -O2 into CXXFLAGS if they are detected. I think that -Werror might make sense as well in this context to make bits a bit easier to control and to remove the number of externally visible toggles.

Opinions?

Cheers,
Jan

--
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/

Reply via email to