[PATCH v2 16/30] Makefile: Disable LTO when not building with gcc

Bin Meng bmeng.cn at gmail.com
Mon May 1 11:16:19 CEST 2023


Hi Simon,

On Sun, Apr 30, 2023 at 9:30 AM Simon Glass <sjg at chromium.org> wrote:
>
> For MSYS2 this creates a lot of errors of the form:
>
> `__stack_chk_fail' referenced in section `.text' of ...ltrans.o: defined
>    in discarded section `.text' of common/stackprot.o (symbol from plugin)
>
> For clang it doesn't work, except with sandbox.

To clarify, you didn't use clang on Windows to build Sandbox?

>
> Update the dependency to (hopefully) deal with all of that.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v2:
> - Make LTO depend on !MSYS2 rather than adding another check
> - Also disable LTO for clang, except with sandbox
>
>  Kconfig | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/Kconfig b/Kconfig
> index 888b9984ac3b..9ac816abef1c 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -72,6 +72,9 @@ config CLANG_VERSION
>         int
>         default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
>
> +config CC_IS_MSYS
> +       def_bool $(success,uname -o | grep -q Msys)
> +
>  choice
>         prompt "Optimization level"
>         default CC_OPTIMIZE_FOR_SIZE
> @@ -121,6 +124,8 @@ config ARCH_SUPPORTS_LTO
>  config LTO
>         bool "Enable Link Time Optimizations"
>         depends on ARCH_SUPPORTS_LTO
> +       depends on CC_IS_GCC || (CC_IS_CLANG && SANDBOX)

This looks like a separate patch needed for adding dependency check for LTO?

> +       depends on !CC_IS_MSYS
>         help
>           This option enables Link Time Optimization (LTO), a mechanism which
>           allows the compiler to optimize between different compilation units.
> --

Regards,
Bin


More information about the U-Boot mailing list