Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: Marsu42 on September 05, 2012, 11:05:34 AM

Title: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 11:05:34 AM
I'm just setting up the arm toolchain and noticed that that the summon-arm script contains the outdated gcc 4.6.2 (current is 4.6.3).

Is there any reason to use this particular gcc release, and why doesn't it use the current linaro 4.6 or 4.7 gcc which is supposed to be the latest and greatest for building arm compiles? Is it just because of "never touch a running system" or does any more current gcc release make your cameras crash and burn? What gcc do you guys use?
Title: Re: Compile ml w/ Linaro gcc?
Post by: a1ex on September 05, 2012, 11:10:29 AM
I'm interested too, if you succeed, please let me know (especially if there are any performance improvement). I couldn't compile with Linaro, but that was many months ago.
Title: Re: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 11:14:12 AM
Quote from: a1ex on September 05, 2012, 11:10:29 AM
I'm interested too, if you succeed, please let me know (especially if there are any performance improvement). I couldn't compile with Linaro, but that was many months ago.

Hmmmm, I'm still somewhat critical about the guinea pig role, but I've been using Linaro for years to compile OpenWrt for my router (though it is mips and Linaro improvements are mainly for arm). And since I'm no ml insider, it is very unlikely I could recognize any performance improvements, or are there any dev benchmark tools hidden somewhere in ml? But I'll let you know if it compiles, and if I'm to hesitant to try it myself maybe you could have a go with your sponsored guinea pig hardware :-o
Title: R: Compile ml w/ Linaro gcc?
Post by: nanomad on September 05, 2012, 11:14:36 AM
I use the 32bit compiler binary mantained by arm. The link should be in the sticky thread

The stability test sub-menu has some benchmarks too if I'm not mistaken
Title: Re: Compile ml w/ Linaro gcc?
Post by: a1ex on September 05, 2012, 11:22:53 AM
Well... if you make the Linaro work with ML (just compile it and tell me what changes you had to do), I'll do the rest. You don't have to try it on your camera for the first time.
Title: R: Compile ml w/ Linaro gcc?
Post by: nanomad on September 05, 2012, 11:31:45 AM
A1ex, how about a compiler "race" then?
Title: Re: Compile ml w/ Linaro gcc?
Post by: a1ex on September 05, 2012, 11:39:43 AM
Sounds good.

I think this is best done in playback mode (where Canon tasks are idle), with some operation that feels a bit slow on ML right now (like focus peaking or defishing).

Compiling with -O3 also has noticeable speed improvements, but it caused trouble on 500D so I've turned it off in 2.3.
Title: Re: Compile ml w/ Linaro gcc?
Post by: nanomad on September 05, 2012, 11:51:49 AM
I just realized that we are using the same cpu the Nintendo DS has. It was fun porting linux to it. We don't have much cpu power eh?
Title: Re: R: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 11:53:38 AM
Quote from: nanomad on September 05, 2012, 11:14:36 AM
The stability test sub-menu has some benchmarks too if I'm not mistaken

Alex' post implies that you are mistaken - but I'll have a go at compiling it w/ Linaro and let you know my findings. There shouldn't be too many changes necessary (unless I try 4.7), Linaro is proven & stable and is the default compiler on Ubuntu.
Title: Re: Compile ml w/ Linaro gcc?
Post by: a1ex on September 05, 2012, 12:01:26 PM
There's enough CPU power to run a basic operating system, with file I/O, multitasking, even some simple image processing at 720x480 at 20fps in parallel with LiveView (that's the new focus peaking).

Trammell was able to write to display from bootloader context, without starting the main firmware: http://vimeo.com/7851909

Also, the bootloader has basic file I/O and probably direct card access too.
Title: Re: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 12:01:47 PM
Quote from: a1ex on September 05, 2012, 11:39:43 AM
Compiling with -O3 also has noticeable speed improvements, but it caused trouble on 500D so I've turned it off in 2.3.

... that's the CFLAG in line 161 in Makefile.inc which is -Os in the current hg checkout, so I can should/can change that to -O3 if the target is my 60d?
Title: Re: Compile ml w/ Linaro gcc?
Post by: a1ex on September 05, 2012, 12:04:46 PM
I usually only add these lines:

# compile some modules with -O3 for increased speed
zebra.o: $(SRC_DIR)/zebra.c
$(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<)
menu.o: $(SRC_DIR)/menu.c
$(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<)
bmp.o: $(SRC_DIR)/bmp.c
$(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<)
chdk-gui_draw.o: $(SRC_DIR)/chdk-gui_draw.c
$(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<)

You can try to compile everything with -O3 too, it usually works, but the binary size will increase quite a bit.
Title: Re: Compile ml w/ Linaro gcc?
Post by: nanomad on September 05, 2012, 12:52:15 PM
Ok, digging out my old DSLinux stuff...here's what we used:
-g -Wall -Os -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math
Maybe it's worth a shot

fomit-frame-pointer is actually redundant but the march and mtune can generate optimized code paths
Title: Re: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 08:17:42 PM
Quote from: nanomad on September 05, 2012, 12:52:15 PM
Maybe it's worth a shot

Harrrgnnn ... now *that* was annoying, but I managed to compile ml with latest Linaro gcc 4.6 series (d/l from Launchpad) and even valiantly tested it - runs fine so far :-)

