* Re: program broke after turn on the option -flto
2020-09-15 7:07 program broke after turn on the option -flto mx
@ 2020-09-15 10:12 ` David Brown
0 siblings, 0 replies; 2+ messages in thread
From: David Brown @ 2020-09-15 10:12 UTC (permalink / raw)
To: mx, gcc-help
On 15/09/2020 09:07, mx via Gcc-help wrote:
> The program run in a embedded system. I turn on -flto option to
> optimize the size of my program. However the program broke in
> runtime. Is it normal?
>
You are giving very little information here, but it is certainly normal
that you need to take some care if you want to use LTO in an embedded
system.
In particular, it's easy to end up with a system that is missing
interrupt functions, non-code flash sections (vector tables,
configuration options, etc.), and other code that is vital but not
directly reachable from main(). Some gcc toolchains for
microcontrollers come with a fair amount of this set up already, others
do not.
Basically, don't try using LTO unless you are happy to read the
documentation for the option, read (and modify) your linker scripts, use
gcc attributes, study map files, and dig into the details of what is
going wrong.
^ permalink raw reply [flat|nested] 2+ messages in thread