-
Notifications
You must be signed in to change notification settings - Fork 13.3k
build gcc with lto support #23
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? No Sign in to your account
Comments
I think there is also an issue with the way gcc was compiled, so that the libiconv-2.dll, is required to be in the root of the Arduino IDE This would prevent the repo being deployed by the new Boards Manager in IDE 1.6.2 or newer Edit. libicon-v.dll problem still exists. This should be fixed at the same time if possible. |
Yes, thanks, looks like there are currently 3 issues that need to go into the toolchain:
For Windows I used this build script: For Linux and Mac I used crosstool-NG (branch lx106-g++). @nerdralph what options do we need to pass to build gcc with lto support? |
Ivan, Did you manage to fix the libiconv-2 dependency issue ? PS. How did you run the script under windows Mingw? |
No I didn't have a chance yet — I'm running OS X and for all the Windows stuff I have use my old laptop which I usually can access on weekends. For the build, yes, I did use mingw. |
OK |
It was a lot of work to figure out lto support for avr-gcc, so I imagine it
|
Ivan I've installed MinGW on my Windows machine, and I'm going to build (well I'm building) the using the script you linked to. Do you have any idea's why we have the issue with libicobv-2.dll ? I presume its a path issue? The other version of the Xtensia compiler didn't have that issue, but I know the build switches were incorrect. I presume the build.sh you linked to does build with the correct switches ? I also presume it must be downloading a config file where somehow libiconv-2.dll path can be referenced ? Anyway, I better leave it compiling, as I expect it may take several hours (or I can leave it on all night if necessary ;-) Edit. I had some issues with Git not being installed by default with MinGW and have now fixed those, but I will need to try again tomorrow as its getting too late to continue tonight If you have any tips for getting it to compile please let me know ;-) |
There should be a way to tell gcc's configure script to link statically to libiconv. But I don't know which exact options are required for this though... |
Perhaps this one might be useful: http://stackoverflow.com/a/14112368 |
Ivan I've tried building on 2 different Windows 7 x 64 machines (more core i5 and one core2) and both just hang after a while in gcc :-( This part of the script gives a warning ./ error
but I think its OK, because its just a clumsy way to rename the file to what its already called (and fails on MinGW). I guess I could try installing XP as a VM and see if it doesn't hang when I do that. Edit. --enable-static and --disable-shared --enable-static are used But perhaps not everywhere |
Oh, right, it does hang quite a lot. |
Thanks I changed to -j1 , and its no longer hanging I'll see if it manages to complete a compile and then see what static link settings need to change, if any I'll also need to do some research about Lto as recommended by @nerdralph |
Ivan
|
Maybe I did... I'll check on my windows laptop tomorrow. On Fri, Apr 3, 2015 at 10:46 AM, Roger Clark notifications@github.com
|
Ivan, Its OK. I worked out what was wrong. I'm not sure how this happened. Anyway, it looks like its a big repo, so I will leave it downloading and look again tomorrow Apart from that, the build now seems OK, If you do run your windows laptop, could you tell me if you get compiler warnings all the time for "llabs" not being defined ? Thanks |
I'm not sure why this works, but Sampreet's repo works on IDE 1.6.3 without needing libiconv-2.dll in the IDE root directory. Anyway. On the build front. g++ and a few other things are still not getting built for me, so I'll need to track down where in build.sh creates them. Re: LinkTimeOptimization It looks like currently adding -flto makes no difference to the output size, but it still compiles OK. But as @nerdralph has indicated, gcc would need to be built with LTO enabled as part of the build, and at the moment, its not too clear how to do this, or whether its possible on the Xtensa version of gcc I found this reference https://gcc.gnu.org/wiki/LinkTimeOptimization Which seems to say that the LTO version is a branch from the main GCC repo But I can't see a branch for LTO on https://github.com/jcmvbkbc/ so I guess the only thing would be to try adding the --enable-lto and see if it gets passed down into the actual compile in the same way as --enable-static is supposed to. However at the moment I think this is not a top priority, as its probably a lot of work / waiting for compiles to finish etc, for possibly not too much difference for most people |
Gcc 5.0 has a lot of new IPA optimizations, even without lto:
|
@rogerclarkmelbourne were you able to make some progress with the gcc build? |
Hi Ivan I tried on a Window XP VM, but it kept hanging like it did before I change the jobs settings But the jobs settings was -j1 But nothing worked :-( I have been too busy with the Boards Manager issues on my other repo STM32 If you send me your XP build script I can try it, but apart from that I don't know how to proceed. PS. I'm not sure if we also need to try gcc 5, but I think it will probably have its own problems ;-) |
I checked my build script and it's no different from the one linked above, aside from -j1 option. |
Ivan, I have been using Azure for work, but its expensive and not very fast unless you pay $$$$ . I'm not sure if its possible to request a 32 bit machine on Azure. I think you would be better off dual booting your computer or using a VM. Do you run Linux or OSX? I ran an vm on OSX with XP int it. ( I think I used virtual box ) But I also tried XP 32 bit under VM on windows 7 x64, and the compiler keeps hanging :-( I guess I should find a copy of Windows 7 , 32 bit and run that in the VM and see if the compiler still hangs. But perhaps the compiler doesn't work in the VM ( virtual box), and perhaps I need to try VirtualPC |
What version of MinGW are you using ? I have been using http://sourceforge.net/projects/mingw/postdownload?source=dlp but I noticed there is another version called MinGW-W64 which seems to be gaining traction and claims to be contain the latest / later releases of gcc However, it doesn't seem to have bash shell so I can't fun the script that Ivan uses Anyway, I've made a new Windows 7 X86 VM using Microsoft Virtual PC and I will see if that runs Ivans' script any better than the Oracle Virtual Box VM running XP 32 bit. |
Roger,
|
That should be __USE_MINGW_ACCESS
|
Just tried another avr-gcc build on MinGW, with __USE_MINGW_ACCESS, and make -j2, and it locked up again. This is with the stock mingw gcc-4.8.1 and binutils. Looks like parallel builds are out for now. |
Ralph Thanks for the info. I tried using Microsoft Virtual PC and a copy of Windows 7 x86, instead if virtual box, but the shared drives with the host are not working, ( aaarrrghhh), which makes it a pain to use, so I may go back to Oracle Virtualbox but with Window 7 x86 rather than XP. Where in the script do you add __USE_MINGW_ACCESS ? |
Roger, first look for a configure option for gcc... Perhaps
|
Ralph, It looks like esp-newlib contans iconv sources BTW. https://github.com/pfalcon/esp-open-sdk However its not clear how to build this on Windows. I guess perhaps I should post an issue on that repo to see if there are windows build instructions |
@rogerclarkmelbourne I got my windows laptop back and looks like I'm making progress. |
Ivan OK. I'm not sure if you saw the issue has been fixed in Sandeep's repo, as someone found if you add the dll in 2 different places, it solves the problem But if you have totally removed the dependencies that's an even better solution |
No I haven't seen that solution, will check.
|
PS. I presumed that Sandeep had contacted you ;-( |
That way is actually preferrable because the code is not statically linked into multiple gcc executables (gcc, gcc-version, g++, c++, etc). Will update my toolchain archive accordingly. |
Cool... Glad to be vaguely useful ;-) (as I failed to recompile the compiler ) |
Based on builds I've done of gcc on Linux, static linking had less of an On Tue, May 5, 2015 at 3:10 AM, Ivan Grokhotkov notifications@github.com
|
I'm working on building an alternative sdk: kireevco/esp-alt-sdk, which is based on similar concept as esp-open-sdk, but is meant to work on all plarforms, including Windows. It's not using crosstool-ng, and should work on mingw32,64 and probably cygwin. Currently I have a build working, some people reported errors, some people reported it working. I'm experimenting with https://github.com/fpoussin/esp-binutils vs https://github.com/jcmvbkbc/binutils-gdb-xtensa (latter has gdb in it). Any thoughts/testing/contributions are welcome! |
I think the ideal would be taking Max's work and creating a script to add
|
@nerdralph not sure what do you mean, can you clarify please? |
Max's gcc-xtensa is based on gcc 4.8.2.
|
So, you want to take https://gcc.gnu.org/releases.html, and add lx106? That's pretty tough step, I think it's been maintained here https://github.com/jcmvbkbc/gcc-xtensa/tree/lx106-5.1? |
By the way, how crosstool-ng is structured? I can't find a clear set of instructions how they build binutils? |
You were asking for feedback; you didn't say it had to be easy. :-)
|
:-) fair enough:)
Well, that sounds great, really! |
I didn't get very far into crosstool-ng before I decided it was an option I
|
@nerdralph that's the issue I'm trying to solve with esp-alt-sdk. Crosstoon-ng is way far from working ok on Windows, and I need to re-do the logic that is under |
@nerdralph just for fun, I'm trying to build binutils, gcc for xtensa target... we'll see how it goes. |
Dont know if this issue is still valid but since I was searching for a newer GCC version (better
Link: http://gnutoolchains.com/esp8266/ That might be the desired GCC 5.2. |
This hopefully fixes many confusing errors regarding undefined functions. Moving away from .h files makes it a lot easier for those files to call each other. Unfortunately, this comes at a cost of code size: link-time optimization (inlining etc. across compilation units) hasn't been enabled for the ESP8266 port yet. See: esp8266/Arduino#23
add send packet size calculator
@igrr we discussed briefly moving to a newer toolchain, namely 5.2, which is the same as mentioned here. Would that address the issues discussed above? |
While this issue does depend on updating to 5.2.0, there's (much) more to LTO support than just a toolchain update. Some core/libraries changes will be required for binaries built with LTO to actually work. |
The included gcc wasn't built with the linker plugin, so enabling link-time optimization (-flto) fails.
dlopen:'.../arduino-1.6.1/hardware/tools/esp8266/xtensa-lx106-elf/bin/../libexec/gcc/xtensa-lx106-elf/4.8.2/liblto_plugin-0.dll': The specified module could not be found.
Lto not only reduces code size, it can significantly improve performance by doing constant folding for function calls like digitalWrite.
http://nerdralph.blogspot.ca/2014/04/gcc-link-time-optimization-can-fix-bad.html
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: