public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux
@ 2023-12-14 11:47 aros at gmx dot com
  2023-12-14 12:23 ` [Bug rtl-optimization/113019] " ktkachov at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: aros at gmx dot com @ 2023-12-14 11:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113019
           Summary: [NOT A BUG] Multi-architecture binaries for Linux
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aros at gmx dot com
  Target Milestone: ---

I know nothing about how libraries/binaries function in Linux or any other OS
however,

Nowadays in Linux there's seemingly a demand [1] [2] for getting more
performance out of applications/libraries by compiling them for newer x86-64
targets, e.g. x86_64_v3 however that instantly excludes a large swathe of CPUs
including very recent Intel CPUs lacking AVX2.

I wonder if GCC is capable of compiling a single library/binary object which
contains distinct code paths for different x86-64 targets. That way you could
have a single binary [object] which has the best performance and compatibility
regardless of where it's run.

I can imagine libraries having offsets for its functions and you cannot have
two offsets for different architectures, but what about 1) having two distinct
functions for different uArchs, e.g. some_routine_x86-64() and
some_routine_x86-64-v3()? or 2) every function having the most basic

if (arch=this)
    {run this}
else
    {run that}.

At the beginning of it?

I apologize if nothing above makes any sense.

https://ubuntu.com/blog/optimising-ubuntu-performance-on-amd64-architecture
https://www.phoronix.com/news/Arch-Linux-ALHP-x86-64-v4

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

* [Bug rtl-optimization/113019] [NOT A BUG] Multi-architecture binaries for Linux
  2023-12-14 11:47 [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux aros at gmx dot com
@ 2023-12-14 12:23 ` ktkachov at gcc dot gnu.org
  2023-12-14 12:39 ` arsen at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2023-12-14 12:23 UTC (permalink / raw)
  To: gcc-bugs

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

ktkachov at gcc dot gnu.org changed:

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

--- Comment #1 from ktkachov at gcc dot gnu.org ---
GCC provides the Function Multiversioning feature that's supported on some
architectures:
https://gcc.gnu.org/onlinedocs/gcc/Function-Multiversioning.html

That seems to do what you want?

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

* [Bug rtl-optimization/113019] [NOT A BUG] Multi-architecture binaries for Linux
  2023-12-14 11:47 [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux aros at gmx dot com
  2023-12-14 12:23 ` [Bug rtl-optimization/113019] " ktkachov at gcc dot gnu.org
@ 2023-12-14 12:39 ` arsen at gcc dot gnu.org
  2023-12-14 14:34 ` ultrafine at gmx dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: arsen at gcc dot gnu.org @ 2023-12-14 12:39 UTC (permalink / raw)
  To: gcc-bugs

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

Arsen Arsenović <arsen at gcc dot gnu.org> changed:

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

--- Comment #2 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
GNU targets, and many non-GNU targets, support ifuncs.  you can use those to
resolve to an optimized implementation of a function.

if you mean to have gcc compile to a few -march/-mtune configurations and
generate these ifuncs 'implicitly', I suppose that could be done, and then
this'd be an RFE

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

