public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug bootstrap/60160] Building with -flto in CFLAGS_FOR_TARGET / CXXFLAGS_FOR_TARGET Date: Fri, 08 Apr 2022 12:49:49 +0000 [thread overview] Message-ID: <bug-60160-4-JPQWxzq3KX@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-60160-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60160 --- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to R. Diez from comment #6) > I am experimenting with a GCC 11.2 cross-compiler for bare-metal embedded > software. > > There is no operating system, so no shared libraries or anything fancy. But > there is a static libc (Newlib or Picolibc). > > I wanted to build everything with LTO, including libc, libstdc++ and libgcc. > This is the makefile I am using: > > https://github.com/rdiez/JtagDue/blob/master/Toolchain/Makefile > > Search for "-ffat-lto-objects" in that makefile. > > As soon as I enable the LTO flags, I get linker errors. They are documented > in the makefile next to the LTO options, and look similar to those reported > in this bug. > > I tried -fno-builtin with varying degrees of success. I also tried building > only the application and libc with LTO, but not libstdc++ etc., to no avail. > > LTO only works for the user application. As soon as libc or the other GCC > libraries are compiled with LTO, it fails. > > Is it unfortunate, because I believe that a full LTO build for a bare-metal > environment would be rather beneficial. I agree. > The patch and information referenced in this bug report look dated. Is there > a way to make LTO work now, at least for my configuration? Problems can exist in all parts of the toolchain here, in particular the linker needs to cope with GCC replacing say a reference to printf with puts (which it will happily do in some cases when not using -fno-builtin). That might be one source of unresolved symbols. Generally GCC doesn't like it very much seeing definitions of functions it also recognizes as builtins. It might be needed to teach GCC to do less agressive dead function removal during WPA or not fold printf to puts late if it removed a definition of puts. Other than that I would suggest to enable emitting LTO bytecode for the static target libraries on a per library base with new configury, say --enable-fatlto-static-target-libraries or so and do opt-in for those where it works. That said - yes, it would be nice, but expect to run into problems. When it works, great, when it doesn't - try to analyze the issue and maybe file a specifc bugreport with a testcase?
next prev parent reply other threads:[~2022-04-08 12:49 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-02-12 15:19 [Bug bootstrap/60160] New: " d.g.gorbachev at gmail dot com 2014-02-12 15:38 ` [Bug bootstrap/60160] " glisse at gcc dot gnu.org 2014-02-12 15:44 ` trippels at gcc dot gnu.org 2014-08-23 13:43 ` glisse at gcc dot gnu.org 2014-08-23 14:39 ` d.g.gorbachev at gmail dot com 2022-04-08 12:34 ` rdiezmail-gcc at yahoo dot de 2022-04-08 12:49 ` rguenth at gcc dot gnu.org [this message] 2023-02-02 8:39 ` a.heider at gmail dot com 2023-02-02 12:56 ` a.heider at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-60160-4-JPQWxzq3KX@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).