cancel
Showing results for 
Search instead for 
Did you mean: 

Cosmic or the worse compilator/linker ever programmed?

pedro23
Senior
Posted on May 29, 2012 at 18:04

Hi. I'm coding my 3rd testing project on stm8, to be exact in 2 different mcus, 103 and 105. I'm using cosmic compiler, and i didnt have any problem with the previous 2 projects (because i didnt verify the size).

The problem is that binary files generated by cosmic linker are oversized,... I expain it.

Until now ( I have more than 25 years programming and 13 years in MCU's world) when you included functions and you didnt use them, the linker was able to remove them from final binary since they are not being used..., I say until now because cosmic compiler is not doing that.

In my 3rd testing project i wanted to create the bigger array in flash (with const char noname[xxx];, where xxx is the size). What was my surprise when with a small code (about 10 lines my code, basically initializing ports and timers)  the bigger table size that I was able to create in a 8kb flash stm8s103 was just 3300... I though then that i did something wrong so i started to do different tests...., I called my provider and he started to do his own tests, after a while we talked again and our conclusion was that COSMIC compiler doesn't remove unused functions.

To verify it, just create a cosmic project with stvd, then include for example in the project stm8_gpio.c, generate a map file (linker tab then output in category combobox). You will see a .map file generated and a line, something like:

start 0000909d end 0000a444 length  5031 segment .text

After that I edit the stm8s_gpio.c file and remove with a &sharpif defined(XXXX) the function GPIO_ExternalPullUpConfig that i'm not using in my code, and i get:

start 0000909d end 0000a42c length  5007 segment .text

So basically it is including the function, even when I dont use it in the code

If you continue reading the programmer.map file in the first case you will see

_GPIO_ExternalPullUpConfig         >    6   (6)

....

  25 > _GPIO_ExternalPullUpConfig: (6)

...

_GPIO_ExternalPullUpConfig          00009f27   defined in Debug\stm8s_gpio.o section .text

Maybe the problem is that i'm using the 32kb limited version of the compiler but at least they can notice you this ''hidden feature'' when you get it.

#cosmic-linker-hidden-features #duplicate-thread
1 REPLY 1
Andrew Neil
Evangelist
Posted on June 05, 2012 at 01:17

Duplicate:

[DEAD LINK /public/STe2ecommunities/mcu/Lists/stm81/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/stm81/Cosmic or the worse compilatorlinker ever programmed&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580001E3853D9DB932A46A3FE4CD15CAB46FB]https://my.st.com/public/STe2ecommunities/mcu/Lists/stm81/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fstm81%2fCosmic%20or%20the%20worse%20compilatorlinker%20ever%20programmed&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580001E3853D9DB932A46A3FE4CD15CAB46FB