On Thu, Mar 25, 2021 at 12:06:08PM +0000, Jonathan Wakely via Gcc wrote:
> What would be the benefit?
> 
> I can understand the advantage of a single binary that is a
> cross-compiler for different targets (but it would be a huge task to
> get GCC there). You wouldn't need multiple complete copies of GCC
> installed to do cross-compilation if there was a --target option like
> Clang's. But what's the benefit to users of a single binary for
> different languages? The 'gcc' driver already exists and gives that
> functionality, what would change with your proposal?

I don't see an advantage to have different FEs in the same binary, and a lot
of things aren't done through language hooks, but just calling specific
functions from the FE (both when the generic code does that and when e.g.
c-family code calls functions implemented separately by the FEs).

Having some binary do the cross-compilation would be nice e.g. for
offloading that we wouldn't need to jump through LTO bytecode saving and
loading to switch targets between separate processes, but I'm afraid
achieving that is far from the scope of GSoC (orders of magnitude).  While
we have target hooks, they cover only part of the backend interfaces.  A lot
is done e.g. through macros the targets define, and while some of them could
be easily replaced by target hooks (and many have been in the past), some
macros really should ideally never be target hooks, e.g. making
BITS_PER_UNIT not a macro but a member of target hooks (or even worse a
call) would slow down the compiler a lot.  Another difficult area is that
we have a lot of generated inline functions, macros and functions emitted
by the gen* tools, that is again specific for a particular target, so
merging it from multiple targets would be a lot of work and again risks of
slowing the compiler down.  Then is the option processing code, different
targets have different target specific options, we have generators for the
option handling, but for a single binary to support multiple targets we'd
need to mark the option tables/macros etc. as specific to different targets,
making them coexist and find out what to do on the command line (e.g. if
the target selection option doesn't come first on the command line, how to
do the target specific option processing when the code doesn't know for
which target it will be; e.g. some targets could have option that takes a
required argument but another target could have option with the same name
that doesn't take an argument).

        Jakub

Reply via email to