* [Bug rtl-optimization/113019] [NOT A BUG] Multi-architecture binaries for Linux
  2023-12-14 11:47 [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux aros at gmx dot com
                   ` (2 preceding siblings ...)
  2023-12-14 14:34 ` ultrafine at gmx dot com
@ 2023-12-14 14:34 ` ultrafine at gmx dot com
  2023-12-14 14:53 ` aros at gmx dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ultrafine at gmx dot com @ 2023-12-14 14:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from ultrafine at gmx dot com ---
Yeah, I'm looking forward to being able to compile this way:

-march=x86-64 -mextra-arch=x86-64-v3

And do _nothing_ else and get a single binary. And then at runtime the
appropriate code for the detected uArch gets executed.

--- Comment #4 from ultrafine at gmx dot com ---
To make it simple Linux distros seemingly want to be able to compile a single
binary (application or shared library) which has two distinct code paths for
different flavours of the x86-64 arch to extract maximum performance from it
regardless of the CPU it's being executed on.

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

* [Bug rtl-optimization/113019] [NOT A BUG] Multi-architecture binaries for Linux
  2023-12-14 11:47 [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux aros at gmx dot com
  2023-12-14 12:23 ` [Bug rtl-optimization/113019] " ktkachov at gcc dot gnu.org
  2023-12-14 12:39 ` arsen at gcc dot gnu.org
@ 2023-12-14 14:34 ` ultrafine at gmx dot com
  2023-12-14 14:34 ` ultrafine at gmx dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ultrafine at gmx dot com @ 2023-12-14 14:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from ultrafine at gmx dot com ---
Yeah, I'm looking forward to being able to compile this way:

-march=x86-64 -mextra-arch=x86-64-v3

And do _nothing_ else and get a single binary. And then at runtime the
appropriate code for the detected uArch gets executed.

--- Comment #4 from ultrafine at gmx dot com ---
To make it simple Linux distros seemingly want to be able to compile a single
binary (application or shared library) which has two distinct code paths for
different flavours of the x86-64 arch to extract maximum performance from it
regardless of the CPU it's being executed on.

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

* [Bug rtl-optimization/113019] [NOT A BUG] Multi-architecture binaries for Linux
  2023-12-14 11:47 [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux aros at gmx dot com
                   ` (3 preceding siblings ...)
  2023-12-14 14:34 ` ultrafine at gmx dot com
@ 2023-12-14 14:53 ` aros at gmx dot com
  2023-12-14 16:44 ` [Bug target/113019] " pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: aros at gmx dot com @ 2023-12-14 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Artem S. Tashkinov <aros at gmx dot com> ---
(In reply to ktkachov from comment #1)
> GCC provides the Function Multiversioning feature that's supported on some
> architectures:
> https://gcc.gnu.org/onlinedocs/gcc/Function-Multiversioning.html
> 
> That seems to do what you want?

This can only be achieved manually by rewriting everything, while I was
thinking about something compiler-side which you can enabled as a compile
option.

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

* [Bug target/113019] [NOT A BUG] Multi-architecture binaries for Linux
  2023-12-14 11:47 [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux aros at gmx dot com
                   ` (4 preceding siblings ...)
  2023-12-14 14:53 ` aros at gmx dot com
@ 2023-12-14 16:44 ` pinskia at gcc dot gnu.org
  2023-12-14 16:48 ` pinskia at gcc dot gnu.org
  2023-12-17 21:32 ` egallager at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-14 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|rtl-optimization            |target
           Severity|normal                      |enhancement

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

* [Bug target/113019] [NOT A BUG] Multi-architecture binaries for Linux
  2023-12-14 11:47 [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux aros at gmx dot com
                   ` (5 preceding siblings ...)
  2023-12-14 16:44 ` [Bug target/113019] " pinskia at gcc dot gnu.org
@ 2023-12-14 16:48 ` pinskia at gcc dot gnu.org
  2023-12-17 21:32 ` egallager at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-14 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 78464.

*** This bug has been marked as a duplicate of bug 78464 ***

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

* [Bug target/113019] [NOT A BUG] Multi-architecture binaries for Linux
  2023-12-14 11:47 [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux aros at gmx dot com
                   ` (6 preceding siblings ...)
  2023-12-14 16:48 ` pinskia at gcc dot gnu.org
@ 2023-12-17 21:32 ` egallager at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: egallager at gcc dot gnu.org @ 2023-12-17 21:32 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

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

--- Comment #7 from Eric Gallager <egallager at gcc dot gnu.org> ---
Perhaps you're looking for something like cosmocc?
https://github.com/jart/cosmopolitan/blob/master/tool/cosmocc/bin/cosmocc
...or perhaps a port of driverdriver.c and lipo from the old Apple GCC to
Linux?
https://opensource.apple.com/source/gcc_42/gcc_42-5566/driverdriver.c.auto.html

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

end of thread, other threads:[~2023-12-17 21:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-14 11:47 [Bug rtl-optimization/113019] New: [NOT A BUG] Multi-architecture binaries for Linux aros at gmx dot com
2023-12-14 12:23 ` [Bug rtl-optimization/113019] " ktkachov at gcc dot gnu.org
2023-12-14 12:39 ` arsen at gcc dot gnu.org
2023-12-14 14:34 ` ultrafine at gmx dot com
2023-12-14 14:34 ` ultrafine at gmx dot com
2023-12-14 14:53 ` aros at gmx dot com
2023-12-14 16:44 ` [Bug target/113019] " pinskia at gcc dot gnu.org
2023-12-14 16:48 ` pinskia at gcc dot gnu.org
2023-12-17 21:32 ` egallager 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).