However, I couldn't persuade summon-arm to get even fsf gcc to compile on my x64 Ubuntu lts system, so I used the arm toolchain from https://launchpad.net/gcc-arm-embedded and replaced their gcc source with Linaro before running their build-toolchain.sh ... and I had to patch newlib, see the patch @ http://sourceware.org/ml/newlib/2011/msg00076.html

If you manage to write some benchmark we might even see if it was worth it - but since Linaro is working on optimizing gcc for arm for years, I think it certainly cannot be worse than the vanilla version. And we could try to compile ml with Linaro gcc 4.7, but without any benchmarks it would be a waste of time because we cannot tell the difference offhand.


Title: Re: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 08:58:19 PM
... btw, here's the autoexec if anyone wants to run a stability test and is to lazy to compile Linaro gcc: [link deleted: obsolete]
Title: Re: Compile ml w/ Linaro gcc?
Post by: ilguercio on September 05, 2012, 09:29:48 PM
Thanks, will try it out.
Title: Re: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 09:32:26 PM
Quote from: ilguercio on September 05, 2012, 09:29:48 PM
Thanks, will try it out.

... and remember it's the latest trunk, so if anything's broken it might be very well the sourcecode itsself, too.
Title: Re: Compile ml w/ Linaro gcc?
Post by: ilguercio on September 05, 2012, 09:37:14 PM
Got an error, here's the log file.
Looks huuuge.

https://dl.dropbox.com/u/1087972/ML/log000.log
Title: Re: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 09:40:55 PM
Quote from: ilguercio on September 05, 2012, 09:37:14 PM
Got an error, here's the log file.
Looks huuuge.

:-) ... what did you do to throw the error? I turned on all optimizations the devs recommended for the 60d, but they also said that might decrease stability. Maybe the next step should be to compile it with standard settings and Linaro 4.6 and then 4.7 to isolate the cause of problems - but as I wrote it runs just fine on my 60d as far as I can see, but your 50d is another model alltogether.
Title: Re: Compile ml w/ Linaro gcc?
Post by: ilguercio on September 05, 2012, 09:56:09 PM
Let me try to reproduce it.
I just opened LV with focus peaking active.
Title: Re: Compile ml w/ Linaro gcc?
Post by: a1ex on September 05, 2012, 10:00:37 PM
Be careful, some bleeding edge focus peaking modes won't work on 50D.
Title: Re: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 10:02:13 PM
Quote from: ilguercio on September 05, 2012, 09:56:09 PM
Let me try to reproduce it.
I just opened LV with focus peaking active.

Alex did some changes to focus peaking recently (see changelog), it might be buggy. I'll do Linaro compiles for the stable 2.3 tag, optimized and non-optimized, this should be better than testing the unstable trunk. Check this thread again tomorrow at latest for the d/l links.
Title: Re: Compile ml w/ Linaro gcc?
Post by: ilguercio on September 05, 2012, 10:02:51 PM
Ok, that might be it then.
Want me to tell you which modes do not work?
Title: Re: Compile ml w/ Linaro gcc?
Post by: nanomad on September 05, 2012, 10:32:06 PM
Please do all tests on 2.3 stable (it's tagged on bitbucket as ML2.3-stable, revision afdeefef62fa)

edit: just realized that ML uses -march so it should be good. The makefile is a mess though ::)
Title: Re: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 05, 2012, 11:43:22 PM
Quote from: a1ex on September 05, 2012, 12:04:46 PM
I usually only add these lines:

@alex: *Where* do I add these lines in the Makefile.inc? In the places I tried they are ignored and everything is compiled with -Os in spite of the special lines with -O3 for zebra.o and so on...

Quote from: nanomad on September 05, 2012, 10:32:06 PM
edit: just realized that ML uses -march so it should be good.

... still, if the exact cpu is known shouldn't be -mtune=arm946e-s or even -mcpu=... better in addition to -march?

Quote from: nanomad on September 05, 2012, 10:32:06 PM
Please do all tests on 2.3 stable (it's tagged on bitbucket as ML2.3-stable, revision afdeefef62fa)

Ok, here it goes - standard -Os compile with current Linaro gcc 4.7, working ok on my 60d, anyone feel free to try it for regressions to the release build with the vanilla fsf compiler: https://dl.dropbox.com/u/94419838/ml-2.3.linaro47-test1.marsu42.zip
Title: Re: Compile ml w/ Linaro gcc?
Post by: ilguercio on September 06, 2012, 12:01:07 AM
This looks ok to me ;)
Title: Re: Compile ml w/ Linaro gcc?
Post by: ilguercio on September 06, 2012, 02:11:04 AM
Only one thing, wasn't movie restart working on 50D lately?
There was a fix by somebody, i read about it on google groups.
Title: Re: Compile ml w/ Linaro gcc?
Post by: Marsu42 on September 06, 2012, 10:01:40 AM
Quote from: ilguercio on September 06, 2012, 02:11:04 AM
Only one thing, wasn't movie restart working on 50D lately?
There was a fix by somebody, i read about it on google groups.

My compile is the ml2.3 release build, if it's not working in alex' official version it won't work on this one (and I have got a 60d, not a 50d). But feel free to install mercurial & gcc yourself and add the patch from google groups, it just takes a day to set it up :->