Hi Richard,

> That was also what I was trying to say.  In the worst case, the linked
> object has to meet the requirements of the lowest common denominator.
>
> And my supposition was that that isn't a property of static vs dynamic.

But it is. Dynamic linking supports mixing different code models without even
knowing which library uses which model. However with static linking you need
all libraries to be built for the same model, and if not, you end up with the 
lowest
common denominator.

Quite a fundamental difference.

> It applies to both (assuming that dynamic is supported by -mcmodel=large,
> despite the current documentation).  If you link medium and large code
> together statically, the result (in general) has to be small enough for
> the medium model.  The same is true if you link medium and large code
> together in a dynamic executable.

Did you mean "small" here rather than "medium"? Note mixing medium and
large models as currently specified would result in small model.

> So -static isn't intrinsically incompatible with -mcmodel=large.
> The documentation seems to be describing a property of the way that
> GLIBC is built on GNU/Linux systems, rather than a feature of -static
> vs -mcmodel=large per se.

AFAIK no libraries have been ported to -mcmodel=large. That includes not only
GLIBC or newlib, but also internal libraries like libatomic, libgcc and 
libstdc++.
Plus you'd need multi-libs.

It's unlikely anyone will ever do all this work. So not only does it not work 
today,
it is not going to work for as long as we insist that those libraries are the 
issue
(or worse, the user), rather than the large model.

This patch is an example of an issue that can be fixed easily so more cases work
out of the box. The large model could also be fixed to support PIC/PIE and 
static
linking with small model libraries.

> On aarch64-elf, everything is linked statically (unless you go to
> heroic lengths to use aarch64-elf on a "full" custom OS).  And that's
> fine provided that everything is built with the right model.

And guess what? -mcmodel=large doesn't work on aarch64-elf. I've lost count
how many times I had to explain why large model code links to dynamic libraries
without errors but fails to link statically.

Cheers,
Wilco

Reply via email to