[PATCH 1/3] kbuild: Change CFI_CLANG to depend on __builtin_function_start

Masahiro Yamada masahiroy at kernel.org
Sat Apr 2 06:31:03 PDT 2022


On Sat, Apr 2, 2022 at 5:19 AM Sami Tolvanen <samitolvanen at google.com> wrote:
>
> Clang 14 added support for the __builtin_function_start()
> built-in function, which allows us to implement function_nocfi()
> without architecture-specific inline assembly. This patch changes
> CONFIG_CFI_CLANG to depend on the built-in and effectively upgrades
> the minimum supported compiler version for CFI to Clang 14.

>From this description, I think the straight-forward change would be:

    depends on CLANG_VERSION >= 120000
-->
    depends on CLANG_VERSION >= 140000

Any reason to avoid this?


>
> Signed-off-by: Sami Tolvanen <samitolvanen at google.com>
> ---
>  arch/Kconfig | 5 +----
>  init/Kconfig | 3 +++
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 29b0167c088b..eecfc2809781 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -723,10 +723,7 @@ config ARCH_SUPPORTS_CFI_CLANG
>  config CFI_CLANG
>         bool "Use Clang's Control Flow Integrity (CFI)"
>         depends on LTO_CLANG && ARCH_SUPPORTS_CFI_CLANG
> -       # Clang >= 12:
> -       # - https://bugs.llvm.org/show_bug.cgi?id=46258
> -       # - https://bugs.llvm.org/show_bug.cgi?id=47479
> -       depends on CLANG_VERSION >= 120000
> +       depends on CC_HAS_BUILTIN_FUNCTION_START
>         select KALLSYMS
>         help
>           This option enables Clang’s forward-edge Control Flow Integrity
> diff --git a/init/Kconfig b/init/Kconfig
> index ddcbefe535e9..f024fd353373 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -86,6 +86,9 @@ config CC_HAS_ASM_INLINE
>  config CC_HAS_NO_PROFILE_FN_ATTR
>         def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
>
> +config CC_HAS_BUILTIN_FUNCTION_START
> +       def_bool $(success,echo 'void f(void) {}; void *p = __builtin_function_start(f);' | $(CC) -x c - -c -o /dev/null)
> +
>  config PAHOLE_VERSION
>         int
>         default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
> --
> 2.35.0
>


--
Best Regards
Masahiro Yamada



More information about the linux-arm-kernel mailing list