Re: Whole program optimization / Link time optimization
Peter Bigot <[email protected]>
| Newsgroups | gmane.comp.hardware.texas-instruments.msp430.gcc.user |
|---|---|
| Message-ID | <CAPOJ94MicpmCKcNC-QJaknttfNSZ3saaMju3s3eS-z440EOp1w@mail.gmail.com> |
I've never tested mspgcc for any whole-program optimizations. A common and supported way to reduce space by eliminating unused material is -ffunction-sections -fdata-sections during compilation and -Wl,-gc-sections during linking. Peter On Sun, Apr 21, 2013 at 8:13 PM, Wayne Uroda <[email protected]> wrote: > Hi, > > Can anybody comment on LTO or WPO’s effect on optimizing for space - I > have run out of flash memory and would rather not refactor my code at the > moment. I only need 10 more bytes or so, for today at least... Yes it’s not > ideal, such is life. > > I am using mspgcc 20120406-p20120911 and when I pass `–flto` in both the > compilation and link stages it compiles fine but the linker complains > “unrecognized option '-plugin'”. I assume LTO isn’t supported at this time? > > So then I skipped intermediate .o files altogether and used the following > command: > msp430-gcc -mmcu=msp430f233 -Os -Wall -Werror -o Coyote.elf <all c files> > > I get the expected message that my code does not fit. > > Using –fwhole-program: > msp430-gcc -mmcu=msp430f233 -Os -Wall -Werror -fwhole-program -o > Coyote.elf <all c files> > > I get the following output: > C:\Users\WAYNEU~1\AppData\Local\Temp\cclYmoCC.o: In function `main': > main.c:(.init9+0x2): undefined reference to `systemDisableInterrupts' > main.c:(.init9+0x6): undefined reference to `PlatformInit' > main.c:(.init9+0xc): undefined reference to `systemEnableCrystalClock' > main.c:(.init9+0x2a): undefined reference to `delay' > main.c:(.init9+0x44): undefined reference to `delay' > main.c:(.init9+0x5e): undefined reference to `delay' > main.c:(.init9+0x78): undefined reference to `delay' > main.c:(.init9+0x80): undefined reference to `delay' > C:\Users\WAYNEU~1\AppData\Local\Temp\cclYmoCC.o:main.c:(.init9+0xa4): more > undefined references to `delay' follow > C:\Users\WAYNEU~1\AppData\Local\Temp\cclYmoCC.o: In function `main': > main.c:(.init9+0xf8): undefined reference to `batteryGetStateOfCharge' > main.c:(.init9+0x104): undefined reference to `chargeIsPresent' > main.c:(.init9+0x118): undefined reference to `delay' > main.c:(.init9+0x134): undefined reference to `delay' > main.c:(.init9+0x138): undefined reference to `infomemValidate' > main.c:(.init9+0x13c): undefined reference to `logicMainLoop' > collect2: ld returned 1 exit status > > > I then created two files, test1.c and test2.c > > test1.c: > ------------------------------- > void test2(void); > > void test1(void) > { > test2(); > } > > int main() > { > test2(); > return 0; > } > > ------------------------------- > > test2.c: > ------------------------------- > void test1(void); > > void test2(void) > { > test1(); > } > > ------------------------------- > > Compiling them: > msp430-gcc -mmcu=msp430f233 -Os -Wall -Werror -fwhole-program -o test.elf > test1.c test2.c > > C:\Users\WAYNEU~1\AppData\Local\Temp\ccs3TYlw.o: In function `main': > test1.c:(.init9+0x2): undefined reference to `test2' > collect2: ld returned 1 exit status > > Have I done something wrong? > > In the meantime, I will refactor. I don’t even expect WPO/LTO to give me > much of a space saving anyway. > > - Wayne > > > ------------------------------------------------------------------------------ > Precog is a next-generation analytics platform capable of advanced > analytics on semi-structured data. The platform includes APIs for building > apps and a phenomenal toolset for data science. Developers can use > our toolset for easy data analysis & visualization. Get a free account! > http://www2.precog.com/precogplatform/slashdotnewsletter > _______________________________________________ > Mspgcc-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mspgcc-users > > ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Mspgcc-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mspgcc-users