10

If debug information is stored in a program database (not as part of an executable), is there any reason not to always build with it (e.g., MSVC's /Zi)?

In CMake, the default configurations are, "Release", "Debug", "RelWithDebInfo", and "MinSizeRel". Is there a reason not to only use "Debug" and "RelWithDebInfo" (perhaps renamed to "Release")?

Does it have any impacts on the size or performance of the code? Is the answer different for gcc or clang than it is for Visual C++?

Update

I did come across these posts that are similar:

However, neither of these get to the question of Release vs. RelWithDebInfo.

Yes. I could do a test on an executable with Release vs. RelWithDebInfo. That would definitely give me the answer about the size of the code, but would be very difficult to conclude that it has NO impact on performance if my test case showed similar performance. How would I know if I exercised aspects of the language that might be impacted by the change? That is, empirical testing could produce a false negative.

Neal Kruis
  • 1,975
  • 2
  • 25
  • 47
  • cant you build with and without and see the difference? – 463035818_is_not_a_number Dec 07 '17 at 21:02
  • I can figure out empirically, but my question is more about the theory. Is there SUPPOSED to be a difference? – Neal Kruis Dec 07 '17 at 21:05
  • Very close, if not an outright duplicate: https://stackoverflow.com/q/947401/10077 – Fred Larson Dec 07 '17 at 21:07
  • 5
    @FredLarson Releasing software in debug mode is not the same as releasing software with debug info. – user7860670 Dec 07 '17 at 21:10
  • 2
    The only reason I can think of is that generating debug info takes time. So building with debug information is slower. But other than that, code size and performance are the same with/without debug info. – geza Dec 07 '17 at 21:56
  • 1
    Thanks, @geza. That's the answer I was looking for (and confirms my suspicion). – Neal Kruis Dec 07 '17 at 22:04
  • yes really. When I dropped the comment there was zero evidence of any research from your side. Not sure what it has to do with eagerness, actually I am rather hesitant to use those links and I think it is the first time it did so. – 463035818_is_not_a_number Dec 07 '17 at 22:26
  • 1
    Fair enough. I posted a little hastily, but your rationale wasn't very fair either. A test build would not be conclusive. – Neal Kruis Dec 07 '17 at 22:36

1 Answers1

6

Releasing with debug info is mandatory for real-life development. When shit happens your primary tool would be a crash dump analysis that would be rather pointless without debug information. Note that this does not imply shipping debug info with product.

As for "little differences" between vc++ and gcc I would like to mention that by default vc++ emits debug information in a separate file while gcc will squeeze it into executable. It is possible to separate debug information on gcc as well, however doing so is not as convenient and requires some extra steps.

user7860670
  • 33,577
  • 4
  • 51
  • 80
  • So do you only build RelWithDebInfo and Debug (or their equivalents for non-cmake build systems)? Are there other configurations you use? Would your answer change for gcc since it makes the executable larger? – Neal Kruis Dec 07 '17 at 22:21
  • @NealKruis: the best way in my opinion is to generate with debug info. And then create a without-debug info executable from the with-debug info executable. Check out the like VTT provided in the answer. A without debug info build is only useful in the case when the debug info is surely not needed. – geza Dec 08 '17 at 00:04
  • @NealKruis: note: even, if the executable is larger, the code is not. Furthermore, the OS will only load parts from the exe which are needed for execution. So the debug info won't be loaded. – geza Dec 08 '17 at 00:16
  • @NealKruis Even if I have to use cmake I typically don't rely on build-in configurations and manually write all the compiler options. – user7860670 Dec 09 '17 at 17:47