cogc to big?
dnalor
Posts: 223
What message will appear if COGC is too large?
I have some strange message:
(alfatdriver.cog+0x5c8): undefined reference to `_udwFileRead.constprop.0_ret'
collect2: ld returned 1 exit status
Done. Build Failed!
When I removed a few lines in this function, then the error message is gone.
Code size in the map file is then 0x618.
I have some strange message:
(alfatdriver.cog+0x5c8): undefined reference to `_udwFileRead.constprop.0_ret'
collect2: ld returned 1 exit status
Done. Build Failed!
When I removed a few lines in this function, then the error message is gone.
Code size in the map file is then 0x618.
Comments
It should be a message like:
c:/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: region `cog' overflowed by 24596 bytes
Something like that I would have expected.
After sleeping a few hours, I see now a bug in the code.
If you program an infinite loop, the rest of the code is simply trimmed. And then the error message makes sense.
But that's one reason why I do not like gcc. Without optimization the code is useless big, with optimization the code is no longer that what you have written down.
The volatile keyword, for example, I did not know before the first use of gcc.
If you think about it a bit it all makes sense and you will like it.
If the result of a code sequence is unused in your program it makes sense for the optimizer to throw that sequence away. That can include entire function calls and the called functions.
If a code sequence is obviously an infinite loop there is no point including the code that comes after it.
If you have functions that are never called why put them in the binary?
And so on.
As for "volatile" if your code sets a variable that is never read by any other part of the source why would the compiler want to keep the code that set's that variable? As far as the compiler knows it is useless. Unless you tell it otherwise.
Finay "volatile" is not a GCC thing. It is part of the C language.
I've never learned and understood what it means and with the Renesas M16 I've also never used it and did not have a colleague who has ever used it. With the PIC24 and MPLAB-C, we have then learned what it means and that it is apparently necessary. But on a system with interrupts or even with multiple cores and shared memory area, it is perfectly clear that any global variable is volatile automatically.
I disagree. If I do not need the code, then I do not write it or I use conditional compilation. And what I write, the compiler should simply translate.
If I write:
Then I do not want this:
And if I write:
instead of:
then it is my fault and compiler may throw a warning but never ever cut my code.
A Compiler never should try to be too intelligent.
And Cutting unused (library) functions is not task of the compiler, but the (smart-)linker.
Optimising -- It exploits the tendency of coding to be extremely single threaded. So, if you know that there is concurrent interfacing then telling (volatile) the compiler about it will allow the compiler to make sure the specified memory references are in-order accessed as per the source code.
With regard to globals, I kind of agree in one sense but then we're ending up hand optimising most accesses of globals which I have to admit I do do just to be sure.
Imagine a global variable, "int A", that you write to but never read in your program. Then the compiler can rightly assume the value written is never used and all code that does the writing can safely be removed. Now "A" might actually be a processor register, in which case the hardware uses the values written to it and "volatile" says "do not optimize those writes away".
I sort know what you are driving at but I'm sure you don't mean it:) If you have "A = 2 * M_PI;" in your code I bet you are happy that the compiler calculates "2 * M_PI" at compile time and uses the resulting constant to load "A" instead of inserting the code to do a long winded multiply.
Perhaps not a good example but I'm sure you do want the compiler to do that. i.e. keep things in registers as much as possible for fast execution. The alternative is that everything is kept in RAM all the time and has to be loaded and stored repeatedly resulting in larger slower code.
If that is really what you want the turn off all optimizations "-O0". Sure it should. See above.
Yes a linker should do that, BUT if you think about it that is not always possible. For example in code like: Clearly the compiler might work out that "printf" can never be callled and so remove the call to it. The linker may then not include "printf" from the library.
BUT linker cannot know that this "printf" is unused. Unless it is really smart and can analyse the code, At which point it is doing what the compiler does so why not let the compiler do it. Besides linkers have to work for many languages not just C so that kind of analysis does not belong in the linker.
And it is very good to have a compiler that produces predictabel code. Then C is exactly what it should be, a good 'macro language' for assembler.
With gcc you get often bad surprises. But I do not want to complain. It is definitely the best solution that exists so far for the propeller.
Is there any way to change optimisation for cogc files in SimpleIDE ? It seems to be fixed to Os.
Wich optimisation levels/options are available ?
My feeling is that one cannot complain that the code is too big to fit in COG and at the same time complain that the optimizer is working too well. If niether of those are acceptable just use PASM.
Given the space constraints of the Prop -Os is pretty much essential.
You heat up quite fast, Heater !???
I did not complain. I had a message that I did not understand. My suspicion was that it was because of size.
But in my opinion, gcc is too aggressive and it's not my preferred compiler if there is another.
You do not have to agree !
But not for cogc files or do I miss something ?
btw. the correct message is: ../propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld.exe: address 0x7e8 of a.out section `alfatdriver.cog' is not within region `coguser'
@dnalor, If you prefer another compiler, then I suggest you start using it.
Sorry if I seem to be heating up. I just don't get the logic of what you are saying. If GCC optimizations are too agressive then sure use some other less aggressive compiler. But then quite likely your code will not fit in COG again.
So what's the point? GCC is a really unagressive puppy at -O0 and anyway we have no other C compiler that will generate native PASM to run in COG.
OK perhaps SimpleIDE should have a means to set whatever optimization and other options we like. Just not sure it it would be very useful.
As we started with a question about the meaning of a compiler error message, I might agree that sometimes it is not clear what the problem is. Over time you get used to most of them. Error messages from C++ are a thousand times worse.
That there is very much a complaint. And specifically a complaint about GCC. Posts #3 and #5 are complaints too.
I think what is really the problem here is not so much what the compiler is doing but the lack of immediate extended help on what the meaning of the error is.
PS: When I said it's "maybe even more a compiler thing than C per se" I meant all compiled code and languages. Not just C. This is one distinction between a compiler and an interpreter or assembler. Compiling guarantees the binary is not the same as the source.
These are statements.
A meaningful error message would help.
The compiler should optimise the code in such way, that it is predictable and trustable and I want full control about what compiler does. If the compiler cuts the code without warning, then it is not acceptable.
@jazzed
The settings in SimpleIde do work only for the main file not the cogc files. Cogc files are always -Os.
That is now do or die but shut up, your opinion does not matter. Right ? Is this your opinion or parallax'.
Purely my opinion. I read your statement regarding another compiler thinking that you had one in mind and prefer using it. That's all.
Cool, I guess my hand crafted optimising wasn't worthless after all.
Copy to batch. Ah, that's a good suggestion! Thank you.
For that it would be nice to have one (or more) user button(s) or entry(s) in Tools menu, which is/are saved in project file. Then one could start batchfile(s) with a click.
No. Propgcc is the best solution so far. My experience with gcc were just not that good so far. But you guys did a much better job than imagecraft with their compiler. They have stopped halfway and wondered why no one wants to have their (propeller) compiler.
If I do rightclick show assembly on a cogc file it takes optimisation from project options (there it seems to be global).
Build do always -Os (there it is not global).
I think it should be global in both cases or not global in both cases.
Thanks for pointing this out. Some consistency is at least expected. I'm still searching for a good solution. Make a .bat or .sh is probably a good idea, but I would have to capture the sequence and allow a build by batch. Any other ideas on this?
http://forums.parallax.com/showthread.php?140797-Is-this-possible-in-PropGCC&p=1106348&viewfull=1#post1106348
But I think you want keep things in SimpleIde as beginner friendly as possible. So fixed optimisation -Os for cogc and other files with project options is maybe the best (like you did it).
Copy from output pane to batchfile "by hand" is not too difficult. But starting this batchfile should be possible with click on a button (see post #20).
Aha. Then all ways are open.
If you know what you have to look after, then you sometimes find something:
http://gcc.gnu.org/wiki/FunctionSpecificOpt