cancel
Showing results for 
Search instead for 
Did you mean: 

Cosmic or the worse compilator/linker ever programmed?

pedro23
Senior
Posted on May 30, 2012 at 10:35

I'm coding my 3rd testing project on stm8, to be exact in 2 different mcus, 103 and 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[***];, where *** 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 3.. 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 #if 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
5 REPLIES 5
pedro23
Senior
Posted on May 30, 2012 at 11:37

Probably i have found it

http://www.cosmic-software.com/faq/faq44.php

Checking, I will comment if it worked
pedro23
Senior
Posted on May 30, 2012 at 12:03

Default cosmic compiler flags

start 00008080 end 0000908c length 4108 segment .const 
start 0000909d end 0000a444 length 5031 segment .text

Setting compiling flag +split

start 00008080 end 00009080 length 4096 segment .const 
start 00009091 end 000098e7 length 2134 segment .text

Still a bit oversized, but it is at least working. Anyways it is stupid to set as default the non-optimized flag....

luca239955_stm1_st
Senior II
Posted on May 30, 2012 at 21:15

>> I have more than 25 years programming and 13 years in MCU's world..

not a fast learner, are you ?

pedro23
Senior
Posted on June 04, 2012 at 12:09

:D

A lot of slow people :),.. or maybe compiler problem! 🙂

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM8Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM8Discovery/text size overflow (1581) - cosmic&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580004008F0975979A844820611B699DF2ED1]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM8Discovery/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM8Discovery%2ftext%20size%20overflow%20%281581%29%20%2d%20cosmic&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580004008F0975979A844820611B699DF2ED1

wolfgang239955_stm1_st
Associate II
Posted on June 25, 2012 at 12:30

Even not so bad after all: the Cosmic Compiler. I tested all the others (IAR, Raisonance), and found COSMIC-STM8-CX meeting most of my requirements.

BUT!!! I really agree with you: It would be in keeping with the times, that for the functions ''the linker is able to remove them from final binary since they are not being used...''

It should be a minor problem to Cosmic to integrate this feature.

Btw: an earlier posted problem. See

[DEAD LINK /public/STe2ecommunities/mcu/Lists/stm81/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/stm81/eliminate unused functions out of linked file&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580001E3853D9DB932A46A3FE4CD15CAB46FB]unused_functions

Regards,

WoRo