diff --git a/config/functions b/config/functions index 6cd0b322d3..019ddee78c 100644 --- a/config/functions +++ b/config/functions @@ -299,25 +299,18 @@ get_target_linker() { setup_toolchain() { if [ "$LTO_SUPPORT" = "yes" ]; then - if flag_enabled "lto-parallel" "no"; then - TARGET_CFLAGS+=" $FLAGS_OPTIM_LTO_PARALLEL $FLAGS_OPTIM_LTO_NO_FAT" - TARGET_CXXFLAGS+=" $FLAGS_OPTIM_LTO_PARALLEL $FLAGS_OPTIM_LTO_NO_FAT" - TARGET_LDFLAGS+=" $LDFLAGS_OPTIM_LTO_COMMON $FLAGS_OPTIM_LTO_PARALLEL" - elif flag_enabled "lto-fat" "no"; then - TARGET_CFLAGS+=" $FLAGS_OPTIM_LTO_NO_PARALLEL $FLAGS_OPTIM_LTO_FAT" - TARGET_CXXFLAGS+=" $FLAGS_OPTIM_LTO_NO_PARALLEL $FLAGS_OPTIM_LTO_FAT" - TARGET_LDFLAGS+=" $LDFLAGS_OPTIM_LTO_COMMON $FLAGS_OPTIM_LTO_NO_PARALLEL" + if flag_enabled "lto-fat" "no"; then + TARGET_CFLAGS+=" $FLAGS_OPTIM_LTO $FLAGS_OPTIM_LTO_FAT" + TARGET_CXXFLAGS+=" $FLAGS_OPTIM_LTO $FLAGS_OPTIM_LTO_FAT" elif flag_enabled "lto" "no"; then - TARGET_CFLAGS+=" $FLAGS_OPTIM_LTO_NO_PARALLEL $FLAGS_OPTIM_LTO_NO_FAT" - TARGET_CXXFLAGS+=" $FLAGS_OPTIM_LTO_NO_PARALLEL $FLAGS_OPTIM_LTO_NO_FAT" - TARGET_LDFLAGS+=" $LDFLAGS_OPTIM_LTO_COMMON $FLAGS_OPTIM_LTO_NO_PARALLEL" + TARGET_CFLAGS+=" $FLAGS_OPTIM_LTO $FLAGS_OPTIM_LTO_NO_FAT" + TARGET_CXXFLAGS+=" $FLAGS_OPTIM_LTO $FLAGS_OPTIM_LTO_NO_FAT" fi fi if flag_enabled "lto-off" "no"; then TARGET_CFLAGS+=" $FLAGS_OPTIM_LTO_OFF" TARGET_CXXFLAGS+=" $FLAGS_OPTIM_LTO_OFF" - TARGET_LDFLAGS+=" $FLAGS_OPTIM_LTO_OFF" fi local linker="$(get_target_linker)" diff --git a/config/optimize b/config/optimize index 1c57ae69f7..d3f5cd59fc 100644 --- a/config/optimize +++ b/config/optimize @@ -20,12 +20,10 @@ HOST_CFLAGS="$HOST_CFLAGS -Wno-format-security" HOST_CXXFLAGS="$HOST_CXXFLAGS -Wno-format-security" # lto flags -FLAGS_OPTIM_LTO_NO_PARALLEL="-flto" -FLAGS_OPTIM_LTO_PARALLEL="-flto=${CONCURRENCY_MAKE_LEVEL}" +FLAGS_OPTIM_LTO="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing" FLAGS_OPTIM_LTO_NO_FAT="-fno-fat-lto-objects" FLAGS_OPTIM_LTO_FAT="-ffat-lto-objects" FLAGS_OPTIM_LTO_OFF="-fno-lto" -LDFLAGS_OPTIM_LTO_COMMON="-fuse-linker-plugin" # linker specific flags LDFLAGS_OPTIM_LINKER_COMPILER_DEFAULT="" diff --git a/packages/readme.md b/packages/readme.md index f80e734b32..91993bc18f 100644 --- a/packages/readme.md +++ b/packages/readme.md @@ -122,8 +122,7 @@ Set the variable `PKG_BUILD_FLAGS` in the `package.mk` to enable/disable the sin | pic:host | disabled | host, bootstrap | see above | | speed | disabled | target, init | replaces default `-O2` compiler optimization with `-O3` (can only enable; overrules size) | | size | disabled | target, init | replaces default `-O2` compiler optimization with `-Os` (can only enable) | -| lto | disabled | target, init | enable LTO (Link Time optimization) in the compiler and linker unless disabled via `LTO_SUPPORT`. Compiles non-fat LTO objects (only bytecode) and performs single-threaded optimization at link stage | -| lto-parallel | disabled | target, init | same as `lto` but enables parallel optimization at link stage. Only enable this if the package build doesn't run multiple linkers in parallel otherwise this can result in lots of parallel processes! | +| lto | disabled | target, init | enable LTO (Link Time optimization) in the compiler and linker unless disabled via `LTO_SUPPORT`. Compiles non-fat LTO objects (only bytecode) and automatically determines number of threads to use for optimization at link stage | | lto-fat | disabled | target, init | same as `lto` but compile fat LTO objects (bytecode plus optimized assembly). This increases compile time but can be useful to create static libraries suitable both for LTO and non-LTO linking | | 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 |