Hello Everybody. I have problem with huge code whitch generates by arm-elf-g++. I red post in this forum but my case is other. I can't use options CXXFLAGS +=-nostdlib because i use #include<vector> and operator new in my class and code etc. I wrote simple program and everything work properly without large code, a simple blinking led - code have 71kb nightmare. I use syscalls.c and ofcourse reduce code about 2 kb, mayby i should write more definitions. Please help me. In attachment I include syscalls.c (this file isn't my). Bestregards Michal Wolo
Michał Wolo wrote: > Hello Everybody. > > I have problem with huge code whitch generates by arm-elf-g++. I red > post in this forum but my case is other. I can't use options CXXFLAGS > +=-nostdlib because i use #include<vector> and operator new in my class > and code etc. I wrote simple program and everything work properly > without large code, a simple blinking led - code have 71kb nightmare. I > use syscalls.c and ofcourse reduce code about 2 kb, mayby i should write > more definitions. Please help me. In attachment I include syscalls.c > (this file isn't my). Bestregards Michal Wolo you can try to disable the exception if you don't need it. it will reduce the code. But for the rest, I really don't know. Jonathan
Michał Wolo wrote: > Hello Everybody. > > I have problem with huge code whitch generates by arm-elf-g++. I red > post in this forum but my case is other. I can't use options CXXFLAGS > +=-nostdlib because i use #include<vector> and operator new in my class > and code etc. I wrote simple program and everything work properly > without large code, a simple blinking led - code have 71kb nightmare. I > use syscalls.c and ofcourse reduce code about 2 kb, mayby i should write > more definitions. Please help me. In attachment I include syscalls.c > (this file isn't my). Bestregards Michal Wolo Hello, I wrote a G++ demo for the LPC2148 that just takes 3 or 4 KB, you need to specify -fno-rtti as option, this saves a LOT of space (of course if you don't need RTTI). If you want to look at the demo code, try here: http://sourceforge.net/projects/chibios/ Download the zip file and look into the directory ./demos/ARM7-LPC214x-G++ Giovanni
Michał Wolo wrote: > Hello Everybody. > > I can't use options CXXFLAGS > +=-nostdlib because i use #include<vector> The use of STL code alone will increase size significantly - STL contains a lot of functionality, but you don't get something for nothing. You also have to realise the manner in which templates work and are implemented in GNU. In C++ in general, for each data type you instantiate a template for, the compiler generates unique code for that type. So for example if you create vectors for 5 different types, you will get five implementations of what may be almost identical code. This can quickly lead to code-bloat. You can create as many vectors for one type as you wish, but you get one template instantiation for each type. Further more, unless the linker is 'template aware' (and it is not), if you create say a vector<int> in one module, and then a vector<int> in another, you will get two copies of vector<int>. This is because only the compiler can instantiate a template, and the compiler deals with single modules. This is also the reason that the template code is inlined in the header file. For this not to be so, the compiler would have to embed the template source into the object file, and then the linker on encountering a matching template would have to pass the template source back to the compiler to instantiate it. That way all modules could share a single instantiated template. This feature is 'promised' for some future version of GCC/LD. In the end I would suggest that STL is just not suited to resource constrained targets. And this probably applies to templates in general if you are not careful. You can minimise the code size by minimising the number of types you instantiate a template for, and by ensuring that all instantiations of a particular type are in the same compilation unit. Note that the EC++ 'standard', although now largely outdated and ignored, does not allow templates at all; http://en.wikipedia.org/wiki/Embedded_C%2B%2B. Of all the parts of C++ removed to form EC++ only the avoidance of templates, exceptions, and rtti has any real merit in my opinion, and you don't need a specific EC++ compiler to do that. Clifford
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.