Hi,
I have searched the web for using lto with mspgcc, and it appears that
it is not yet officially supported. However, minus one minor bug it does
appear to work. The bug is if main is included in the lto then main does
not show up in the binary. The obvious workaround is to place a wrapper
around main. I give an example of what I mean below. The example shows
that inlining across object files works (specifically the externally
defined get_value is inlined in sub_main). It was compiled with
mspgcc-20120911.
Can anyone comment further on the state of lto support in mspgcc? Are
there any show stoppers I am likely to encounter when trying to compile
more complex code than this simple example?
Thanks,
Matt
Makefile
01 CC=/usr/mspgcc-4.7.0/bin/msp430-gcc
02 COMPILE_FLAGS+= -mmcu=msp430f1611 -O -Os -mmpy=none -Wall -Wshadow
03
04 main.firmware: main.o sub_main.o inlineable_functions.o
05 $(CC) $(COMPILE_FLAGS) -flto -o $@ $^
06 main.o: main.c
07 $(CC) $(COMPILE_FLAGS) -c $^
08 sub_main.o: sub_main.c
09 $(CC) $(COMPILE_FLAGS) -flto -c $^
10 inlineable_functions.o: inlineable_functions.c
11 $(CC) $(COMPILE_FLAGS) -flto -c $^
main.c
01 extern int sub_main(void);
02 int main(void) {
03 return sub_main();
04 }
sub_main.c
01 extern int get_value(int i);
02 int sub_main(void) {
03 *((unsigned int*)200) = get_value(0);
04 return 0;
05 }
inlineable_functions.c
01 int get_value(int i) {
02 return i + 10;
03 }
main.firmware: file format elf32-msp430
Disassembly of section .text:
00004000 <__watchdog_support>:
4000: 55 42 20 01 mov.b &0x0120,r5
4004: 35 d0 08 5a bis #23048, r5 ;#0x5a08
4008: 82 45 00 11 mov r5, &0x1100
0000400c <__init_stack>:
400c: 31 40 00 39 mov #14592, r1 ;#0x3900
00004010 <__do_copy_data>:
4010: 3f 40 00 00 mov #0, r15 ;#0x0000
4014: 0f 93 tst r15
4016: 08 24 jz $+18 ;abs 0x4028
4018: 92 42 00 11 mov &0x1100,&0x0120
401c: 20 01
401e: 2f 83 decd r15
4020: 9f 4f 58 40 mov 16472(r15),4352(r15);0x4058(r15),
0x1100(r15)
4024: 00 11
4026: f8 23 jnz $-14 ;abs 0x4018
00004028 <__do_clear_bss>:
4028: 3f 40 00 00 mov #0, r15 ;#0x0000
402c: 0f 93 tst r15
402e: 07 24 jz $+16 ;abs 0x403e
4030: 92 42 00 11 mov &0x1100,&0x0120
4034: 20 01
4036: 1f 83 dec r15
4038: cf 43 00 11 mov.b #0, 4352(r15);r3 As==00,
0x1100(r15)
403c: f9 23 jnz $-12 ;abs 0x4030
0000403e <main>:
403e: b0 12 4c 40 call #0x404c
00004042 <__stop_progExec__>:
4042: 32 d0 f0 00 bis #240, r2 ;#0x00f0
4046: fd 3f jmp $-4 ;abs 0x4042
00004048 <__ctors_end>:
4048: 30 40 56 40 br #0x4056
0000404c <sub_main>:
404c: b2 40 0a 00 mov #10, &0x00c8 ;#0x000a
4050: c8 00
4052: 0f 43 clr r15
4054: 30 41 ret
00004056 <_unexpected_>:
4056: 00 13 reti
------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users