ld: Expand options for partial static linking

Nick Clifton nickc@redhat.com
Tue Apr 9 08:24:04 GMT 2024


Hi Mike,

> I would like to propose a new command line option for the linkers to add support for partial static linking.

Thanks for bringing up this topic.

> I have two proposed solutions:
> 
> A. The lowest impact version
> Add a command line option along the lines of "--Bstatic-preferred" that reverses the default searching behavior.  It would search libraries looking for ".a then .so" 
> instead of the default ".so then .a".
> 
> It solves my problem, and in combination with --Bstatic and --Bdynamic it covers 3 of the 4 possible search types that could be conceived.

Meh.  If we are going to fix a problem, let's fix it
correctly and once, rather than leaving issues for the
future.

> B. The logically consistent version:
> Add four new options that clearly state the behavior.  These would cover all four combinations of the current dynamic and static search behaviors.  Two would be duplicates 
> of existing flags.
> 
> * --Bstatic-only;  same as --Bstatic; linker searches for .a only
> * --Bdynamic-only; new behavior; linker searches for .so only
> * --Bstatic-preferred; new behavior; linker searches for .a and falls back to .so
> * --Bdynamic-preferred; same as --Bdynamic; linker searches for .so and falls back to .a; DEFAULT

I prefer this solution.

Are you offering to write a patch to implement this behaviour ?

Have you contacted the LLVM linker people and/or the MOLD linker
folks about this idea ?  If so, do they have a preference ?

Cheers
   Nick



More information about the Binutils mailing list