On 10/2/25 2:40 PM, Eyal Itkin wrote:
> I won't say that keeping the use of a .a archive of a single .o file is
> the most elegant solution, yet it ticks all the boxes, and that is good
> enough.
I think it ticks many boxes that you're not even
thinking about, because sticking to these existing
mechanisms immediately expands your reach to just about
every ELF system, and not just the ones you've directly
set out to care about.
For example, I'm sure you're not concerned about Solaris,
but even so, from the sound of it, all I would need to use
this there would be to upgrade to a newer gcc/binutils.
Now adding this new option to the native Solaris link-editor
is definitely not free, but since it doesn't involve a format
change, and can probably reuse quite a lot of existing code,
it's also not particularly hard. Whether I'll actually do that
or not really just comes down to demand from my users. In the
meantime, gld is enough to let me play, and the price is right.
The low barrier to entry does qualify as elegant, even if
the idea of having one object in an archive might not.
On 10/3/25 2:33 AM, Eyal Itkin wrote:
> I'm still new to this process so please excuse me for asking, but are
> you telling me that there is no need anywhere to define the new
> "standard" for static libraries? Or that your meaning is that what we
> discussed in this thread is good enough?
>
> I'm asking because I'm trying to wrap my head around what will be the
> motivation of the maintainers of GNU ld to discuss patches that I'll
> prepare instead of telling me that this sounds like an ELF standard
> issue and that a new e_type is needed? And even if my patches will be
> accepted, what blocks other toolchains from deciding they don't think
> they should support a "--static-lib" flag? Or maybe they want to support
> it using a completely different binary format?
>
> After all, while there is no change at the client side, there is the
> change at the project side, as this change should propagate to: 1) The
> linker, 2) The build infrastructure that will pass this flag to the
> linker. Hence, the "news" about this proposed format should still travel
> around the community so that it would help with the adoption of it.
I don't think putting a single object into an archive is
a new idea, nor one that needs standardizing. Nor are the
sort of finalizing steps you'll be applying to your generated
.o. Since all of that is built out of existing pieces, the GNU
ld folks should have no standards concerns about it. They'll
probably have lots of other concerns, as with any project.
Finally, as Ian said, you don't standardize something like this
and just expect the users to follow. What you do is roll it out,
start using it, refine it based on experience, and win users as
they see value. Even if you ultimately did need a standards change,
this would be the necessary first step, because there's nothing worse
than standardizing something that turns out to need tweaking later.
New gABI additions need to be already proven somehow.
So yes, I think you can just carry on from here.
----
Nothing that follows is gABI related, and are just thoughts
that have occurred to me as this has gone by.
I wonder about calling these "static libraries", because
that expression has long been used to describe ordinary
archives containing non-PIC objects, intended to be linked
into executables. What you're doing is something else:
You're producing a single relocatable object that's been
finalized so that it provides an entire unit of things.
That unit is most likely a "library", but it could be
any self contained collection of objects.
I wonder if there's a better name that isn't ridiculously
verbose (e.g. --finalize), that would be used with -r,
that better captures the essential thing being done.
Related to that, I'm not sure that you should have the
link-editor produce the archive, containing that object.
I'd vote for producing the object, and letting the user
stuff it into an archive if they need those additional
features. This is more flexible:
- I don't have to use an archive, if my project
doesn't need that, I can just link to the .o.
- I can put it in another archive with other, unrelated, objects,
if that model better suites what I'm building. You could
essentially have a single archive, containing multiple
finalized "library" objects, any of which will only be
extracted on demand, like any archive.
Which is another reason not to call it a "library", and instead
try to find a name that captures the essential operation being
done to those objects.
Good luck!
- Ali