buildsystem: support choosing default linker

Default linker can be set with DEFAULT_LINKER in options.

Packages can influence linker selection both by positive and/or
negative PKG_BUILD_FLAGS, eg +bfd or -gold.

Positive build flags take priority over the default linker so eg
DEFAULT_LINKER="gold" and PKG_BUILD_FLAGS="+bfd" will select bfd.

Negative flags mean a specific linker should not be used, eg -gold
prevents using gold.

If the default linker is disabled via a build flag then any other
available linker will be used.

Optional linkers like gold have to be enabled with eg GOLD_SUPPORT="yes"
in options. If an optional linker is not enabled it won't be a candidate
for linker selection. So eg "+mold" will have no effect if MOLD_SUPPORT
isn't set to "yes".

Signed-off-by: Matthias Reichl <hias@horus.com>
This commit is contained in:
Matthias Reichl
2022-09-25 15:09:46 +02:00
parent b1d73ad348
commit 4bcc171bd2
5 changed files with 58 additions and 10 deletions

View File

@@ -32,6 +32,9 @@
# GOLD (Google Linker) support
GOLD_SUPPORT="yes"
# default linker (bfd / gold)
DEFAULT_LINKER="gold"
# HARDENING (security relevant linker and compiler flags) support
HARDENING_SUPPORT="no"