News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

[fix] improve GCC options in Makefile, make "no-debug" build turn off assertions

Started by neroden, April 17, 2010, 08:31:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

neroden

This does a couple of different things in the main Makefile:
(1) eliminates -ffunctions-sections.  I'm pretty sure this doesn't do anything any more, and I can't find it in either the GCC or binutils manuals -- even really old ones.
(2) Adds -fno-schedule-insns.
(3) Builds the profile build with the same options as the regular build.  This is necessary in order to get a useful profile, frankly.
(4) Adds -DNDEBUG (eliminating assertions) to non-debug builds.

If any of these cause problems that I haven't thought of please let me know.

prissi

No inlines was something, that was needed for useful profiling imho. Otherwise the calling graph was all messed up in the past. I need to check this in the current setting though.

Quote
(1) eliminates -ffunctions-sections.  I'm pretty sure this doesn't do anything any more, and I can't find it in either the GCC or binutils manuals -- even really old ones.
Extract from current GCC manual:

-ffunction-sections
-fdata-sections
    Place each function or data item into its own section in the output file if the target supports arbitrary sections. The name of the function or the name of the data item determines the section's name in the output file.

    Use these options on systems where the linker can perform optimizations to improve locality of reference in the instruction space. Most systems using the ELF object format and SPARC processors running Solaris 2 have linkers with such optimizations. AIX may have these optimizations in the future.

    Only use these options when there are significant benefits from doing so. When you specify these options, the assembler and linker will create larger object and executable files and will also be slower. You will not be able to use gprof on all systems if you specify this option and you may have problems with debugging if you specify both this option and -g.

(Also the linux kernel is apparently compiled with those enabled.)

Last time I checked (which is same years ago, Simutrans benefitted from them. Although lots of dead code was removed since then.

A last thing: Should asserting not be disabled anyhow, when DEBUG is not set? I remember at least one such bug report.

neroden

Quote from: prissi on April 17, 2010, 10:23:57 PM
Extract from current GCC manual:

-ffunction-sections


Oh.  The option is mis-spelled.  (It would need to be -ffunction-sections, not -ffunctions-sections). It hasn't been doing anything for a while....

Quote
A last thing: Should asserting not be disabled anyhow, when DEBUG is not set? I remember at least one such bug report.
Well, that's a choice, we can leave asserting on even for non-debug builds.  That's OK.

neroden

Attached is a very small patch to enable -ffunction-sections.  I don't know whether it's a good idea to enable it, but the current option is mis-spelled and won't work, so we should either enable it or remove it.  According to the documentation, the option should be used in both the compiler and the linker.

prissi

If I understood correctly, -ffunction-sections should remove dead code. However, most of the dead code was cleaned up in between, so I am not sure, this is still useful. Needs some more testing, I think. I will incorporate the other stuff first.

According to docu, "-fomit-frame-pointer" is also automatically turned on for and -O? level. So this can aparently go too.

neroden

Quote from: prissi on April 18, 2010, 08:06:52 PMAccording to docu, "-fomit-frame-pointer" is also automatically turned on for and -O? level. So this can aparently go too.

Well, I was leaving that in case it was compiled on very old versions of GCC.  I didn't check whether gcc 2.95 turned that on automatically.