Link set alternative in static library


I have a codebase where I have many .so 's and lot of link sets defined & implemented.
Now for performance reasons I want to compile my code as a single static library.
But I get the errors that linker sets aren’t allowed in static libraries or executable.
Is there any alternate which exists for the same? Also I am not sure if this question belongs to this category. If not, please do suggest the right category.


Since Clang is not a linker, it would be helpful if you can tell us which linker you’re using.

I am using llvm’s lld

Moved to lld category then.

Can you be a bit more specific about which LLD you are using, and what you mean by linker sets? I’m familiar with ld.lld the ELF version, which I think you are referring to as ELF has .so but I don’t recognise the term “linker set” and I can’t see any LLD diagnostics that use “linker set”.

The closest thing that I can think of that exists in shared-libraries but not static libraries is dynamic information. This is usually created by the linker, although in the case of symbol versioning scripts that is provided by the user.

Link sets are mentioned here:

This is what I am asking about.

Linker sets work in executables and static libraries, though with the latter you likely want -Wl,–whole-archive.

Thanks for the reference. From what I can see the linker feature this needs is support for the GNU ld convention that linker can define __start_<secname> and __stop_<secname> for every output section called <secname>. These are supported by lld, and as jrtc27 says these are not restricted to shared objects.