build system: add support for mold & linker PKG_BUILD_FLAGS

This commit is contained in:
SupervisedThinking 2022-10-06 19:39:35 +02:00
parent 0d5fd365fb
commit e485a16a8d
5 changed files with 8 additions and 2 deletions

View File

@ -270,7 +270,7 @@ linker_allowed() {
get_target_linker() {
# all known linkers, in descending order of priority
# those are candidates for explicit opt-in via PKG_BUILD_FLAGS
local all_linkers="gold bfd"
local all_linkers="mold gold bfd"
# linkers to choose from unless disabled via PKG_BUILD_FLAGS
local linker_candidates="${DEFAULT_LINKER:-bfd} ${all_linkers}"

View File

@ -31,6 +31,7 @@ LDFLAGS_OPTIM_LTO_COMMON="-fuse-linker-plugin"
LDFLAGS_OPTIM_LINKER_COMPILER_DEFAULT=""
LDFLAGS_OPTIM_LINKER_BFD="-fuse-ld=bfd"
LDFLAGS_OPTIM_LINKER_GOLD="-fuse-ld=gold"
LDFLAGS_OPTIM_LINKER_MOLD="-fuse-ld=mold"
# default compiler optimization
CFLAGS_OPTIM_DEFAULT="-O2 -fomit-frame-pointer -DNDEBUG"

View File

@ -31,6 +31,7 @@ show_config() {
config_message+="\n - CPU features:\t\t\t ${TARGET_FEATURES}"
config_message+="\n - LTO (Link Time Optimization) support: ${LTO_SUPPORT}"
config_message+="\n - GOLD (Google Linker) Support:\t ${GOLD_SUPPORT}"
config_message+="\n - MOLD (Modern Linker) Support:\t ${MOLD_SUPPORT}"
config_message+="\n - Default Linker:\t\t\t ${DEFAULT_LINKER}"
config_message+="\n - LLVM support:\t\t\t ${LLVM_SUPPORT}"
config_message+="\n - DEBUG:\t\t\t\t ${DEBUG:-no}"

View File

@ -32,7 +32,10 @@
# GOLD (Google Linker) support
GOLD_SUPPORT="yes"
# default linker (bfd / gold)
# MOLD (Modern Linker) support
MOLD_SUPPORT="no"
# default linker (bfd / gold / mold)
DEFAULT_LINKER="gold"
# HARDENING (security relevant linker and compiler flags) support

View File

@ -128,6 +128,7 @@ Set the variable `PKG_BUILD_FLAGS` in the `package.mk` to enable/disable the sin
| lto-off | disabled | target, init | explicitly disable LTO in the compiler and linker |
| bfd | - | target, init | `+bfd` prefers bfd linker over default linker, `-bfd` disables using bfd |
| gold | - | target, init | `+gold` prefers gold linker over default linker, `-gold` disables using gold |
| mold | - | target, init | `+mold` prefers mold linker over default linker, `-mold` disables using gold |
| parallel | enabled | all | `make` or `ninja` builds with multiple threads/processes (or not) |
| strip | enabled | target | strips executables (or not) |
| sysroot | enabled | target | installs the package to the sysroot folder (or not) |