Page 1 of 1

Linux - Debug {Split}

Posted: Fri Jul 31, 2015 6:14 am
by Blackstorm
Microsoft rules to compile 32 and 64bits plateforms. ... s.85).aspx

On Linux 64 you are using gcc with x64 libs by default. On windows the default compiler type should be in 32bits.

I'am not sure the link is useful for the question but can help ^^

Re: Peer Code Reviews

Posted: Fri Jul 31, 2015 6:48 am
by John Adams
Black, since you manage our "makefile", is there a flag in there for DEBUG? And, what is the effect if we remove it? ie., no more gdb debugging on linux, etc

Re: Peer Code Reviews

Posted: Fri Jul 31, 2015 8:38 am
by Blackstorm
I know in the make file we have a VG_DEBUG flag, but i don't know if we have a compiler debug flag value.
I am checking.

Edit: We have a -g arg into the WFLAGS the should be used to generate some debug.

Code: Select all

Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2). GDB can work with this debugging information.
On most systems that use stabs format, -g enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but probably makes other debuggers crash or refuse to read the program. If you want to control for certain whether to generate the extra information, use -gstabs+, -gstabs, -gxcoff+, -gxcoff, or -gvms (see below).

GCC allows you to use -g with -O. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values are already at hand; some statements may execute in different places because they have been moved out of loops.

Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.

The following options are useful when GCC is generated with the capability for more than one debugging format. 
also i see this thread : ... difference

maybe we should replace -g by -ggdb to improve the compatibility and the output msg (it's say: gdb can use the -g but i think it's not espacialy for it and we recommend to use gdb for vg debug ^^)

ok, so, with gcc, you have not really a "release" or a "debug" mode ( ... ons-in-gcc)
it's depend of what optimizations are used.
see : ... tions.html

Actually we are running gcc with the simple -O optimization and -g (should be equivalent to "debug" VS mode), and that should be -02 -s -DNDEBUG for an equivalent of "Release" VS optimization.
(see the 2nd answer)

i've tried to compile on linux vg_world with the optimized (-02 -s -DNDEBUG) options. I have no problem.

Of course, if we remove all debug info from the compiler, we will have an optimized and light binary, but we have no more debug.
An intermediate case should be : -02 -ggdb
so you have some optimizations and gdb debug (with all symbols)

Re: Peer Code Reviews

Posted: Fri Jul 31, 2015 2:51 pm
by John Adams
Perfect answer, Black. Thank you for looking at that. I was mostly curious if we needed to maintain a 2nd makefile for "optimized" mode; it would be important to see our performance as we go because I never trust Debug to be a good measure.

I will look into the Release (non-debug) of VS2012 as well. I think it's time to come out of hiding.

Re: Peer Code Reviews

Posted: Fri Jul 31, 2015 2:58 pm
by Blackstorm
on Linux the make file can be modified to use : "make debug" like you use "make clean", so in place of "release" vars the process will use the "debug" vars.
So we will have only one make file to manage ^^ i can make these modifications if wanted.

Re: Peer Code Reviews

Posted: Fri Jul 31, 2015 3:57 pm
by John Adams
Sure, let's do it for our Linux friends. Please make the default "debug" though, meaning if I just type "make -j8" like I do now, it will compile Debug.

I assume if I wanted, I could then type "make release -j8" to make the release binary.

Re: Linux - Debug {Split}

Posted: Fri Jul 31, 2015 5:09 pm
by Blackstorm
done, i will update the svn just with that file. I just need some minutes to cleanup my own Makefile.. because...

edit: updated. John, can you try it on Ubuntu please and tell me if these args are good for you ?

- New Makefile to manage Debug and Release builds.

make (debug build: -O -ggdb)
make debug (debug build: -O -ggdb)
make release (release build: -O2 -s -DNDEBUG)[/quote]

Re: Linux - Debug {Split}

Posted: Fri Jul 31, 2015 6:03 pm
by Blackstorm
added a fix to use the args into the subfunctions.
i.e: make release -j8

Re: Linux - Debug {Split}

Posted: Fri Jul 31, 2015 7:31 pm
by John Adams
Take 2, decided to try them all for you First response:

On Unbuntu, my "make release -j8" compiled using -DVG_DEBUG still.

Code: Select all

g++ -c `mysql_config --cflags` -march=native -pipe -pthread -O2 -s -DNDEBUG -std=c++0x -Wall -Wno-reorder -DVG_WORLD -DVG_DEBUG -D_GNU_SOURCE SpawnUtil.cpp -o SpawnUtil.o
I see -DNDEBUG in there.

"release" binary size
2540344 Jul 31 19:25 vgemu-world

Debug compile:

Code: Select all

g++ -c `mysql_config --cflags` -march=native -pipe -pthread -O -ggdb -std=c++0x -Wall -Wno-reorder -DVG_WORLD -DVG_DEBUG -D_GNU_SOURCE SpawnUtil.cpp -o SpawnUtil.o
Debug size:
44094335 Jul 31 19:29 vgemu-world

So yes, I do believe it is correct. The VG_DEBUG is just our preprocessor for use in the code, and not about "Debug Mode" at all.

Re: Linux - Debug {Split}

Posted: Fri Jul 31, 2015 7:49 pm
by Blackstorm
[quote="John Adams"]
I see -DNDEBUG in there.

"you'll build the Release CFLAGS version where optimization is turned on (-O2), debugging symbols stripped (-s) and assertions disabled (-DNDEBUG)."