The International Simutrans Forum

 

Author Topic: [fix] improve GCC options in Makefile, make "no-debug" build turn off assertions  (Read 5952 times)

0 Members and 1 Guest are viewing this topic.

Offline neroden

  • Devotees (Inactive)
  • *
  • Posts: 831
  • Nathanael Nerode
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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10638
  • Languages: De,EN,JP
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:
Code: [Select]
-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.

Offline neroden

  • Devotees (Inactive)
  • *
  • Posts: 831
  • Nathanael Nerode
Extract from current GCC manual:
Code: [Select]
-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.

Offline neroden

  • Devotees (Inactive)
  • *
  • Posts: 831
  • Nathanael Nerode
Attached is a very small patch to enable
Code: [Select]
-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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10638
  • Languages: De,EN,JP
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.
« Last Edit: April 18, 2010, 08:10:42 PM by prissi »

Offline neroden

  • Devotees (Inactive)
  • *
  • Posts: 831
  • Nathanael Nerode
According 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.