Ticket #40 (new enhancement)

Opened 3 years ago

Support for whole program compilation mode

Reported by: debrouxl Owned by:
Priority: major Milestone: Version 1.00
Component: project Version: 0.96
Keywords: Cc:

Description

The whole program compilation mode (gcc -fwhole-program --combine switches), is desirable to use on our embedded-type platform: it yields maximum interprocedural optimization, so it is likely to result in speed and/or size improvements.

Currently, it's fairly unreasonable to use this mode, because it is experimental in GCC 4.1: compiler crashes and incorrect code generation may happen.
However, this mode is more usable in GCC 4.3 and 4.4 (see ticket #39): IPO is both more powerful and more stable in those versions. If and when the TIGCC patch is ported to those versions, programs would benefit from using this mode.

Currently, neither TIGCC IDE, nor KTIGCC, nor tprbuilder, nor tigcc support this compilation mode. One has to resort to observing what tigcc invokes when compiling all sources together, and building upon those invocations to call gcc, patcher, as and ld-tigcc directly. For example:

 tigcc -v -DUSE_TI89 -DMLINK_FORMAT_RELOCS -DLANG_$1 -Os -fno-if-conversion -fno-function-cse -fomit-frame-pointer -mregparm=5 -ffunction-sections -fdata-sections --merge-constants -fmerge-all-constants -Wa,--all-relocs -Wall -W -Wwrite-strings -save-temps -mno-bss -freg-relative-a5 --optimize-code --cut-ranges --reorder-sections -fwhole-program --combine logo.c generic.c bg_ti89.c input.c interrupt.c board.c loadsave.c infoboards.c menu.c gui.c engine.c clocks.c tichess.c -o ticstart -pack tichess

translates to something like

 $TIGCC/bin/gcc -v -DUSE_TI89 -DMLINK_FORMAT_RELOCS -DLANG_french -O2 -fno-if-conversion -fno-function-cse -fomit-frame-pointer -mregparm=5 -ffunction-sections -fdata-sections -fmerge-all-constants -Wall -W -Wwrite-strings -save-temps -mno-bss -freg-relative-a5 -fwhole-program --combine -B/usr/local/tigcc/bin/ -I/usr/local/tigcc/include/c logo.c generic.c bg_ti89.c input.c interrupt.c board.c loadsave.c infoboards.c menu.c gui.c engine.c clocks.c tichess.c -S -o tichess.s
 $TIGCC/bin/patcher tichess.s -o tichess.s
 $TIGCC/bin/as -mc68000 -I/usr/local/tigcc/include/s tichess.s -o tichess.o --all-relocs --keep-locals
 $TIGCC/bin/ld-tigcc -v --merge-constants --optimize-code --cut-ranges --reorder-sections tichess.o /usr/local/tigcc/lib/tigcc.a -o ticstar # --outputbin-main-only
 ttppggen ticstar.89z tichess

Under Windows, neither patcher nor ld-tigcc are currently provided as standalone executables, so the above series of invocations currently works only under *nix. That's what ticket #31 tracks.

Therefore, support for whole program compilation mode without having to call the internal tools directly requires changes to all other higher-level tools...

Note that GCC 4.3 and 4.4 implement function-specific compilation switches: this way, whole program compilation mode doesn't necessarily result in compilation of all chunks of the program with the same switches.

Note: See TracTickets for help on using tickets.