public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* program broke after turn on the option -flto
@ 2020-09-15  7:07 mx
  2020-09-15 10:12 ` David Brown
  0 siblings, 1 reply; 2+ messages in thread
From: mx @ 2020-09-15  7:07 UTC (permalink / raw)
  To: gcc-help

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?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* 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

end of thread, other threads:[~2020-09-15 10:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15  7:07 program broke after turn on the option -flto mx
2020-09-15 10:12 ` David Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).