public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/114337] New: LTO symbol table doesn't include builtin functions
@ 2024-03-14 13:43 hjl.tools at gmail dot com
  2024-03-14 13:46 ` [Bug lto/114337] " hjl.tools at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2024-03-14 13:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114337

            Bug ID: 114337
           Summary: LTO symbol table doesn't include builtin functions
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---

[hjl@gnu-cfl-3 pr31482-a]$ cat y.c
#include <stdio.h>
#include <stdlib.h>

void *
foo (size_t n)
{
  printf ("hello\n");
  return malloc (n);
}
[hjl@gnu-cfl-3 pr31482-a]$ gcc -flto -c y.c
[hjl@gnu-cfl-3 pr31482-a]$ nm y.o
00000000 T foo
[hjl@gnu-cfl-3 pr31482-a]$ lto-dump -list y.o
Type   Visibility  Size  Name
function  default     0  puts  
function  default     0  malloc  
function  default     4  foo  

[hjl@gnu-cfl-3 pr31482-a]$ 

This doesn't work with libraries which provide alternative implementations
for standard functions, like jemalloc, since linker doesn't know the builtin
functions are referenced.  Unless GCC can inline these builtin functions,
these symbols should be in LTO symbol table.

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

* [Bug lto/114337] LTO symbol table doesn't include builtin functions
  2024-03-14 13:43 [Bug lto/114337] New: LTO symbol table doesn't include builtin functions hjl.tools at gmail dot com
@ 2024-03-14 13:46 ` hjl.tools at gmail dot com
  2024-03-14 13:50 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2024-03-14 13:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114337

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
Maybe linker can deal with it.

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

* [Bug lto/114337] LTO symbol table doesn't include builtin functions
  2024-03-14 13:43 [Bug lto/114337] New: LTO symbol table doesn't include builtin functions hjl.tools at gmail dot com
  2024-03-14 13:46 ` [Bug lto/114337] " hjl.tools at gmail dot com
@ 2024-03-14 13:50 ` jakub at gcc dot gnu.org
  2024-03-14 14:02 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-14 13:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114337

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Without -ffat-lto-objects, the compiler doesn't really know if the builtins
will be expanded inline and not require any symbol from other objects, or if
they will need some library function (and which exact one).

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

* [Bug lto/114337] LTO symbol table doesn't include builtin functions
  2024-03-14 13:43 [Bug lto/114337] New: LTO symbol table doesn't include builtin functions hjl.tools at gmail dot com
  2024-03-14 13:46 ` [Bug lto/114337] " hjl.tools at gmail dot com
  2024-03-14 13:50 ` jakub at gcc dot gnu.org
@ 2024-03-14 14:02 ` rguenth at gcc dot gnu.org
  2024-03-14 15:12 ` hjl.tools at gmail dot com
  2024-03-25 13:44 ` amonakov at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-14 14:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114337

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The linker needs to re-scan for new references to libc and libgcc functions
anyway.  For example a structure copy might be expanded as memcpy.  We probably
don't introduce new calls to memcpy so maybe for a subset of builtins that
are never expanded inline or those that are never automatically generated
by the compiler we can put them into the symbol table.  Note we can
introduce calls to things like stpcpy as well, so it's a bit non-obvious
how to classify builtins here.  Keying on just whether the decl is built-in is
probably too coarse.

We could simply include all built-ins in the symbol table.

Honza?

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

* [Bug lto/114337] LTO symbol table doesn't include builtin functions
  2024-03-14 13:43 [Bug lto/114337] New: LTO symbol table doesn't include builtin functions hjl.tools at gmail dot com
                   ` (2 preceding siblings ...)
  2024-03-14 14:02 ` rguenth at gcc dot gnu.org
@ 2024-03-14 15:12 ` hjl.tools at gmail dot com
  2024-03-25 13:44 ` amonakov at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2024-03-14 15:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114337

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |MOVED

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
Will fix it in linker.

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

* [Bug lto/114337] LTO symbol table doesn't include builtin functions
  2024-03-14 13:43 [Bug lto/114337] New: LTO symbol table doesn't include builtin functions hjl.tools at gmail dot com
                   ` (3 preceding siblings ...)
  2024-03-14 15:12 ` hjl.tools at gmail dot com
@ 2024-03-25 13:44 ` amonakov at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: amonakov at gcc dot gnu.org @ 2024-03-25 13:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114337

Alexander Monakov <amonakov at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amonakov at gcc dot gnu.org

--- Comment #5 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Gold handles such rescanning correctly. BFD ld regressed in 2.27, this
bugreport contains references to previous discussions about rescanning:
https://sourceware.org/bugzilla/show_bug.cgi?id=23935

(in the above bug there's a patch for ld.bfd that seemingly went nowhere)

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

end of thread, other threads:[~2024-03-25 13:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-14 13:43 [Bug lto/114337] New: LTO symbol table doesn't include builtin functions hjl.tools at gmail dot com
2024-03-14 13:46 ` [Bug lto/114337] " hjl.tools at gmail dot com
2024-03-14 13:50 ` jakub at gcc dot gnu.org
2024-03-14 14:02 ` rguenth at gcc dot gnu.org
2024-03-14 15:12 ` hjl.tools at gmail dot com
2024-03-25 13:44 ` amonakov at gcc dot gnu.org

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).