Handling groupings and positional parameters during native linkage


(Schalk Cronjé) #1

Hereby a use case, which is not handled by native builds at all, but which is not as uncommon as one might think.

Not all static libs on Linux/BSD are actually a collection of objects, some just contains text such as

GROUP ( librte_pmd_i40e.a  librte_cfgfile.a )

This is used to combine a number of static archives into a single reference. When linking against these it is many times necessary to pass something like

-whole-archive,  --start-group,  -l, nameOfLib, --end-group, --no-whole-archive

Currently there is no way of handling this in Gradle except for doing it direct

linker.args '-whole-archive',  '--start-group', '-l', 'nameOfLib', 
  '--end-group',  '--no-whole-archive'

It might be worthwhile adding something to PrebuiltStaticLibraryBinary to tag certain libraries to be within positional groupings on the command-line. I appreciate that Gradle cannto cope with all possible combinations, so maybe adding some methods such as

  prefixFlags( String... args )
  postfixFlags( String... args )