CTXz / STM8-DCE

SDCC STM8 Dead Code Elimination Tool
GNU General Public License v3.0
6 stars 0 forks source link

err ?ASlink-Warning-Undefined Global '___str_0' referenced by module 'main' #3

Closed dzantemir closed 3 months ago

dzantemir commented 3 months ago
#include "stdio.h"
#include "stm8s.h"
void main(void)
{
 float gg=123.123;

  char str[20]; //create an empty string to store number

    sprintf(str, "%f", gg);//make the number into string using sprintf function
 }

sdcc 4.4.1

platformio 
extra_scripts = use_stm8dce.py
?ASlink-Warning-Undefined Global '___str_0' referenced by module 'main'
CTXz commented 3 months ago

Likely related to the ___str_0 const (these are generated by full asserts) not getting loaded via ldw but push instructions. Since the dce tool only checks for load instructions to evaluate if a constant is used, it falsely optimizes it away.

A fix for this is currently in works where all memory read instructions are tested for constants, not just ld/ldw/ldf. I'll publish it today or tomorrow.

This will also hopefully also improve backwards- and upwards compatibility for different SDCC versions

CTXz commented 3 months ago

The most recent commits in the 1.0.2wip branch should fix this issue. I'd like to do a little more testing and clean-up before merging into main.

Until then, feel free check-out the 1.0.2wip branch