From: Oleg E. <ole...@t-...> - 2024-04-08 23:55:49
|
Hi! On Sun, 2024-04-07 at 08:31 +0800, 月明风清 via sdcc-devel wrote: > I am using SDCC4.2.0 for a pic18 like single-chip-processor, but I found that the SDCC can not distinguish the global variable define in one file , but it was not used at all. > The compiler still allocated RAM location for this kind global variable. > SDCC cannnot do across .c file analysis. How to do with this situation?? > Your assessment is correct. SDCC does not implement this type of optimization. Other compiler tools like GCC have options like -ffunction-sections -fdata-sections which will put each function and data item into its own ELF section. Then the linker can figure out which sections are used and which ones are not used. In addition there is also things like LTO which can be helpful. In case of SDCC, it will likely require the modification of the compiler/assembler/linker tools. Since the compiler only sees one translation unit (.c file) at a time, this optimization has to be eventually implemented by the linking step. Best regards, Oleg Endo |